From f35b63ef9533241f9411118802d22928218959fd Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 15 Apr 2014 14:26:33 +0400 Subject: [PATCH] fixes --- examples/example1/main.d | 7 +++++++ src/dlangui/widgets/menu.d | 2 +- src/dlangui/widgets/popup.d | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/example1/main.d b/examples/example1/main.d index f59957c7..3e569ae3 100644 --- a/examples/example1/main.d +++ b/examples/example1/main.d @@ -53,6 +53,13 @@ extern (C) int UIAppMain(string[] args) { MenuItem fileItem = new MenuItem(new Action(1, "File"d)); fileItem.add(new Action(10, "Open..."d)); fileItem.add(new Action(11, "Save..."d)); + MenuItem openRecentItem = new MenuItem(new Action(13, "Open recent..."d)); + openRecentItem.add(new Action(100, "File 1"d)); + openRecentItem.add(new Action(101, "File 2"d)); + openRecentItem.add(new Action(102, "File 3"d)); + openRecentItem.add(new Action(103, "File 4"d)); + openRecentItem.add(new Action(104, "File 5"d)); + fileItem.add(openRecentItem); fileItem.add(new Action(12, "Exit"d)); MenuItem editItem = new MenuItem(new Action(2, "Edit"d)); editItem.add(new Action(20, "Copy"d)); diff --git a/src/dlangui/widgets/menu.d b/src/dlangui/widgets/menu.d index 44110205..45eb21d8 100644 --- a/src/dlangui/widgets/menu.d +++ b/src/dlangui/widgets/menu.d @@ -113,7 +113,7 @@ class MenuWidgetBase : ListWidget { _openedPopup.close(); } PopupMenu popupMenu = new PopupMenu(itemWidget.item, this); - PopupWidget popup = window.showPopup(popupMenu, itemWidget, PopupAlign.Below); + PopupWidget popup = window.showPopup(popupMenu, itemWidget, orientation == Orientation.Horizontal ? PopupAlign.Below : PopupAlign.Right); popup.onPopupCloseListener = &onPopupClosed; popup.flags = PopupFlags.CloseOnClickOutside; _openedPopup = popup; diff --git a/src/dlangui/widgets/popup.d b/src/dlangui/widgets/popup.d index cba6018d..3dc4c3ee 100644 --- a/src/dlangui/widgets/popup.d +++ b/src/dlangui/widgets/popup.d @@ -10,6 +10,8 @@ enum PopupAlign : uint { Center = 1, /// place popup below anchor widget close to lower bound Below = 2, + /// place popup below anchor widget close to right bound (when no space enough, align near left bound) + Right = 4, } struct PopupAnchor { @@ -90,6 +92,9 @@ class PopupWidget : LinearLayout { } else if (anchor.alignment & PopupAlign.Below) { r.left = anchorrc.left; r.top = anchorrc.bottom; + } else if (anchor.alignment & PopupAlign.Right) { + r.left = anchorrc.right; + r.top = anchorrc.top; } r.right = r.left + w; r.bottom = r.top + h;