summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-05 16:01:21 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-05 16:01:21 +0200
commitf45839c10ddf30e735354f66f1f4b3886e181437 (patch)
tree2984b7c6e5d27dcb5ab5093c9246b4f7ebd4578a /src/ui/util.c
parenteddaa31cd3799666ae7520db9cd2362c1cce22e8 (diff)
Consistent dialog titles
Added a utility for setting up dialog titles consistently. They are now in all-caps and aligned appropriately.
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c79
1 files changed, 23 insertions, 56 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index e4e4f50b..8cf21538 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1684,6 +1684,22 @@ void useSheetStyle_Widget(iWidget *d) {
1684 iTrue); 1684 iTrue);
1685} 1685}
1686 1686
1687static iLabelWidget *addDialogTitle_(iWidget *dlg, const char *text, const char *id) {
1688 iLabelWidget *label = new_LabelWidget(text, NULL);
1689 addChildFlags_Widget(dlg, iClob(label), alignLeft_WidgetFlag | frameless_WidgetFlag |
1690 resizeToParentWidth_WidgetFlag);
1691 setAllCaps_LabelWidget(label, iTrue);
1692 setTextColor_LabelWidget(label, uiHeading_ColorId);
1693 if (id) {
1694 setId_Widget(as_Widget(label), id);
1695 }
1696 return label;
1697}
1698
1699iLabelWidget *addDialogTitle_Widget(iWidget *dlg, const char *text, const char *idOrNull) {
1700 return addDialogTitle_(dlg, text, idOrNull);
1701}
1702
1687static void acceptValueInput_(iWidget *dlg) { 1703static void acceptValueInput_(iWidget *dlg) {
1688 const iInputWidget *input = findChild_Widget(dlg, "input"); 1704 const iInputWidget *input = findChild_Widget(dlg, "input");
1689 if (!isEmpty_String(id_Widget(dlg))) { 1705 if (!isEmpty_String(id_Widget(dlg))) {
@@ -1858,10 +1874,7 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
1858 addChild_Widget(parent, iClob(dlg)); 1874 addChild_Widget(parent, iClob(dlg));
1859 } 1875 }
1860 if (deviceType_App() == desktop_AppDeviceType) { /* conserve space on mobile */ 1876 if (deviceType_App() == desktop_AppDeviceType) { /* conserve space on mobile */
1861 setId_Widget( 1877 addDialogTitle_(dlg, title, "valueinput.title");
1862 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)),
1863 frameless_WidgetFlag),
1864 "valueinput.title");
1865 } 1878 }
1866 iLabelWidget *promptLabel; 1879 iLabelWidget *promptLabel;
1867 setId_Widget(addChildFlags_Widget( 1880 setId_Widget(addChildFlags_Widget(
@@ -2007,9 +2020,7 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg,
2007 } 2020 }
2008 iWidget *dlg = makeSheet_Widget(""); 2021 iWidget *dlg = makeSheet_Widget("");
2009 setCommandHandler_Widget(dlg, messageHandler_); 2022 setCommandHandler_Widget(dlg, messageHandler_);
2010 setId_Widget( 2023 addDialogTitle_(dlg, title, "question.title");
2011 addChildFlags_Widget(dlg, iClob(new_LabelWidget(title, NULL)), frameless_WidgetFlag),
2012 "question.title");
2013 iLabelWidget *msgLabel; 2024 iLabelWidget *msgLabel;
2014 setId_Widget(addChildFlags_Widget(dlg, 2025 setId_Widget(addChildFlags_Widget(dlg,
2015 iClob(msgLabel = new_LabelWidget(msg, NULL)), 2026 iClob(msgLabel = new_LabelWidget(msg, NULL)),
@@ -2186,28 +2197,6 @@ static const iArray *makeFontItems_(const char *id) {
2186 0, 2197 0,
2187 format_CStr("!font.set %s:%s", id, cstr_String(&spec->id)) }); 2198 format_CStr("!font.set %s:%s", id, cstr_String(&spec->id)) });
2188 } 2199 }
2189#if 0
2190 const struct {
2191 const char * name;
2192 enum iTextFont cfgId;
2193 } fonts[] = { { "Nunito", nunito_TextFont },
2194 { "Source Sans 3", sourceSans3_TextFont },
2195 { "Fira Sans", firaSans_TextFont },
2196 { "---", -1 },
2197 { "Literata", literata_TextFont },
2198 { "Tinos", tinos_TextFont },
2199 { "---", -1 },
2200 { "Iosevka", iosevka_TextFont } };
2201 iForIndices(i, fonts) {
2202 pushBack_Array(items,
2203 &(iMenuItem){ fonts[i].name,
2204 0,
2205 0,
2206 fonts[i].cfgId >= 0
2207 ? format_CStr("!%s.set arg:%d", id, fonts[i].cfgId)
2208 : NULL });
2209 }
2210#endif
2211 pushBack_Array(items, &(iMenuItem){ NULL }); /* terminator */ 2200 pushBack_Array(items, &(iMenuItem){ NULL }); /* terminator */
2212 return items; 2201 return items;
2213} 2202}
@@ -2223,13 +2212,6 @@ static void addFontButtons_(iWidget *parent, const char *id) {
2223 addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag); 2212 addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag);
2224} 2213}
2225 2214
2226#if 0
2227static int cmp_MenuItem_(const void *e1, const void *e2) {
2228 const iMenuItem *a = e1, *b = e2;
2229 return iCmpStr(a->label, b->label);
2230}
2231#endif
2232
2233void updatePreferencesLayout_Widget(iWidget *prefs) { 2215void updatePreferencesLayout_Widget(iWidget *prefs) {
2234 if (!prefs || deviceType_App() != desktop_AppDeviceType) { 2216 if (!prefs || deviceType_App() != desktop_AppDeviceType) {
2235 return; 2217 return;
@@ -2635,9 +2617,7 @@ iWidget *makePreferences_Widget(void) {
2635 return dlg; 2617 return dlg;
2636 } 2618 }
2637 iWidget *dlg = makeSheet_Widget("prefs"); 2619 iWidget *dlg = makeSheet_Widget("prefs");
2638 setAllCaps_LabelWidget(addChildFlags_Widget(dlg, 2620 addDialogTitle_(dlg, "${heading.prefs}", NULL);
2639 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.prefs}", NULL)),
2640 frameless_WidgetFlag), iTrue);
2641 iWidget *tabs = makeTabs_Widget(dlg); 2621 iWidget *tabs = makeTabs_Widget(dlg);
2642 setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId); 2622 setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId);
2643 setId_Widget(tabs, "prefs.tabs"); 2623 setId_Widget(tabs, "prefs.tabs");
@@ -3021,11 +3001,7 @@ iWidget *makeBookmarkEditor_Widget(void) {
3021 } 3001 }
3022 else { 3002 else {
3023 dlg = makeSheet_Widget("bmed"); 3003 dlg = makeSheet_Widget("bmed");
3024 setId_Widget(addChildFlags_Widget( 3004 addDialogTitle_(dlg, "${heading.bookmark.edit}", "bmed.heading");
3025 dlg,
3026 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.bookmark.edit}", NULL)),
3027 frameless_WidgetFlag),
3028 "bmed.heading");
3029 iWidget *headings, *values; 3005 iWidget *headings, *values;
3030 addChild_Widget(dlg, iClob(makeTwoColumns_Widget(&headings, &values))); 3006 addChild_Widget(dlg, iClob(makeTwoColumns_Widget(&headings, &values)));
3031 iInputWidget *inputs[4]; 3007 iInputWidget *inputs[4];
@@ -3205,9 +3181,7 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) {
3205 } 3181 }
3206 else { 3182 else {
3207 dlg = makeSheet_Widget("feedcfg"); 3183 dlg = makeSheet_Widget("feedcfg");
3208 setId_Widget( 3184 addDialogTitle_(dlg, headingText, "feedcfg.heading");
3209 addChildFlags_Widget(dlg, iClob(new_LabelWidget(headingText, NULL)), frameless_WidgetFlag),
3210 "feedcfg.heading");
3211 iWidget *headings, *values; 3185 iWidget *headings, *values;
3212 addChild_Widget(dlg, iClob(makeTwoColumns_Widget(&headings, &values))); 3186 addChild_Widget(dlg, iClob(makeTwoColumns_Widget(&headings, &values)));
3213 iInputWidget *input = new_InputWidget(0); 3187 iInputWidget *input = new_InputWidget(0);
@@ -3286,11 +3260,7 @@ iWidget *makeIdentityCreation_Widget(void) {
3286 } 3260 }
3287 else { 3261 else {
3288 dlg = makeSheet_Widget("ident"); 3262 dlg = makeSheet_Widget("ident");
3289 setId_Widget(addChildFlags_Widget( 3263 addDialogTitle_(dlg, "${heading.newident}", "ident.heading");
3290 dlg,
3291 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.newident}", NULL)),
3292 frameless_WidgetFlag),
3293 "ident.heading");
3294 iWidget *page = new_Widget(); 3264 iWidget *page = new_Widget();
3295 addChildFlags_Widget( 3265 addChildFlags_Widget(
3296 dlg, iClob(new_LabelWidget("${dlg.newident.rsa.selfsign}", NULL)), frameless_WidgetFlag); 3266 dlg, iClob(new_LabelWidget("${dlg.newident.rsa.selfsign}", NULL)), frameless_WidgetFlag);
@@ -3428,10 +3398,7 @@ iWidget *makeTranslation_Widget(iWidget *parent) {
3428 dlg = makeSheet_Widget("xlt"); 3398 dlg = makeSheet_Widget("xlt");
3429 setFlags_Widget(dlg, keepOnTop_WidgetFlag, iFalse); 3399 setFlags_Widget(dlg, keepOnTop_WidgetFlag, iFalse);
3430 dlg->minSize.x = 70 * gap_UI; 3400 dlg->minSize.x = 70 * gap_UI;
3431 addChildFlags_Widget( 3401 addDialogTitle_(dlg, "${heading.translate}", NULL);
3432 dlg,
3433 iClob(new_LabelWidget(uiHeading_ColorEscape "${heading.translate}", NULL)),
3434 frameless_WidgetFlag);
3435 addChild_Widget(dlg, iClob(makePadding_Widget(lineHeight_Text(uiLabel_FontId)))); 3402 addChild_Widget(dlg, iClob(makePadding_Widget(lineHeight_Text(uiLabel_FontId))));
3436 iWidget *headings, *values; 3403 iWidget *headings, *values;
3437 iWidget *page; 3404 iWidget *page;