| 1989 | //----------------------------------------------------------------------------- |
| 1990 | |
| 1991 | bool GuiControl::findHitControls( const RectI& rect, Vector< GuiControl* >& outResult, U32 flags, S32 initialLayer, U32 depth ) |
| 1992 | { |
| 1993 | if( !mVisible ) |
| 1994 | return false; |
| 1995 | else if( !mCanHit && flags & HIT_NoCanHitNoRecurse ) |
| 1996 | return false; |
| 1997 | |
| 1998 | // Check for hit. If not full-box, always counts. |
| 1999 | |
| 2000 | bool isHit = mVisible; |
| 2001 | if( flags & HIT_FullBoxOnly ) |
| 2002 | { |
| 2003 | RectI rectInParentSpace = rect; |
| 2004 | rectInParentSpace.point += getPosition(); |
| 2005 | |
| 2006 | isHit &= rectInParentSpace.contains( getBounds() ); |
| 2007 | } |
| 2008 | else |
| 2009 | isHit &= mCanHit; |
| 2010 | |
| 2011 | // If we have a hit and should not recurse into children, |
| 2012 | // return us. |
| 2013 | |
| 2014 | if( isHit && flags & HIT_ParentPreventsChildHit && depth > 0 ) |
| 2015 | { |
| 2016 | outResult.push_back( this ); |
| 2017 | return true; |
| 2018 | } |
| 2019 | |
| 2020 | // Check child controls. |
| 2021 | |
| 2022 | bool haveFoundChild = false; |
| 2023 | iterator i = end(); |
| 2024 | |
| 2025 | while( i != begin() ) |
| 2026 | { |
| 2027 | i --; |
| 2028 | |
| 2029 | GuiControl* ctrl = static_cast< GuiControl* >( *i ); |
| 2030 | if( initialLayer >= 0 && ctrl->mLayer > initialLayer ) |
| 2031 | continue; |
| 2032 | |
| 2033 | if( ctrl->getBounds().overlaps( rect ) ) |
| 2034 | { |
| 2035 | RectI transposedRect = rect; |
| 2036 | transposedRect.point -= ctrl->getPosition(); |
| 2037 | |
| 2038 | if( ctrl->findHitControls( transposedRect, outResult, flags, -1, depth + 1 ) ) |
| 2039 | haveFoundChild = true; |
| 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | if( ( !haveFoundChild || flags & HIT_AddParentHits ) && isHit ) |
| 2044 | { |
| 2045 | outResult.push_back( this ); |
| 2046 | return true; |
| 2047 | } |
| 2048 |
no test coverage detected