diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-15 13:18:57 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-06-15 13:18:57 +0300 |
commit | 379c1100995fbc841df863027871ee91c77deedf (patch) | |
tree | c9a2cd58baed2c6ad7dfda6f6d120def03b130b9 /src/ui | |
parent | 00a67e05bd6b1b2a8a8a65b3611c59c3a253e755 (diff) |
Mobile: Show identity name in toolbar
Shuffled the widget flags a bit to make room for a new one.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/labelwidget.c | 8 | ||||
-rw-r--r-- | src/ui/labelwidget.h | 1 | ||||
-rw-r--r-- | src/ui/root.c | 29 | ||||
-rw-r--r-- | src/ui/text.c | 1 | ||||
-rw-r--r-- | src/ui/text.h | 1 | ||||
-rw-r--r-- | src/ui/util.c | 4 | ||||
-rw-r--r-- | src/ui/widget.c | 5 | ||||
-rw-r--r-- | src/ui/widget.h | 6 |
8 files changed, 47 insertions, 8 deletions
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 09c5812b..46ef5d1f 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -45,6 +45,7 @@ struct Impl_LabelWidget { | |||
45 | uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ | 45 | uint8_t alignVisual : 1; /* align according to visible bounds, not font metrics */ |
46 | uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ | 46 | uint8_t noAutoMinHeight : 1; /* minimum height is not set automatically */ |
47 | uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ | 47 | uint8_t drawAsOutline : 1; /* draw as outline, filled with background color */ |
48 | uint8_t noTopFrame : 1; | ||
48 | } flags; | 49 | } flags; |
49 | }; | 50 | }; |
50 | 51 | ||
@@ -290,7 +291,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { | |||
290 | }; | 291 | }; |
291 | drawLines_Paint(&p, points + 2, 3, frame2); | 292 | drawLines_Paint(&p, points + 2, 3, frame2); |
292 | drawLines_Paint( | 293 | drawLines_Paint( |
293 | &p, points, !isHover && flags & noTopFrame_WidgetFlag ? 2 : 3, frame); | 294 | &p, points, !isHover && flags & d->flags.noTopFrame ? 2 : 3, frame); |
294 | } | 295 | } |
295 | } | 296 | } |
296 | setClip_Paint(&p, rect); | 297 | setClip_Paint(&p, rect); |
@@ -444,6 +445,7 @@ void init_LabelWidget(iLabelWidget *d, const char *label, const char *cmd) { | |||
444 | d->flags.alignVisual = iFalse; | 445 | d->flags.alignVisual = iFalse; |
445 | d->flags.noAutoMinHeight = iFalse; | 446 | d->flags.noAutoMinHeight = iFalse; |
446 | d->flags.drawAsOutline = iFalse; | 447 | d->flags.drawAsOutline = iFalse; |
448 | d->flags.noTopFrame = iFalse; | ||
447 | updateSize_LabelWidget(d); | 449 | updateSize_LabelWidget(d); |
448 | updateKey_LabelWidget_(d); /* could be bound to another key */ | 450 | updateKey_LabelWidget_(d); /* could be bound to another key */ |
449 | } | 451 | } |
@@ -483,6 +485,10 @@ void setNoAutoMinHeight_LabelWidget(iLabelWidget *d, iBool noAutoMinHeight) { | |||
483 | } | 485 | } |
484 | } | 486 | } |
485 | 487 | ||
488 | void setNoTopFrame_LabelWidget(iLabelWidget *d, iBool noTopFrame) { | ||
489 | d->flags.noTopFrame = noTopFrame; | ||
490 | } | ||
491 | |||
486 | void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { | 492 | void setOutline_LabelWidget(iLabelWidget *d, iBool drawAsOutline) { |
487 | d->flags.drawAsOutline = drawAsOutline; | 493 | d->flags.drawAsOutline = drawAsOutline; |
488 | } | 494 | } |
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h index 25c873fc..f6343273 100644 --- a/src/ui/labelwidget.h +++ b/src/ui/labelwidget.h | |||
@@ -31,6 +31,7 @@ iDeclareObjectConstructionArgs(LabelWidget, const char *label, const char *comma | |||
31 | 31 | ||
32 | void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); | 32 | void setAlignVisually_LabelWidget(iLabelWidget *, iBool alignVisual); |
33 | void setNoAutoMinHeight_LabelWidget(iLabelWidget *, iBool noAutoMinHeight); | 33 | void setNoAutoMinHeight_LabelWidget(iLabelWidget *, iBool noAutoMinHeight); |
34 | void setNoTopFrame_LabelWidget (iLabelWidget *, iBool noTopFrame); | ||
34 | void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); | 35 | void setOutline_LabelWidget (iLabelWidget *, iBool drawAsOutline); |
35 | void setFont_LabelWidget (iLabelWidget *, int fontId); | 36 | void setFont_LabelWidget (iLabelWidget *, int fontId); |
36 | void setTextColor_LabelWidget (iLabelWidget *, int color); | 37 | void setTextColor_LabelWidget (iLabelWidget *, int color); |
diff --git a/src/ui/root.c b/src/ui/root.c index 71f51ef0..9f4aeb7f 100644 --- a/src/ui/root.c +++ b/src/ui/root.c | |||
@@ -443,6 +443,10 @@ static void updateNavBarIdentity_(iWidget *navBar) { | |||
443 | subjectName ? format_CStr(uiTextAction_ColorEscape "%s", cstr_String(subjectName)) | 443 | subjectName ? format_CStr(uiTextAction_ColorEscape "%s", cstr_String(subjectName)) |
444 | : "${menu.identity.notactive}"); | 444 | : "${menu.identity.notactive}"); |
445 | setFlags_Widget(as_Widget(idItem), disabled_WidgetFlag, !ident); | 445 | setFlags_Widget(as_Widget(idItem), disabled_WidgetFlag, !ident); |
446 | iLabelWidget *toolName = findWidget_App("toolbar.name"); | ||
447 | if (toolName) { | ||
448 | updateTextCStr_LabelWidget(toolName, subjectName ? cstr_String(subjectName) : ""); | ||
449 | } | ||
446 | } | 450 | } |
447 | 451 | ||
448 | static void updateNavDirButtons_(iWidget *navBar) { | 452 | static void updateNavDirButtons_(iWidget *navBar) { |
@@ -951,6 +955,19 @@ void updateMetrics_Root(iRoot *d) { | |||
951 | updatePadding_Root(d); | 955 | updatePadding_Root(d); |
952 | arrange_Widget(d->widget); | 956 | arrange_Widget(d->widget); |
953 | updateUrlInputContentPadding_(navBar); | 957 | updateUrlInputContentPadding_(navBar); |
958 | /* Position the toolbar identity name label manually. */ { | ||
959 | iLabelWidget *idName = findChild_Widget(d->widget, "toolbar.name"); | ||
960 | if (idName) { | ||
961 | const iWidget *idButton = findChild_Widget(d->widget, "toolbar.ident"); | ||
962 | const int font = defaultSmall_FontId; | ||
963 | setFont_LabelWidget(idName, font); | ||
964 | setPos_Widget(as_Widget(idName), | ||
965 | windowToLocal_Widget(as_Widget(idName), | ||
966 | addY_I2(bottomLeft_Rect(bounds_Widget(idButton)), -gap_UI * 2))); | ||
967 | setFixedSize_Widget(as_Widget(idName), init_I2(width_Widget(idButton), | ||
968 | lineHeight_Text(font))); | ||
969 | } | ||
970 | } | ||
954 | postRefresh_App(); | 971 | postRefresh_App(); |
955 | } | 972 | } |
956 | 973 | ||
@@ -1284,16 +1301,24 @@ void createUserInterface_Root(iRoot *d) { | |||
1284 | iClob(newLargeIcon_LabelWidget(book_Icon, "toolbar.showview arg:-1")), | 1301 | iClob(newLargeIcon_LabelWidget(book_Icon, "toolbar.showview arg:-1")), |
1285 | frameless_WidgetFlag | commandOnClick_WidgetFlag), | 1302 | frameless_WidgetFlag | commandOnClick_WidgetFlag), |
1286 | "toolbar.view"); | 1303 | "toolbar.view"); |
1304 | setId_Widget(addChildFlags_Widget(toolBar, | ||
1305 | iClob(new_LabelWidget("", NULL)), | ||
1306 | frameless_WidgetFlag | | ||
1307 | noBackground_WidgetFlag | | ||
1308 | disabled_WidgetFlag | | ||
1309 | fixedPosition_WidgetFlag | | ||
1310 | fixedSize_WidgetFlag | | ||
1311 | ignoreForParentWidth_WidgetFlag | | ||
1312 | ignoreForParentHeight_WidgetFlag), | ||
1313 | "toolbar.name"); | ||
1287 | iLabelWidget *menuButton = makeMenuButton_LabelWidget(menu_Icon, phoneNavMenuItems_, | 1314 | iLabelWidget *menuButton = makeMenuButton_LabelWidget(menu_Icon, phoneNavMenuItems_, |
1288 | iElemCount(phoneNavMenuItems_)); | 1315 | iElemCount(phoneNavMenuItems_)); |
1289 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); | 1316 | setFont_LabelWidget(menuButton, uiLabelLarge_FontId); |
1290 | setId_Widget(as_Widget(menuButton), "toolbar.navmenu"); | 1317 | setId_Widget(as_Widget(menuButton), "toolbar.navmenu"); |
1291 | addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); | 1318 | addChildFlags_Widget(toolBar, iClob(menuButton), frameless_WidgetFlag); |
1292 | // setBackgroundColor_Widget(toolBar, tmBannerBackground_ColorId); | ||
1293 | iForEach(ObjectList, i, children_Widget(toolBar)) { | 1319 | iForEach(ObjectList, i, children_Widget(toolBar)) { |
1294 | iLabelWidget *btn = i.object; | 1320 | iLabelWidget *btn = i.object; |
1295 | setFlags_Widget(i.object, noBackground_WidgetFlag, iTrue); | 1321 | setFlags_Widget(i.object, noBackground_WidgetFlag, iTrue); |
1296 | // setTextColor_LabelWidget(i.object, tmBannerIcon_ColorId); | ||
1297 | } | 1322 | } |
1298 | updateToolbarColors_Root(d); | 1323 | updateToolbarColors_Root(d); |
1299 | const iMenuItem items[] = { | 1324 | const iMenuItem items[] = { |
diff --git a/src/ui/text.c b/src/ui/text.c index 8a70e4db..fcd944d6 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -306,6 +306,7 @@ static void initFonts_Text_(iText *d) { | |||
306 | { &fontSourceSans3Regular_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, | 306 | { &fontSourceSans3Regular_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, |
307 | { &fontSourceSans3Regular_Embedded, uiSize * 1.333f, 1.0f, uiBig_FontSize }, | 307 | { &fontSourceSans3Regular_Embedded, uiSize * 1.333f, 1.0f, uiBig_FontSize }, |
308 | { &fontSourceSans3Regular_Embedded, uiSize * 1.666f, 1.0f, uiLarge_FontSize }, | 308 | { &fontSourceSans3Regular_Embedded, uiSize * 1.666f, 1.0f, uiLarge_FontSize }, |
309 | { &fontSourceSans3Regular_Embedded, uiSize * 0.8f, 1.0f, uiNormal_FontSize }, | ||
309 | /* UI fonts: bold weight */ | 310 | /* UI fonts: bold weight */ |
310 | { &fontSourceSans3Bold_Embedded, uiSize, 1.0f, uiNormal_FontSize }, | 311 | { &fontSourceSans3Bold_Embedded, uiSize, 1.0f, uiNormal_FontSize }, |
311 | { &fontSourceSans3Bold_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, | 312 | { &fontSourceSans3Bold_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, |
diff --git a/src/ui/text.h b/src/ui/text.h index 64a8352f..dd377247 100644 --- a/src/ui/text.h +++ b/src/ui/text.h | |||
@@ -50,6 +50,7 @@ enum iFontId { | |||
50 | defaultMedium_FontId, | 50 | defaultMedium_FontId, |
51 | defaultBig_FontId, | 51 | defaultBig_FontId, |
52 | defaultLarge_FontId, | 52 | defaultLarge_FontId, |
53 | defaultSmall_FontId, | ||
53 | /* UI fonts: bold weight */ | 54 | /* UI fonts: bold weight */ |
54 | defaultBold_FontId, | 55 | defaultBold_FontId, |
55 | defaultMediumBold_FontId, | 56 | defaultMediumBold_FontId, |
diff --git a/src/ui/util.c b/src/ui/util.c index f094bdf9..3a9bc400 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -979,8 +979,8 @@ static void addTabPage_Widget_(iWidget *tabs, enum iWidgetAddPos addPos, iWidget | |||
979 | iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), | 979 | iClob(newKeyMods_LabelWidget(label, key, kmods, format_CStr("tabs.switch page:%p", page))), |
980 | addPos); | 980 | addPos); |
981 | setFlags_Widget(button, selected_WidgetFlag, isSel); | 981 | setFlags_Widget(button, selected_WidgetFlag, isSel); |
982 | setFlags_Widget( | 982 | setFlags_Widget(button, commandOnClick_WidgetFlag | expand_WidgetFlag, iTrue); |
983 | button, noTopFrame_WidgetFlag | commandOnClick_WidgetFlag | expand_WidgetFlag, iTrue); | 983 | setNoTopFrame_LabelWidget((iLabelWidget *) button, iTrue); |
984 | addChildPos_Widget(pages, page, addPos); | 984 | addChildPos_Widget(pages, page, addPos); |
985 | if (tabCount_Widget(tabs) > 1) { | 985 | if (tabCount_Widget(tabs) > 1) { |
986 | setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); | 986 | setFlags_Widget(buttons, hidden_WidgetFlag, iFalse); |
diff --git a/src/ui/widget.c b/src/ui/widget.c index 85672c04..4e1c9119 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -406,6 +406,11 @@ static void boundsOfChildren_Widget_(const iWidget *d, iRect *bounds_out) { | |||
406 | iRect childRect = child->rect; | 406 | iRect childRect = child->rect; |
407 | if (child->flags & ignoreForParentWidth_WidgetFlag) { | 407 | if (child->flags & ignoreForParentWidth_WidgetFlag) { |
408 | childRect.size.x = 0; | 408 | childRect.size.x = 0; |
409 | childRect.pos.x = bounds_out->pos.x; | ||
410 | } | ||
411 | if (child->flags & ignoreForParentHeight_WidgetFlag) { | ||
412 | childRect.size.y = 0; | ||
413 | childRect.pos.y = bounds_out->pos.y; | ||
409 | } | 414 | } |
410 | if (isEmpty_Rect(*bounds_out)) { | 415 | if (isEmpty_Rect(*bounds_out)) { |
411 | *bounds_out = childRect; | 416 | *bounds_out = childRect; |
diff --git a/src/ui/widget.h b/src/ui/widget.h index acb8fa9d..79565483 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h | |||
@@ -87,7 +87,7 @@ enum iWidgetFlag { | |||
87 | }; | 87 | }; |
88 | 88 | ||
89 | /* 64-bit extended flags */ | 89 | /* 64-bit extended flags */ |
90 | #define rightEdgeDraggable_WidgetFlag iBit64(32) | 90 | #define rightEdgeDraggable_WidgetFlag iBit64(31) |
91 | #define disabledWhenHidden_WidgetFlag iBit64(32) | 91 | #define disabledWhenHidden_WidgetFlag iBit64(32) |
92 | #define centerHorizontal_WidgetFlag iBit64(33) | 92 | #define centerHorizontal_WidgetFlag iBit64(33) |
93 | #define moveToParentLeftEdge_WidgetFlag iBit64(34) | 93 | #define moveToParentLeftEdge_WidgetFlag iBit64(34) |
@@ -103,7 +103,7 @@ enum iWidgetFlag { | |||
103 | #define drawBackgroundToVerticalSafeArea_WidgetFlag iBit64(44) | 103 | #define drawBackgroundToVerticalSafeArea_WidgetFlag iBit64(44) |
104 | #define visualOffset_WidgetFlag iBit64(45) | 104 | #define visualOffset_WidgetFlag iBit64(45) |
105 | #define parentCannotResize_WidgetFlag iBit64(46) | 105 | #define parentCannotResize_WidgetFlag iBit64(46) |
106 | #define noTopFrame_WidgetFlag iBit64(47) | 106 | #define ignoreForParentHeight_WidgetFlag iBit64(47) |
107 | #define unpadded_WidgetFlag iBit64(48) /* ignore parent's padding */ | 107 | #define unpadded_WidgetFlag iBit64(48) /* ignore parent's padding */ |
108 | #define extraPadding_WidgetFlag iBit64(49) | 108 | #define extraPadding_WidgetFlag iBit64(49) |
109 | #define borderBottom_WidgetFlag iBit64(50) | 109 | #define borderBottom_WidgetFlag iBit64(50) |
@@ -117,7 +117,7 @@ enum iWidgetFlag { | |||
117 | #define parentCannotResizeHeight_WidgetFlag iBit64(58) | 117 | #define parentCannotResizeHeight_WidgetFlag iBit64(58) |
118 | #define ignoreForParentWidth_WidgetFlag iBit64(59) | 118 | #define ignoreForParentWidth_WidgetFlag iBit64(59) |
119 | #define noFadeBackground_WidgetFlag iBit64(60) | 119 | #define noFadeBackground_WidgetFlag iBit64(60) |
120 | #define destroyPending_WidgetFlag iBit64(61) /* TODO: needed? */ | 120 | #define destroyPending_WidgetFlag iBit64(61) |
121 | #define leftEdgeDraggable_WidgetFlag iBit64(62) | 121 | #define leftEdgeDraggable_WidgetFlag iBit64(62) |
122 | #define refChildrenOffset_WidgetFlag iBit64(63) /* visual offset determined by the offset of referenced children */ | 122 | #define refChildrenOffset_WidgetFlag iBit64(63) /* visual offset determined by the offset of referenced children */ |
123 | 123 | ||