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.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 29ac04a3..ad72a11e 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -455,19 +455,22 @@ static iWidget *makeMenuSeparator_(void) {
455 455
456iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) { 456iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
457 iWidget *menu = new_Widget(); 457 iWidget *menu = new_Widget();
458 setFrameColor_Widget(menu, uiSeparator_ColorId);
459 setBackgroundColor_Widget(menu, uiBackground_ColorId); 458 setBackgroundColor_Widget(menu, uiBackground_ColorId);
460 if (deviceType_App() != desktop_AppDeviceType) { 459 if (deviceType_App() != desktop_AppDeviceType) {
461 setPadding1_Widget(menu, 2 * gap_UI); 460 setPadding1_Widget(menu, 2 * gap_UI);
462 } 461 }
462 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App());
463 int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) |
464 (isPortraitPhone ? extraPadding_WidgetFlag : 0);
463 setFlags_Widget(menu, 465 setFlags_Widget(menu,
464 keepOnTop_WidgetFlag | collapse_WidgetFlag | hidden_WidgetFlag | 466 keepOnTop_WidgetFlag | collapse_WidgetFlag | hidden_WidgetFlag |
465 arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | 467 arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag |
466 resizeChildrenToWidestChild_WidgetFlag | overflowScrollable_WidgetFlag, 468 resizeChildrenToWidestChild_WidgetFlag | overflowScrollable_WidgetFlag |
469 (isPortraitPhone ? drawBackgroundToVerticalSafeArea_WidgetFlag : 0),
467 iTrue); 470 iTrue);
468 const iBool isPortraitPhone = (deviceType_App() == phone_AppDeviceType && isPortrait_App()); 471 if (!isPortraitPhone) {
469 int64_t itemFlags = (deviceType_App() != desktop_AppDeviceType ? 0 : 0) | 472 setFrameColor_Widget(menu, uiSeparator_ColorId);
470 (isPortraitPhone ? extraPadding_WidgetFlag : 0); 473 }
471 iBool haveIcons = iFalse; 474 iBool haveIcons = iFalse;
472 for (size_t i = 0; i < n; ++i) { 475 for (size_t i = 0; i < n; ++i) {
473 const iMenuItem *item = &items[i]; 476 const iMenuItem *item = &items[i];
@@ -478,7 +481,8 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
478 iLabelWidget *label = addChildFlags_Widget( 481 iLabelWidget *label = addChildFlags_Widget(
479 menu, 482 menu,
480 iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)), 483 iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)),
481 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag | itemFlags); 484 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag |
485 drawKey_WidgetFlag | itemFlags);
482 haveIcons |= checkIcon_LabelWidget(label); 486 haveIcons |= checkIcon_LabelWidget(label);
483 updateSize_LabelWidget(label); /* drawKey was set */ 487 updateSize_LabelWidget(label); /* drawKey was set */
484 } 488 }
@@ -487,7 +491,8 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
487 addChild_Widget(menu, iClob(makeMenuSeparator_())); 491 addChild_Widget(menu, iClob(makeMenuSeparator_()));
488 addChildFlags_Widget(menu, 492 addChildFlags_Widget(menu,
489 iClob(new_LabelWidget("Cancel", "cancel")), 493 iClob(new_LabelWidget("Cancel", "cancel")),
490 itemFlags | frameless_WidgetFlag | alignLeft_WidgetFlag); 494 itemFlags | noBackground_WidgetFlag | frameless_WidgetFlag |
495 alignLeft_WidgetFlag);
491 } 496 }
492 if (haveIcons) { 497 if (haveIcons) {
493 /* All items must have icons if at least one of them has. */ 498 /* All items must have icons if at least one of them has. */
@@ -953,7 +958,8 @@ void finalizeSheet_Widget(iWidget *sheet) {
953 /* Toggles have the button on the right. */ 958 /* Toggles have the button on the right. */
954 if (valueLabel && cmp_String(command_LabelWidget(valueLabel), "toggle") == 0) { 959 if (valueLabel && cmp_String(command_LabelWidget(valueLabel), "toggle") == 0) {
955 iWidget *div = new_Widget(); 960 iWidget *div = new_Widget();
956 setFrameColor_Widget(div, uiSeparator_ColorId); 961 setBackgroundColor_Widget(div, uiBackgroundSidebar_ColorId);
962// setFrameColor_Widget(div, uiSeparator_ColorId);
957 setPadding_Widget(div, gap_UI, gap_UI, 4 * gap_UI, gap_UI); 963 setPadding_Widget(div, gap_UI, gap_UI, 4 * gap_UI, gap_UI);
958 addChildFlags_Widget(div, iClob(heading), 0); 964 addChildFlags_Widget(div, iClob(heading), 0);
959 setFont_LabelWidget((iLabelWidget *) heading, defaultBig_FontId); 965 setFont_LabelWidget((iLabelWidget *) heading, defaultBig_FontId);
@@ -961,7 +967,7 @@ void finalizeSheet_Widget(iWidget *sheet) {
961 addChild_Widget(div, iClob(value)); 967 addChild_Widget(div, iClob(value));
962 addChildFlags_Widget(sheet, 968 addChildFlags_Widget(sheet,
963 iClob(div), 969 iClob(div),
964 arrangeHeight_WidgetFlag | 970 borderBottom_WidgetFlag | arrangeHeight_WidgetFlag |
965 resizeWidthOfChildren_WidgetFlag | 971 resizeWidthOfChildren_WidgetFlag |
966 arrangeHorizontal_WidgetFlag); 972 arrangeHorizontal_WidgetFlag);
967 } 973 }
@@ -969,27 +975,48 @@ void finalizeSheet_Widget(iWidget *sheet) {
969 if (valueLabel && isEmpty_String(text_LabelWidget(valueLabel))) { 975 if (valueLabel && isEmpty_String(text_LabelWidget(valueLabel))) {
970 /* Subheading padding goes above. */ 976 /* Subheading padding goes above. */
971 addChild_Widget(sheet, iClob(value)); 977 addChild_Widget(sheet, iClob(value));
972 addChild_Widget(sheet, iClob(heading)); 978 addChildFlags_Widget(sheet, iClob(heading), 0);
973 setFont_LabelWidget(headingLabel, uiLabelBold_FontId); 979 setFont_LabelWidget(headingLabel, uiLabelBold_FontId);
974 } 980 }
975 else { 981 else {
976 addChild_Widget(sheet, iClob(heading)); 982 addChildFlags_Widget(sheet, iClob(heading), borderBottom_WidgetFlag);
977 if (headingLabel) { 983 if (headingLabel) {
978 setTextColor_LabelWidget(headingLabel, uiSubheading_ColorId); 984 setTextColor_LabelWidget(headingLabel, uiSubheading_ColorId);
979 setText_LabelWidget(headingLabel, 985 setText_LabelWidget(headingLabel,
980 collect_String(upper_String(text_LabelWidget(headingLabel)))); 986 collect_String(upper_String(text_LabelWidget(headingLabel))));
981 } 987 }
982 addChild_Widget(sheet, iClob(value)); 988 const iBool isMenuButton = findChild_Widget(value, "menu") != NULL;
989 if (isMenuButton) {
990 setFlags_Widget(value, noBackground_WidgetFlag | frameless_WidgetFlag, iTrue);
991 }
992 if (valueInput || isMenuButton) {
993 setFlags_Widget(value, borderBottom_WidgetFlag, iFalse);
994 iWidget *pad = new_Widget();
995 setBackgroundColor_Widget(pad, uiBackgroundSidebar_ColorId);
996 setPadding_Widget(pad, 0, 1 * gap_UI, 0, 1 * gap_UI);
997 addChild_Widget(pad, iClob(value));
998 addChildFlags_Widget(sheet, iClob(pad), borderBottom_WidgetFlag |
999 arrangeVertical_WidgetFlag |
1000 resizeToParentWidth_WidgetFlag |
1001 resizeWidthOfChildren_WidgetFlag |
1002 arrangeHeight_WidgetFlag);
1003 }
1004 else {
1005 addChild_Widget(sheet, iClob(value));
1006 }
983 /* Align radio buttons to the right. */ 1007 /* Align radio buttons to the right. */
984 if (childCount_Widget(value)) { 1008 if (childCount_Widget(value) >= 2) {
1009 setBackgroundColor_Widget(value, uiBackgroundSidebar_ColorId);
1010 setPadding_Widget(value, 4 * gap_UI, 2 * gap_UI, 4 * gap_UI, 2 * gap_UI);
985 setFlags_Widget(value, 1011 setFlags_Widget(value,
1012 borderBottom_WidgetFlag |
986 resizeToParentWidth_WidgetFlag | 1013 resizeToParentWidth_WidgetFlag |
987 resizeWidthOfChildren_WidgetFlag, 1014 resizeWidthOfChildren_WidgetFlag,
988 iTrue); 1015 iTrue);
989 iForEach(ObjectList, sub, children_Widget(value)) { 1016 iForEach(ObjectList, sub, children_Widget(value)) {
990 if (isInstance_Object(sub.object, &Class_LabelWidget)) { 1017 if (isInstance_Object(sub.object, &Class_LabelWidget)) {
991 iLabelWidget *opt = sub.object; 1018 iLabelWidget *opt = sub.object;
992 setFont_LabelWidget(opt, defaultBig_FontId); 1019 setFont_LabelWidget(opt, defaultMedium_FontId);
993 } 1020 }
994 } 1021 }
995 } 1022 }