summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2010-11-09 14:43:19 +0000
committerArtur Signell <artur.signell@itmill.com>2010-11-09 14:43:19 +0000
commit7d66ded78c70d608d2f8aeb2f0c8c3b466ec6273 (patch)
tree4c623f033c83ca08cf39b8cab61505efbe0c97f7 /src
parent7fd0e6e1d4f1895de65858e09e26c26f49244211 (diff)
downloadvaadin-framework-7d66ded78c70d608d2f8aeb2f0c8c3b466ec6273.tar.gz
vaadin-framework-7d66ded78c70d608d2f8aeb2f0c8c3b466ec6273.zip
Fix for #5894 Right aligned Menubar with Icons runs out of browser
Fix for #5906 Menu shadow is too narrow in Chrome7 svn changeset:15936/svn branch:6.5
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index 8fc56250a9..1ee7040295 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -41,6 +41,9 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
CloseHandler<PopupPanel>, ContainerResizedListener, KeyPressHandler,
KeyDownHandler, FocusHandler, SubPartAware {
+ // The hierarchy of VMenuBar is a bit weird as VMenuBar is the Paintable,
+ // used for the root menu but also used for the sub menus.
+
/** Set the CSS class name to allow styling. */
public static final String CLASSNAME = "v-menubar";
@@ -51,6 +54,8 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
protected final VMenuBar hostReference = this;
protected String submenuIcon = null;
protected CustomMenuItem moreItem = null;
+
+ // Only used by the root menu bar
protected VMenuBar collapsedRootItems;
// Construct an empty command to be used when the item has no command
@@ -272,7 +277,7 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
}
}// while
- iLayout();
+ iLayout(false);
}// updateFromUIDL
@@ -396,7 +401,16 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
// Handle onload events (icon loaded, size changes)
if (DOM.eventGetType(e) == Event.ONLOAD) {
- requestLayout();
+ VMenuBar parent = getParentMenu();
+ if (parent != null) {
+ // The onload event for an image in a popup should be sent to
+ // the parent, which owns the popup
+ parent.iconLoaded();
+ } else {
+ // Onload events for images in the root menu are handled by the
+ // root menu itself
+ iconLoaded();
+ }
return;
}
@@ -460,13 +474,13 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
return enabled;
}
- private void requestLayout() {
+ private void iconLoaded() {
if (layoutTimer == null) {
layoutTimer = new Timer() {
@Override
public void run() {
layoutTimer = null;
- iLayout();
+ iLayout(true);
}
};
}
@@ -747,6 +761,14 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
setStyleName(CLASSNAME + "-menuitem");
sinkEvents(VTooltip.TOOLTIP_EVENTS);
+
+ // Sink the onload event for an icon (if it exists). The onload
+ // events are handled by the parent VMenuBar.
+ NodeList<com.google.gwt.dom.client.Element> imgElements = getElement()
+ .getElementsByTagName("img");
+ for (int i = 0; i < imgElements.getLength(); i++) {
+ DOM.sinkEvents((Element) imgElements.getItem(i), Event.ONLOAD);
+ }
}
public void setSelected(boolean selected) {
@@ -883,6 +905,10 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
private int paddingWidth = -1;
public void iLayout() {
+ iLayout(false);
+ }
+
+ public void iLayout(boolean iconLoadEvent) {
// Only collapse if there is more than one item in the root menu and the
// menu has an explicit size
if ((getItems().size() > 1 || (collapsedRootItems != null && collapsedRootItems
@@ -965,6 +991,17 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
addItem(moreItem);
}
}
+
+ // If a popup is open we might need to adjust the shadow as well if an
+ // icon shown in that popup was loaded
+ if (popup != null) {
+ // Forces a recalculation of the shadow size
+ popup.show();
+ }
+ if (iconLoadEvent) {
+ // Size have changed if the width is undefined
+ Util.notifyParentOfSizeChange(this, false);
+ }
}
private int getConsumedWidth() {