diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2005-09-25 19:04:04 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2005-09-25 19:04:04 +0000 |
| commit | 60812b2ecc615a5ce40fa9a4c93c170c06f4282e (patch) | |
| tree | d3a5b04f55a050866b1a702f97b2f92173747ae2 /src | |
| parent | ba56eeaad57d232894ca2bfbb0c2f3e137c6546f (diff) | |
STR #973: popup menus now pop up fully visible in the current screen if possible and useful. In detail, menus in a menubar will pop up above the title if they would cut into the screen bottom. Submenus will show the *last* item to the right of the parent instead of the first. Finally, Pulldowns with title will simply apppera over the title instead of under the title.
There are two exceptions:
Menus that have a selected item will not be modified, so the selected item is visible. Hence an Fl_Choice will never have a 'fixed' menu.
If putting the menu high would intersect the top frame of the screen, we leave the menu at the bottom.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4584 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Menu.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 16ea170f2..533811c72 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -306,8 +306,24 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp, h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+3); if (selected >= 0) Y = Y+(Hp-itemheight)/2-selected*itemheight-BW; - else + else { Y = Y+Hp; + // if the menu hits the bottom of the screen, we try to draw + // it above the menubar instead. We will not adjust any menu + // that has a selected item. + if (Y+h()>scr_y+scr_h && Y-h()>=scr_y) { + if (Hp>1) + // if we know the height of the Fl_Menu_, use it + Y = Y-Hp-h(); + else if (t) + // assume that the menubar item height relates to the first + // menuitem as well + Y = Y-itemheight-h()-Fl::box_dh(box()); + else + // draw the menu to the right + Y = Y-h()+itemheight+Fl::box_dy(box()); + } + } if (m) y(Y); else {y(Y-2); w(1); h(1);} if (t) { |
