summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index edfd43cc..b487e13d 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -733,12 +733,13 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
733 return menu; 733 return menu;
734} 734}
735 735
736void openMenu_Widget(iWidget *d, iInt2 coord) { 736void openMenu_Widget(iWidget *d, iInt2 windowCoord) {
737 openMenuFlags_Widget(d, coord, iTrue); 737 openMenuFlags_Widget(d, windowCoord, iTrue);
738} 738}
739 739
740void openMenuFlags_Widget(iWidget *d, iInt2 coord, iBool postCommands) { 740void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, iBool postCommands) {
741 const iInt2 rootSize = size_Window(get_Window()); 741 const iRect rootRect = rect_Root(d->root);
742 const iInt2 rootSize = rootRect.size;
742 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); 743 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App());
743 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0; 744 const iBool isSlidePanel = (flags_Widget(d) & horizontalOffset_WidgetFlag) != 0;
744 if (postCommands) { 745 if (postCommands) {
@@ -756,7 +757,7 @@ void openMenuFlags_Widget(iWidget *d, iInt2 coord, iBool postCommands) {
756 if (!isSlidePanel) { 757 if (!isSlidePanel) {
757 setFlags_Widget(d, borderTop_WidgetFlag, iTrue); 758 setFlags_Widget(d, borderTop_WidgetFlag, iTrue);
758 } 759 }
759 d->rect.size.x = size_Window(get_Window()).x; 760 d->rect.size.x = rootSize.x;
760 } 761 }
761 /* Update item fonts. */ { 762 /* Update item fonts. */ {
762 iForEach(ObjectList, i, children_Widget(d)) { 763 iForEach(ObjectList, i, children_Widget(d)) {
@@ -790,14 +791,14 @@ void openMenuFlags_Widget(iWidget *d, iInt2 coord, iBool postCommands) {
790 } 791 }
791 } 792 }
792 else { 793 else {
793 d->rect.pos = coord; 794 d->rect.pos = windowToLocal_Widget(d, windowCoord);
794 } 795 }
795 /* Ensure the full menu is visible. */ 796 /* Ensure the full menu is visible. */
796 const iRect bounds = bounds_Widget(d); 797 const iRect bounds = bounds_Widget(d);
797 int leftExcess = -left_Rect(bounds); 798 int leftExcess = left_Rect(rootRect) - left_Rect(bounds);
798 int rightExcess = right_Rect(bounds) - rootSize.x; 799 int rightExcess = right_Rect(bounds) - right_Rect(rootRect);
799 int topExcess = -top_Rect(bounds); 800 int topExcess = top_Rect(rootRect) - top_Rect(bounds);
800 int bottomExcess = bottom_Rect(bounds) - rootSize.y; 801 int bottomExcess = bottom_Rect(bounds) - bottom_Rect(rootRect);
801#if defined (iPlatformAppleMobile) 802#if defined (iPlatformAppleMobile)
802 /* Reserve space for the system status bar. */ { 803 /* Reserve space for the system status bar. */ {
803 float l, t, r, b; 804 float l, t, r, b;
@@ -868,7 +869,7 @@ int checkContextMenu_Widget(iWidget *menu, const SDL_Event *ev) {
868 } 869 }
869 const iInt2 mousePos = init_I2(ev->button.x, ev->button.y); 870 const iInt2 mousePos = init_I2(ev->button.x, ev->button.y);
870 if (contains_Widget(menu->parent, mousePos)) { 871 if (contains_Widget(menu->parent, mousePos)) {
871 openMenu_Widget(menu, localCoord_Widget(menu->parent, mousePos)); 872 openMenu_Widget(menu, mousePos);
872 return 0x2; 873 return 0x2;
873 } 874 }
874 } 875 }
@@ -1044,7 +1045,7 @@ void showTabPage_Widget(iWidget *tabs, const iWidget *page) {
1044 } 1045 }
1045 /* Notify. */ 1046 /* Notify. */
1046 if (!isEmpty_String(id_Widget(page))) { 1047 if (!isEmpty_String(id_Widget(page))) {
1047 postCommandf_App("tabs.changed id:%s", cstr_String(id_Widget(page))); 1048 postCommandf_Root(page->root, "tabs.changed id:%s", cstr_String(id_Widget(page)));
1048 } 1049 }
1049} 1050}
1050 1051
@@ -1160,7 +1161,7 @@ static iBool slidePanelHandler_(iWidget *d, const char *cmd) {
1160 if (equal_Command(cmd, "panel.open")) { 1161 if (equal_Command(cmd, "panel.open")) {
1161 iWidget *button = pointer_Command(cmd); 1162 iWidget *button = pointer_Command(cmd);
1162 iWidget *panel = userData_Object(button); 1163 iWidget *panel = userData_Object(button);
1163 openMenu_Widget(panel, zero_I2()); 1164 openMenu_Widget(panel, innerToWindow_Widget(panel, zero_I2()));
1164 setFlags_Widget(panel, disabled_WidgetFlag, iFalse); 1165 setFlags_Widget(panel, disabled_WidgetFlag, iFalse);
1165// updateTextCStr_LabelWidget(findWidget_App("panel.back"), ); 1166// updateTextCStr_LabelWidget(findWidget_App("panel.back"), );
1166 return iTrue; 1167 return iTrue;