summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/color.c4
-rw-r--r--src/ui/inputwidget.c4
-rw-r--r--src/ui/util.c55
-rw-r--r--src/ui/widget.c19
-rw-r--r--src/ui/widget.h1
5 files changed, 61 insertions, 22 deletions
diff --git a/src/ui/color.c b/src/ui/color.c
index 02ee59d6..3c504c14 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -299,6 +299,10 @@ void setThemePalette_Color(enum iColorTheme theme) {
299 0.4f)); 299 0.4f));
300 palette_[uiMarked_ColorId].a = 128; 300 palette_[uiMarked_ColorId].a = 128;
301 palette_[uiMatching_ColorId].a = 128; 301 palette_[uiMatching_ColorId].a = 128;
302 if (deviceType_App() == phone_AppDeviceType) {
303 copy_(uiInputBackground_ColorId, uiBackgroundSidebar_ColorId);
304 copy_(uiInputFrame_ColorId, uiBackgroundSidebar_ColorId);
305 }
302} 306}
303 307
304iColor get_Color(int color) { 308iColor get_Color(int color) {
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 267ccdf7..3f178fc5 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -117,8 +117,8 @@ static void invalidateBuffered_InputWidget_(iInputWidget *d) {
117static void updateMetrics_InputWidget_(iInputWidget *d) { 117static void updateMetrics_InputWidget_(iInputWidget *d) {
118 iWidget *w = as_Widget(d); 118 iWidget *w = as_Widget(d);
119 /* Caller must arrange the width, but the height is fixed. */ 119 /* Caller must arrange the width, but the height is fixed. */
120 w->rect.size.y = lineHeight_Text(default_FontId) + 2 * gap_UI; 120 w->rect.size.y = lineHeight_Text(d->font) * 1.3f;
121#if defined (iPlatformAppleMobile) 121#if defined (iPlatformMobile)
122 w->rect.size.y += 2 * gap_UI; 122 w->rect.size.y += 2 * gap_UI;
123#endif 123#endif
124 invalidateBuffered_InputWidget_(d); 124 invalidateBuffered_InputWidget_(d);
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 }
diff --git a/src/ui/widget.c b/src/ui/widget.c
index bb5431eb..c54ea444 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -680,12 +680,6 @@ void drawBackground_Widget(const iWidget *d) {
680 if (d->flags & (hidden_WidgetFlag | noBackground_WidgetFlag)) { 680 if (d->flags & (hidden_WidgetFlag | noBackground_WidgetFlag)) {
681 return; 681 return;
682 } 682 }
683 if (d->flags & borderTop_WidgetFlag) {
684 const iRect rect = bounds_Widget(d);
685 iPaint p;
686 init_Paint(&p);
687 drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect), uiBackgroundFramelessHover_ColorId);
688 }
689 /* Popup menus have a shadowed border. */ 683 /* Popup menus have a shadowed border. */
690 const iBool shadowBorder = 684 const iBool shadowBorder =
691 (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) != 0; 685 (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) != 0;
@@ -757,6 +751,19 @@ void drawBackground_Widget(const iWidget *d) {
757 drawRectThickness_Paint(&p, rect, gap_UI / 4, d->frameColor); 751 drawRectThickness_Paint(&p, rect, gap_UI / 4, d->frameColor);
758 } 752 }
759 } 753 }
754 if (d->flags & (borderTop_WidgetFlag | borderBottom_WidgetFlag)) {
755 const iRect rect = bounds_Widget(d);
756 iPaint p;
757 init_Paint(&p);
758 if (d->flags & borderTop_WidgetFlag) {
759 drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect),
760 uiBackgroundFramelessHover_ColorId);
761 }
762 if (d->flags & borderBottom_WidgetFlag) {
763 drawHLine_Paint(&p, addY_I2(bottomLeft_Rect(rect), -1), width_Rect(rect),
764 uiBackgroundFramelessHover_ColorId);
765 }
766 }
760} 767}
761 768
762iLocalDef iBool isDrawn_Widget_(const iWidget *d) { 769iLocalDef iBool isDrawn_Widget_(const iWidget *d) {
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 48070158..b1ee8c73 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -102,6 +102,7 @@ enum iWidgetFlag {
102#define noTopFrame_WidgetFlag iBit64(47) 102#define noTopFrame_WidgetFlag iBit64(47)
103#define unpadded_WidgetFlag iBit64(48) /* ignore parent's padding */ 103#define unpadded_WidgetFlag iBit64(48) /* ignore parent's padding */
104#define extraPadding_WidgetFlag iBit64(49) 104#define extraPadding_WidgetFlag iBit64(49)
105#define borderBottom_WidgetFlag iBit64(50)
105 106
106enum iWidgetAddPos { 107enum iWidgetAddPos {
107 back_WidgetAddPos, 108 back_WidgetAddPos,