Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[VisUI] SubMenu may be out of the screen if it larger then stage's width #220

Closed
metaphore opened this issue Oct 2, 2016 · 6 comments
Closed

Comments

@metaphore
Copy link
Contributor

metaphore commented Oct 2, 2016

I encountered with pretty strange behavior, once my SubMenu is no longer visible anymore. Then I noticed that problem occurs only if there is not enough width for submenu.

So here is a code that resposible for the situation MenuItem#showSubMenu():

Vector2 pos = localToStageCoordinates(tmpVector.setZero());

float subMenuX;
if (pos.x + getWidth() + subMenu.getWidth() >= stage.getWidth()) { //if won't fit on screen
    subMenuX = pos.x - subMenu.getWidth() + 1;
} else {
    subMenuX = pos.x + getWidth() - 1;
}
subMenu.setPosition(subMenuX, pos.y - subMenu.getHeight() + getHeight());

It looks very strange, because it always places SubMenu to the left to MenuItem, and in most cases it could be even worse then displaying only portion to the right. For example, my MenuItem at the most left corner of a screen, and screen width is less then SubMenu's width. So we've got SubMenu completely out of the screen.

Perhaps this conditional check must be a little bit more complicate, it should check whether it's better to display submenu to the left or right to parent menu and has an addition special case when there is not enough width, then act somehow very specific, like place submenu to the most left corner of a screen.

@kotcrab kotcrab added the ui label Oct 2, 2016
@kotcrab
Copy link
Owner

kotcrab commented Oct 2, 2016

Are you using 1.2.2 or newer? This was most likely fixed in 9f473c2.

@metaphore
Copy link
Contributor Author

It's 1.2.3 and you referenced exact that cahnge that stands for current issue

@metaphore metaphore changed the title [VisUI] SubMenu is always out of the screen if it doesn't fit stage's width [VisUI] SubMenu may be out of the screen if it larger then stage's width Oct 2, 2016
@kotcrab
Copy link
Owner

kotcrab commented Oct 2, 2016

For me, it wasn't working before this change. Please provide SSCCE.

That if places submenu to the left if there isn't enough space to fully display submenu on the right. The version before doesn't make sense because it uses width of current MenuItem to offset submenu to the right, I don't really know why it was working before, probably when I was testing I used menus with same widths.

@metaphore
Copy link
Contributor Author

Perhaps this gif will be enough to demonstrate the issue:

Alt Text

@kotcrab
Copy link
Owner

kotcrab commented Oct 3, 2016

Yep this explains it, it's working as intended: not enough space on the right so it displays on the left. Too bad there is 0 available space on the left. I will make it always prefer side that has more available space.

@kotcrab kotcrab closed this as completed in faa6765 Oct 3, 2016
@kotcrab
Copy link
Owner

kotcrab commented Oct 3, 2016

Done, thanks for reporting.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants