Alexander Wels has uploaded a new change for review.

Change subject: userportal,webadmin: sub menu positioning
......................................................................

userportal,webadmin: sub menu positioning

- When a sub menu (such as the reports) would show up and
  there was no enough room to show the menu to the right and
  below the menu, it would move the sub menu higher so it can
  fit on the screen, but it would not take into account that
  the bottom of the sub menu needs to line up with the bottom
  of the item of menu that is associated with the sub menu.
  This patch does take the height of the menu item into account
  when calculating the position of the sub menu.

Change-Id: I8500c8737ec24d3ade438c6924620eedc7b4fc55
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1184983
Signed-off-by: Alexander Wels <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/PopupUtils.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/MenuBar.java
2 files changed, 8 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/97/37297/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/PopupUtils.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/PopupUtils.java
index 88ab452..ea73aa2 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/PopupUtils.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/utils/PopupUtils.java
@@ -15,7 +15,7 @@
     public static void adjustPopupLocationToFitScreenAndShow(final PopupPanel 
popup,
             int left,
             int top,
-            MenuBar parentMenu) {
+            MenuBar parentMenu, int itemHeight) {
 
         Style style = popup.getElement().getStyle();
 
@@ -25,14 +25,15 @@
         style.setProperty("width", "auto"); //$NON-NLS-1$ //$NON-NLS-2$
 
         popup.show();
-        adjustPopupLocationToFitScreenAndShow(popup, left, top, 
-parentMenu.getOffsetWidth(), 0);
+        adjustPopupLocationToFitScreenAndShow(popup, left, top, 
-parentMenu.getOffsetWidth(), 0, itemHeight);
     }
 
     private static void adjustPopupLocationToFitScreenAndShow(final PopupPanel 
popup,
             int relativeLeft,
             int relativeTop,
             int relativeWidth,
-            int relativeHeight) {
+            int relativeHeight,
+            int itemHeight) {
         Style style = popup.getElement().getStyle();
 
         /* We need this code because the gwt MenuBar- openPopupMethod, sets 
the position of the subMenu popup. It can't be overridden.
@@ -73,7 +74,7 @@
             top += relativeHeight;
         }
         else if (distanceFromWindowTop >= popup.getOffsetHeight()) {
-            top -= popup.getOffsetHeight();
+            top -= popup.getOffsetHeight() - itemHeight;
         } else {// Position above the relative object and add scroll
             top += relativeHeight;
             style.setHeight(distanceToWindowBottom, Unit.PX);
@@ -182,10 +183,10 @@
                 relativeObject.getAbsoluteLeft(),
                 relativeObject.getAbsoluteTop(),
                 relativeObject.getOffsetWidth(),
-                relativeObject.getOffsetHeight());
+                relativeObject.getOffsetHeight(), 0);
     }
 
     public static void adjustPopupLocationToFitScreenAndShow(final PopupPanel 
popup, int left, int top) {
-        adjustPopupLocationToFitScreenAndShow(popup, left, top, 0, 0);
+        adjustPopupLocationToFitScreenAndShow(popup, left, top, 0, 0, 0);
     }
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/MenuBar.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/MenuBar.java
index cfba3af..1d12329 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/MenuBar.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/MenuBar.java
@@ -47,7 +47,7 @@
                 if (subMenuPopup != null) {
                     
PopupUtils.adjustPopupLocationToFitScreenAndShow(subMenuPopup,
                             subMenuPopup.getAbsoluteLeft(),
-                            subMenuPopup.getAbsoluteTop(), this);
+                            subMenuPopup.getAbsoluteTop(), this, 
item.getOffsetHeight());
                 }
             }
             break;


-- 
To view, visit http://gerrit.ovirt.org/37297
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8500c8737ec24d3ade438c6924620eedc7b4fc55
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alexander Wels <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to