mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-09 01:03:51 +01:00
No longer move context sub-menu to left if there's even less space there
Probably still moving too often to the left - should find some better solution. But at least some improvement. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6471 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
37d821dcc3
commit
e55af78b31
@ -673,19 +673,22 @@ void CGUIContextMenu::recalculateSize()
|
||||
if ( root )
|
||||
{
|
||||
core::rect<s32> rectRoot( root->getAbsolutePosition() );
|
||||
core::rect<s32> absRect( getAbsolutePosition() );
|
||||
|
||||
// if it would be drawn beyond the right border, then add it to the left side
|
||||
if ( getAbsolutePosition().UpperLeftCorner.X+subRect.LowerRightCorner.X > rectRoot.LowerRightCorner.X )
|
||||
// if it would be drawn beyond the right border, then add it to the left side - if there is more space
|
||||
irr::s32 beyondRight = absRect.UpperLeftCorner.X+subRect.LowerRightCorner.X-rectRoot.LowerRightCorner.X;
|
||||
irr::s32 beyondLeft = -(absRect.UpperLeftCorner.X - w - rectRoot.UpperLeftCorner.X);
|
||||
if ( beyondRight > 0 && beyondRight > beyondLeft )
|
||||
{
|
||||
subRect.UpperLeftCorner.X = -w;
|
||||
subRect.LowerRightCorner.X = 0;
|
||||
}
|
||||
|
||||
// if it would be drawn below bottom border, move it up, but not further than to top.
|
||||
irr::s32 belowBottom = getAbsolutePosition().UpperLeftCorner.Y+subRect.LowerRightCorner.Y - rectRoot.LowerRightCorner.Y;
|
||||
irr::s32 belowBottom = absRect.UpperLeftCorner.Y+subRect.LowerRightCorner.Y - rectRoot.LowerRightCorner.Y;
|
||||
if ( belowBottom > 0 )
|
||||
{
|
||||
irr::s32 belowTop = getAbsolutePosition().UpperLeftCorner.Y+subRect.UpperLeftCorner.Y;
|
||||
irr::s32 belowTop = absRect.UpperLeftCorner.Y+subRect.UpperLeftCorner.Y;
|
||||
irr::s32 moveUp = belowBottom < belowTop ? belowBottom : belowTop;
|
||||
subRect.UpperLeftCorner.Y -= moveUp;
|
||||
subRect.LowerRightCorner.Y -= moveUp;
|
||||
|
Loading…
Reference in New Issue
Block a user