1. CEGUI team
  2. CEGUI
  3. CEGUI
  4. Pull requests

Pull requests

#233 Open

Popup menu positioning (was PR #231)

Bitbucket cannot automatically merge this request.

The commits that make up this pull request have been removed.

Bitbucket cannot automatically merge this request due to conflicts.

Review the conflicts on the Overview tab. You can then either decline the request or merge it manually on your local system using the following commands:

hg update default
hg pull -r popup_menu_positioning https://bitbucket.org/cbeck88/cegui
hg merge popup_menu_positioning
hg commit -m 'Merged in cbeck88/cegui/popup_menu_positioning (pull request #233)'
  1. Christopher Beck

This adds "smart" popup placement which avoids getting the menus clipped by the screen, and makes that the default behavior.

The manual "popup offset" member variable is removed in favor of a virtual member function which computes the appropriate offset on demand. (This was the consensus solution in discussion following PR #231)

Comments (2)

  1. Christopher Beck author


    There's a few changes from the original PR:

    1: I moved the "set position" code in MenuItem::openPopupMenu() to after the if (notify && p) block. I did this because on code review, that does always trigger a later call to MenuItem::openPopupMenu(false), it seems cleaner to do parent notification completely before we start doing anything with the popup menu, and then set its position and open it at the same time. I don't think this is a behavior change, just reorganization.

    2: I changed the way I determine the popup menu bounding box. In original PR I was using this: p->getParent() ? p->getParent()->getClipRect(false) : Rectf(Vector2f(0, 0), getRootContainerSize()) but in testing I concluded that doesn't always give good behavior. It's a bit fiddly unfortunately... I decided to just use the root container dimensions for now, since that's simple and gives good results in my programs. I put this bit of code in a virtual function to make it easier to tweak it if desired.