summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2015-11-23 11:53:30 +0100
committerRémi Verschelde <remi@verschelde.fr>2015-11-23 11:53:30 +0100
commit2fbc1445a542688bfe08ffde9d130aa9e8ef4a33 (patch)
tree477d5d4a61924a863993f07019057fe270223983
parentaa30e01f264220dcfd63c60c731a7e9c7ef6ee2b (diff)
parent9797b6374bff3845130e31029eeaa544ca546653 (diff)
Merge pull request #2870 from neikeq/submenu_pos_fix
Popup submenu position enhancement
-rw-r--r--scene/gui/popup_menu.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 99663fb2e2..20f28ecf10 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -170,7 +170,14 @@ void PopupMenu::_activate_submenu(int over) {
Point2 p = get_global_pos();
Rect2 pr(p,get_size());
Ref<StyleBox> style = get_stylebox("panel");
- pm->set_pos(p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y));
+
+ Point2 pos = p+Point2(get_size().width,items[over]._ofs_cache-style->get_offset().y);
+ Size2 size = pm->get_size();
+ // fix pos
+ if (pos.x+size.width > get_viewport_rect().size.width)
+ pos.x=p.x-size.width;
+
+ pm->set_pos(pos);
pm->popup();
PopupMenu *pum = pm->cast_to<PopupMenu>();