diff options
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index eb3d1cf2..b78cd6c6 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -683,29 +683,11 @@ static iWidget *makeMenuSeparator_(void) { | |||
683 | return sep; | 683 | return sep; |
684 | } | 684 | } |
685 | 685 | ||
686 | iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | 686 | void makeMenuItems_Widget(iWidget *menu, const iMenuItem *items, size_t n) { |
687 | iWidget *menu = new_Widget(); | ||
688 | setDrawBufferEnabled_Widget(menu, iTrue); | ||
689 | setBackgroundColor_Widget(menu, uiBackgroundMenu_ColorId); | ||
690 | if (deviceType_App() != desktop_AppDeviceType) { | ||
691 | setPadding1_Widget(menu, 2 * gap_UI); | ||
692 | } | ||
693 | else { | ||
694 | setPadding1_Widget(menu, gap_UI / 2); | ||
695 | } | ||
696 | const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); | 687 | const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); |
697 | int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) | | 688 | int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) | |
698 | (isPortraitPhone ? extraPadding_WidgetFlag : 0); | 689 | (isPortraitPhone ? extraPadding_WidgetFlag : 0); |
699 | setFlags_Widget(menu, | 690 | iBool haveIcons = iFalse; |
700 | keepOnTop_WidgetFlag | collapse_WidgetFlag | hidden_WidgetFlag | | ||
701 | arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | | ||
702 | resizeChildrenToWidestChild_WidgetFlag | overflowScrollable_WidgetFlag | | ||
703 | (isPortraitPhone ? drawBackgroundToVerticalSafeArea_WidgetFlag : 0), | ||
704 | iTrue); | ||
705 | if (!isPortraitPhone) { | ||
706 | setFrameColor_Widget(menu, uiSeparator_ColorId); | ||
707 | } | ||
708 | iBool haveIcons = iFalse; | ||
709 | iWidget *horizGroup = NULL; | 691 | iWidget *horizGroup = NULL; |
710 | for (size_t i = 0; i < n; ++i) { | 692 | for (size_t i = 0; i < n; ++i) { |
711 | const iMenuItem *item = &items[i]; | 693 | const iMenuItem *item = &items[i]; |
@@ -739,7 +721,7 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
739 | iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)), | 721 | iClob(newKeyMods_LabelWidget(labelText, item->key, item->kmods, item->command)), |
740 | noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | | 722 | noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | |
741 | drawKey_WidgetFlag | itemFlags); | 723 | drawKey_WidgetFlag | itemFlags); |
742 | setWrap_LabelWidget(label, isInfo); | 724 | setWrap_LabelWidget(label, isInfo); |
743 | haveIcons |= checkIcon_LabelWidget(label); | 725 | haveIcons |= checkIcon_LabelWidget(label); |
744 | updateSize_LabelWidget(label); /* drawKey was set */ | 726 | updateSize_LabelWidget(label); /* drawKey was set */ |
745 | if (isInfo) { | 727 | if (isInfo) { |
@@ -765,7 +747,28 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | |||
765 | } | 747 | } |
766 | } | 748 | } |
767 | } | 749 | } |
750 | }} | ||
751 | |||
752 | iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { | ||
753 | iWidget *menu = new_Widget(); | ||
754 | setDrawBufferEnabled_Widget(menu, iTrue); | ||
755 | setBackgroundColor_Widget(menu, uiBackgroundMenu_ColorId); | ||
756 | if (deviceType_App() != desktop_AppDeviceType) { | ||
757 | setPadding1_Widget(menu, 2 * gap_UI); | ||
758 | } | ||
759 | else { | ||
760 | setPadding1_Widget(menu, gap_UI / 2); | ||
761 | } | ||
762 | setFlags_Widget(menu, | ||
763 | keepOnTop_WidgetFlag | collapse_WidgetFlag | hidden_WidgetFlag | | ||
764 | arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | | ||
765 | resizeChildrenToWidestChild_WidgetFlag | overflowScrollable_WidgetFlag | | ||
766 | (isPortraitPhone_App() ? drawBackgroundToVerticalSafeArea_WidgetFlag : 0), | ||
767 | iTrue); | ||
768 | if (!isPortraitPhone_App()) { | ||
769 | setFrameColor_Widget(menu, uiSeparator_ColorId); | ||
768 | } | 770 | } |
771 | makeMenuItems_Widget(menu, items, n); | ||
769 | addChild_Widget(parent, menu); | 772 | addChild_Widget(parent, menu); |
770 | iRelease(menu); /* owned by parent now */ | 773 | iRelease(menu); /* owned by parent now */ |
771 | setCommandHandler_Widget(menu, menuHandler_); | 774 | setCommandHandler_Widget(menu, menuHandler_); |