MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _hitTest

Method _hitTest

Engine/source/gui/controls/guiTreeViewCtrl.cpp:1921–1995  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1919//------------------------------------------------------------------------------
1920
1921bool GuiTreeViewCtrl::_hitTest(const Point2I & pnt, Item* & item, BitSet32 & flags)
1922{
1923 // Initialize some things.
1924 const Point2I pos = globalToLocalCoord(pnt);
1925 flags.clear();
1926 item = 0;
1927
1928 // get the hit cell
1929 Point2I cell((pos.x < 0 ? -1 : pos.x / mCellSize.x),
1930 (pos.y < 0 ? -1 : pos.y / mCellSize.y));
1931
1932 // valid?
1933 if((cell.x < 0 || cell.x >= mSize.x) ||
1934 (cell.y < 0 || cell.y >= mSize.y))
1935 return false;
1936
1937 flags.set(OnRow);
1938
1939 // Grab the cell.
1940 if (cell.y >= mVisibleItems.size())
1941 return false; //Invalid cell, so don't do anything
1942
1943 item = mVisibleItems[cell.y];
1944
1945 S32 min = mTabSize * item->mTabLevel;
1946
1947 // left of icon/text?
1948 if(pos.x < min)
1949 {
1950 flags.set(OnIndent);
1951 return true;
1952 }
1953
1954 // check image
1955 S32 image = BmpChild;
1956
1957 if(item->isInspectorData())
1958 image = item->isExpanded() ? BmpExp : BmpCon;
1959 else
1960 image = item->isExpanded() ? item->getExpandedImage() : item->getNormalImage();
1961
1962 if((image >= 0) && (image < mProfile->mBitmapArrayRects.size()))
1963 min += mProfile->mBitmapArrayRects[image].extent.x;
1964
1965 // Is it on the image?
1966 if(pos.x < min)
1967 {
1968 flags.set(OnImage);
1969 return(true);
1970 }
1971
1972 // Check the icon.
1973 min += getInspectorItemIconsWidth( item );
1974
1975 if ( pos.x < min )
1976 {
1977 flags.set(OnIcon);
1978 return true;

Callers

nothing calls this directly

Calls 11

isInspectorDataMethod · 0.80
getExpandedImageMethod · 0.80
getNormalImageMethod · 0.80
getDisplayTextLengthMethod · 0.80
getDisplayTextMethod · 0.80
getStrWidthMethod · 0.80
clearMethod · 0.45
setMethod · 0.45
sizeMethod · 0.45
isExpandedMethod · 0.45
allocMethod · 0.45

Tested by

no test coverage detected