Skip to content

Commit f546391

Browse files
committed
Support for popup menus flipping upside instead downside
1 parent 1157b82 commit f546391

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

projects/jar/src/app/java/echopointng/Menu.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ public class Menu extends MenuItem {
8989

9090
public static final String PROPERTY_HORIZONTAL = "horizontal";
9191

92+
public static final String PROPERTY_FLIP = "flip";
93+
9294
public static final String PROPERTY_KEEP_ALIVE = "keepAlive";
9395

9496
public static final String PROPERTY_LEFT_OFFSET = "leftOffset";
@@ -151,6 +153,7 @@ public class Menu extends MenuItem {
151153

152154
style.setProperty(PROPERTY_TEXT_ALIGNMENT, new Alignment(Alignment.CENTER, Alignment.CENTER));
153155
style.setProperty(PROPERTY_HORIZONTAL, false);
156+
style.setProperty(PROPERTY_FLIP, false);
154157
style.setProperty(PROPERTY_STYLE_CHILDREN, true);
155158

156159
DEFAULT_STYLE = style;
@@ -396,6 +399,13 @@ public boolean isHorizontal() {
396399
return ComponentEx.getProperty(this, PROPERTY_HORIZONTAL, false);
397400
}
398401

402+
/**
403+
* @return true if the Menu is flipped over
404+
*/
405+
public boolean isFlipped() {
406+
return ComponentEx.getProperty(this, PROPERTY_FLIP, false);
407+
}
408+
399409
/**
400410
* @return true if drop down menu boxes will stay alive (ie visible) when
401411
* the mouse moves out of them
@@ -458,6 +468,13 @@ public void setHorizontal(boolean newValue) {
458468
ComponentEx.setProperty(this, PROPERTY_HORIZONTAL, newValue);
459469
}
460470

471+
/**
472+
* Sets the whether the <code>Menu</code> is flipped over
473+
*/
474+
public void setFlipped(boolean newValue) {
475+
ComponentEx.setProperty(this, PROPERTY_FLIP, newValue);
476+
}
477+
461478
/**
462479
* Set to true if drop down menu boxes will stay alive (ie visible) when the
463480
* mouse moves out of them

projects/jar/src/app/java/echopointng/MenuBar.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public class MenuBar extends Menu implements Positionable {
6060
static {
6161
MutableStyleEx style = new MutableStyleEx(Menu.DEFAULT_STYLE);
6262
style.setProperty(PROPERTY_HORIZONTAL, true);
63+
style.setProperty(PROPERTY_FLIP, false);
6364

6465
//style.setProperty(PROPERTY_BACKGROUND,ColorKit.makeColor("#D4D0C8"));
6566

projects/jar/src/ui/java/echopointng/ui/resource/js/menu.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ EPMI.MessageProcessor.processInit = function(initMessageElement) {
147147

148148
mi.isRootMenu = item.getAttribute("isRootMenu") === "true";
149149
mi.horizontal = item.getAttribute("horizontal")==="true";
150+
mi.flip = item.getAttribute("flip")==="true";
150151
mi.keepAlive = item.getAttribute("keepAlive")==="true";
151152
mi.clickToOpen = item.getAttribute("clickToOpen")==="true";
152153
mi.submenuClickToOpen = item.getAttribute("submenuClickToOpen")==="true";
@@ -568,10 +569,10 @@ EPMI.prototype.showBoxImpl = function() {
568569
if (this.parent && this.parent.eBox && ! horizontal) {
569570
itemWidth = EP.getWidth(this.parent.eBox);
570571
}
571-
572+
572573
var x = targetX + this.leftOffset;
573574
// if the Menu is vertical and not the root Menu, then adjust by the width
574-
if (! horizontal && this.getLevel() > 0) {
575+
if (!horizontal && this.getLevel() > 0) {
575576
x += itemWidth;
576577
}
577578
// if too wide then try to align to left of item
@@ -583,11 +584,11 @@ EPMI.prototype.showBoxImpl = function() {
583584
}
584585
}
585586

586-
var y = targetY + this.topOffset;
587+
var y = this.flip ? targetY - this.topOffset : targetY + this.topOffset;
587588
// if the menu is horizontal or a top level one then
588589
// adjust by the height
589590
if (horizontal || this.getLevel() === 0) {
590-
y += itemHeight;
591+
y = this.flip ? y - boxHeight : y + itemHeight;
591592
}
592593

593594
EP.debug("x = " + x + " y=" + y + " targetX=" + targetX + " targetY="+targetY);

projects/jar/src/ui/java/echopointng/ui/syncpeer/MenuItemPeer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ protected void createMenuItemInitDirective(RenderingContext rc, Component compon
420420
itemElement.setAttribute("leftOffset", String.valueOf(rc.getRP(Menu.PROPERTY_LEFT_OFFSET, fallbackStyle)));
421421
itemElement.setAttribute("topOffset", String.valueOf(rc.getRP(Menu.PROPERTY_TOP_OFFSET, fallbackStyle)));
422422
itemElement.setAttribute("horizontal", String.valueOf(rc.getRP(Menu.PROPERTY_HORIZONTAL, fallbackStyle)));
423+
itemElement.setAttribute("flip", String.valueOf(rc.getRP(Menu.PROPERTY_FLIP, fallbackStyle)));
423424
itemElement.setAttribute("keepAlive", String.valueOf(rc.getRP(Menu.PROPERTY_KEEP_ALIVE, fallbackStyle)));
424425
itemElement.setAttribute("submenuImageBordered", String.valueOf(rc.getRP(Menu.PROPERTY_SUBMENU_IMAGE_BORDERED, fallbackStyle)));
425426
itemElement.setAttribute("clickToOpen", String.valueOf(clickToOpen));

readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
EchoPointNG Read Me
44
====================================================
55

6+
------ Version 2.2.2 --------------
7+
Support for popup menus flipping upside instead downside
8+
69
------ Version 2.2.1-a6d923b2d --------------
710
Fix minor memory leak with images.
811
Bugfix: Selection clear removed content.

0 commit comments

Comments
 (0)