Perform a better fitting for menu's in a bounded region, so they'll position themself for

maximum visibility even if they can't fully pop up/down, left/right.  (Menu's larger than 
the bounded area will still have some issues).


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@417 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Mark Johnson
2008-02-16 01:01:14 +00:00
parent ba7dadba97
commit 7e804e60c5
+19 -1
View File
@@ -72,7 +72,7 @@ use namespace mx_internal;
* ];
*
* See "Defining menu structure and data" in the Flex manual for the full list.
*/
*/
public class CommandMenu extends Menu
{
/**
@@ -139,9 +139,16 @@ public class CommandMenu extends Menu
if (mx + getExplicitOrMeasuredWidth() > bounds.right) {
mx -= getExplicitOrMeasuredWidth();
}
if (mx < bounds.left) {
mx = Math.max(bounds.right - getExplicitOrMeasuredWidth(), bounds.left);
}
// if we've poped out of the boundaries, just snap it to the lower right corner
if (my + getExplicitOrMeasuredHeight() > bounds.bottom) {
my -= getExplicitOrMeasuredHeight();
}
if (my < bounds.top) {
my = Math.max(bounds.bottom - getExplicitOrMeasuredHeight(), bounds.top);
}
// finally move it to the correct position
x = mx;
@@ -265,6 +272,17 @@ public class CommandMenu extends Menu
if (upping) {
submenu.y -= (submenu.getExplicitOrMeasuredHeight() - DisplayObject(row).height);
}
// if we've poped out of the boundaries, just snap it to the lower right corner
if (_fitting != null) {
if (submenu.x < _fitting.left) {
submenu.x = Math.max(
_fitting.right - submenu.getExplicitOrMeasuredWidth(), _fitting.left);
}
if (submenu.y < _fitting.top) {
submenu.y = Math.max(
_fitting.bottom - submenu.getExplicitOrMeasuredHeight(), _fitting.top);
}
}
}
// from List