MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / findHitControls

Method findHitControls

Engine/source/gui/core/guiControl.cpp:1976–2035  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1974//-----------------------------------------------------------------------------
1975
1976bool GuiControl::findHitControls( const RectI& rect, Vector< GuiControl* >& outResult, U32 flags, S32 initialLayer, U32 depth )
1977{
1978 if( !mVisible )
1979 return false;
1980 else if( !mCanHit && flags & HIT_NoCanHitNoRecurse )
1981 return false;
1982
1983 // Check for hit. If not full-box, always counts.
1984
1985 bool isHit = mVisible;
1986 if( flags & HIT_FullBoxOnly )
1987 {
1988 RectI rectInParentSpace = rect;
1989 rectInParentSpace.point += getPosition();
1990
1991 isHit &= rectInParentSpace.contains( getBounds() );
1992 }
1993 else
1994 isHit &= mCanHit;
1995
1996 // If we have a hit and should not recurse into children,
1997 // return us.
1998
1999 if( isHit && flags & HIT_ParentPreventsChildHit && depth > 0 )
2000 {
2001 outResult.push_back( this );
2002 return true;
2003 }
2004
2005 // Check child controls.
2006
2007 bool haveFoundChild = false;
2008 iterator i = end();
2009
2010 while( i != begin() )
2011 {
2012 i --;
2013
2014 GuiControl* ctrl = static_cast< GuiControl* >( *i );
2015 if( initialLayer >= 0 && ctrl->mLayer > initialLayer )
2016 continue;
2017
2018 if( ctrl->getBounds().overlaps( rect ) )
2019 {
2020 RectI transposedRect = rect;
2021 transposedRect.point -= ctrl->getPosition();
2022
2023 if( ctrl->findHitControls( transposedRect, outResult, flags, -1, depth + 1 ) )
2024 haveFoundChild = true;
2025 }
2026 }
2027
2028 if( ( !haveFoundChild || flags & HIT_AddParentHits ) && isHit )
2029 {
2030 outResult.push_back( this );
2031 return true;
2032 }
2033

Callers 3

guiControl.cppFile · 0.80
doControlSnapMethod · 0.80

Calls 8

getBoundsFunction · 0.85
endFunction · 0.85
beginFunction · 0.85
overlapsMethod · 0.80
containsMethod · 0.45
push_backMethod · 0.45
getBoundsMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected