summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-12-29 08:51:08 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-12-29 08:51:08 +0200
commit4dc0e17e8f315cbb336ac3664177a7f6bb3f993b (patch)
treef6041e32f51ec197702245f1b27808779cdf7155 /src
parentda6ceb3858ae864fab63efb6d39aa963374c4bce (diff)
Added a bold UI font
The bold UI label font is used for highlighted sidebar items and default buttons.
Diffstat (limited to 'src')
-rw-r--r--src/ui/color.c2
-rw-r--r--src/ui/sidebarwidget.c20
-rw-r--r--src/ui/text.c2
-rw-r--r--src/ui/text.h6
-rw-r--r--src/ui/util.c23
5 files changed, 37 insertions, 16 deletions
diff --git a/src/ui/color.c b/src/ui/color.c
index 7cbb468b..8233818e 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -167,7 +167,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
167 copy_(uiBackgroundPressed_ColorId, cyan_ColorId); 167 copy_(uiBackgroundPressed_ColorId, cyan_ColorId);
168 copy_(uiBackgroundFramelessHover_ColorId, orange_ColorId); 168 copy_(uiBackgroundFramelessHover_ColorId, orange_ColorId);
169 copy_(uiText_ColorId, black_ColorId); 169 copy_(uiText_ColorId, black_ColorId);
170 copy_(uiTextStrong_ColorId, teal_ColorId); 170 copy_(uiTextStrong_ColorId, black_ColorId);
171 copy_(uiTextPressed_ColorId, black_ColorId); 171 copy_(uiTextPressed_ColorId, black_ColorId);
172 copy_(uiTextSelected_ColorId, black_ColorId); 172 copy_(uiTextSelected_ColorId, black_ColorId);
173 copy_(uiTextDisabled_ColorId, gray50_ColorId); 173 copy_(uiTextDisabled_ColorId, gray50_ColorId);
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index d3be3710..6bd51731 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -1174,8 +1174,9 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1174 } 1174 }
1175 else { 1175 else {
1176 const iBool isUnread = (d->indent != 0); 1176 const iBool isUnread = (d->indent != 0);
1177 const int titleFont = isUnread ? uiContentBold_FontId : uiContent_FontId;
1177 const int h1 = lineHeight_Text(uiLabel_FontId); 1178 const int h1 = lineHeight_Text(uiLabel_FontId);
1178 const int h2 = lineHeight_Text(uiContent_FontId); 1179 const int h2 = lineHeight_Text(titleFont);
1179 const int iconPad = 9 * gap_UI; 1180 const int iconPad = 9 * gap_UI;
1180 iRect iconArea = { addY_I2(pos, 0), init_I2(iconPad, itemHeight) }; 1181 iRect iconArea = { addY_I2(pos, 0), init_I2(iconPad, itemHeight) };
1181 if (isUnread) { 1182 if (isUnread) {
@@ -1199,7 +1200,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1199 deinit_String(&str); 1200 deinit_String(&str);
1200 } 1201 }
1201 /* Select the layout based on how the title fits. */ 1202 /* Select the layout based on how the title fits. */
1202 iInt2 titleSize = advanceRange_Text(uiContent_FontId, range_String(&d->label)); 1203 iInt2 titleSize = advanceRange_Text(titleFont, range_String(&d->label));
1203 const iInt2 metaSize = advanceRange_Text(uiLabel_FontId, range_String(&d->meta)); 1204 const iInt2 metaSize = advanceRange_Text(uiLabel_FontId, range_String(&d->meta));
1204 pos.x += iconPad; 1205 pos.x += iconPad;
1205 const int avail = width_Rect(itemRect) - iconPad - 3 * gap_UI; 1206 const int avail = width_Rect(itemRect) - iconPad - 3 * gap_UI;
@@ -1214,12 +1215,12 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1214 const char *endPos; 1215 const char *endPos;
1215 tryAdvance_Text( 1216 tryAdvance_Text(
1216 uiContent_FontId, range_String(&d->label), avail - skip, &endPos); 1217 uiContent_FontId, range_String(&d->label), avail - skip, &endPos);
1217 drawRange_Text(uiContent_FontId, 1218 drawRange_Text(titleFont,
1218 cur, 1219 cur,
1219 labelFg, 1220 labelFg,
1220 (iRangecc){ constBegin_String(&d->label), endPos }); 1221 (iRangecc){ constBegin_String(&d->label), endPos });
1221 if (endPos < constEnd_String(&d->label)) { 1222 if (endPos < constEnd_String(&d->label)) {
1222 drawRange_Text(uiContent_FontId, 1223 drawRange_Text(titleFont,
1223 addY_I2(pos, h2), labelFg, 1224 addY_I2(pos, h2), labelFg,
1224 (iRangecc){ endPos, constEnd_String(&d->label) }); 1225 (iRangecc){ endPos, constEnd_String(&d->label) });
1225 } 1226 }
@@ -1227,7 +1228,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1227 else { 1228 else {
1228 pos.y += (itemHeight - h1 - h2) / 2; 1229 pos.y += (itemHeight - h1 - h2) / 2;
1229 drawRange_Text(uiLabel_FontId, pos, fg, range_String(&d->meta)); 1230 drawRange_Text(uiLabel_FontId, pos, fg, range_String(&d->meta));
1230 drawRange_Text(uiContent_FontId, addY_I2(pos, h1), labelFg, range_String(&d->label)); 1231 drawRange_Text(titleFont, addY_I2(pos, h1), labelFg, range_String(&d->label));
1231 } 1232 }
1232 } 1233 }
1233 } 1234 }
@@ -1266,8 +1267,6 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1266 } 1267 }
1267 else if (sidebar->mode == history_SidebarMode) { 1268 else if (sidebar->mode == history_SidebarMode) {
1268 iBeginCollect(); 1269 iBeginCollect();
1269 const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId)
1270 : uiText_ColorId;
1271 if (d->listItem.isSeparator) { 1270 if (d->listItem.isSeparator) {
1272 if (!isEmpty_String(&d->meta)) { 1271 if (!isEmpty_String(&d->meta)) {
1273 iInt2 drawPos = addY_I2(topLeft_Rect(itemRect), d->id); 1272 iInt2 drawPos = addY_I2(topLeft_Rect(itemRect), d->id);
@@ -1284,6 +1283,8 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1284 } 1283 }
1285 } 1284 }
1286 else { 1285 else {
1286 const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId)
1287 : uiHeading_ColorId;
1287 iUrl parts; 1288 iUrl parts;
1288 init_Url(&parts, &d->label); 1289 init_Url(&parts, &d->label);
1289 const iBool isAbout = equalCase_Rangecc(parts.scheme, "about"); 1290 const iBool isAbout = equalCase_Rangecc(parts.scheme, "about");
@@ -1320,7 +1321,10 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1320 drawRange_Text( 1321 drawRange_Text(
1321 font, cPos, d->listItem.isSelected ? iconColor : metaFg, range_String(&icon)); 1322 font, cPos, d->listItem.isSelected ? iconColor : metaFg, range_String(&icon));
1322 deinit_String(&icon); 1323 deinit_String(&icon);
1323 drawRange_Text(font, add_I2(cPos, init_I2(6 * gap_UI, 0)), fg, range_String(&d->label)); 1324 drawRange_Text(d->listItem.isSelected ? uiContentBold_FontId : font,
1325 add_I2(cPos, init_I2(6 * gap_UI, 0)),
1326 fg,
1327 range_String(&d->label));
1324 drawRange_Text(default_FontId, 1328 drawRange_Text(default_FontId,
1325 add_I2(cPos, init_I2(6 * gap_UI, lineHeight_Text(font))), 1329 add_I2(cPos, init_I2(6 * gap_UI, lineHeight_Text(font))),
1326 metaFg, 1330 metaFg,
diff --git a/src/ui/text.c b/src/ui/text.c
index 2ab40387..e9ca17e7 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -224,7 +224,9 @@ static void initFonts_Text_(iText *d) {
224 int symbolsFont; 224 int symbolsFont;
225 } fontData[max_FontId] = { 225 } fontData[max_FontId] = {
226 { &fontSourceSansProRegular_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId }, 226 { &fontSourceSansProRegular_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId },
227 { &fontSourceSansProBold_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId },
227 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 228 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId },
229 { &fontSourceSansProBold_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId },
228 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 230 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.666f, 1.0f, defaultLargeSymbols_FontId },
229 { &fontIosevkaTermExtended_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId }, 231 { &fontIosevkaTermExtended_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId },
230 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId }, 232 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId },
diff --git a/src/ui/text.h b/src/ui/text.h
index f78f570a..217bdd13 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -31,10 +31,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
31 31
32enum iFontId { 32enum iFontId {
33 default_FontId, 33 default_FontId,
34 defaultBold_FontId,
34 defaultMedium_FontId, 35 defaultMedium_FontId,
36 defaultMediumBold_FontId,
35 defaultLarge_FontId, 37 defaultLarge_FontId,
36 defaultMonospace_FontId, 38 defaultMonospace_FontId,
37 defaultContentSized_FontId, 39 defaultContentSized_FontId,
38 /* content fonts */ 40 /* content fonts */
39 regular_FontId, 41 regular_FontId,
40 monospace_FontId, 42 monospace_FontId,
@@ -96,10 +98,12 @@ enum iFontId {
96 98
97 /* UI fonts: */ 99 /* UI fonts: */
98 uiLabel_FontId = default_FontId, 100 uiLabel_FontId = default_FontId,
101 uiLabelBold_FontId = defaultBold_FontId,
99 uiLabelLarge_FontId = defaultLarge_FontId, 102 uiLabelLarge_FontId = defaultLarge_FontId,
100 uiShortcuts_FontId = default_FontId, 103 uiShortcuts_FontId = default_FontId,
101 uiInput_FontId = defaultMonospace_FontId, 104 uiInput_FontId = defaultMonospace_FontId,
102 uiContent_FontId = defaultMedium_FontId, 105 uiContent_FontId = defaultMedium_FontId,
106 uiContentBold_FontId = defaultMediumBold_FontId,
103 uiContentSymbols_FontId = defaultMediumSymbols_FontId, 107 uiContentSymbols_FontId = defaultMediumSymbols_FontId,
104 /* Document fonts: */ 108 /* Document fonts: */
105 paragraph_FontId = regular_FontId, 109 paragraph_FontId = regular_FontId,
diff --git a/src/ui/util.c b/src/ui/util.c
index 0361cd72..c626759a 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -872,12 +872,13 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
872 iWidget *div = new_Widget(); { 872 iWidget *div = new_Widget(); {
873 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 873 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
874 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 874 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
875 addChild_Widget( 875 iLabelWidget *accept = addChild_Widget(
876 div, 876 div,
877 iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", 877 iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK",
878 SDLK_RETURN, 878 SDLK_RETURN,
879 0, 879 0,
880 "valueinput.accept"))); 880 "valueinput.accept")));
881 setFont_LabelWidget(accept, uiLabelBold_FontId);
881 } 882 }
882 addChild_Widget(dlg, iClob(div)); 883 addChild_Widget(dlg, iClob(div));
883 centerSheet_Widget(dlg); 884 centerSheet_Widget(dlg);
@@ -924,8 +925,12 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, const char *lab
924 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 925 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
925 for (size_t i = 0; i < count; ++i) { 926 for (size_t i = 0; i < count; ++i) {
926 /* The last one is the default option. */ 927 /* The last one is the default option. */
927 const int key = (i == count - 1 ? SDLK_RETURN : 0); 928 const int key = (i == count - 1 ? SDLK_RETURN : 0);
928 addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i]))); 929 iLabelWidget *btn =
930 addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i])));
931 if (key) {
932 setFont_LabelWidget(btn, uiLabelBold_FontId);
933 }
929 } 934 }
930 } 935 }
931 addChild_Widget(dlg, iClob(div)); 936 addChild_Widget(dlg, iClob(div));
@@ -1168,7 +1173,10 @@ iWidget *makePreferences_Widget(void) {
1168 } 1173 }
1169 iWidget *div = new_Widget(); { 1174 iWidget *div = new_Widget(); {
1170 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1175 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1171 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); 1176 setFont_LabelWidget(
1177 addChild_Widget(
1178 div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))),
1179 uiLabelBold_FontId);
1172 } 1180 }
1173 addChild_Widget(dlg, iClob(div)); 1181 addChild_Widget(dlg, iClob(div));
1174 addChild_Widget(get_Window()->root, iClob(dlg)); 1182 addChild_Widget(get_Window()->root, iClob(dlg));
@@ -1205,10 +1213,11 @@ iWidget *makeBookmarkEditor_Widget(void) {
1205 iWidget *div = new_Widget(); { 1213 iWidget *div = new_Widget(); {
1206 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1214 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1207 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 1215 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
1208 addChild_Widget( 1216 iLabelWidget *accept = addChild_Widget(
1209 div, 1217 div,
1210 iClob(newKeyMods_LabelWidget( 1218 iClob(newKeyMods_LabelWidget(
1211 uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept"))); 1219 uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept")));
1220 setFont_LabelWidget(accept, uiLabelBold_FontId);
1212 } 1221 }
1213 addChild_Widget(dlg, iClob(div)); 1222 addChild_Widget(dlg, iClob(div));
1214 addChild_Widget(get_Window()->root, iClob(dlg)); 1223 addChild_Widget(get_Window()->root, iClob(dlg));
@@ -1345,6 +1354,7 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) {
1345 KMOD_PRIMARY, 1354 KMOD_PRIMARY,
1346 format_CStr("feedcfg.accept bmid:%d", bookmarkId)))), 1355 format_CStr("feedcfg.accept bmid:%d", bookmarkId)))),
1347 "feedcfg.save"); 1356 "feedcfg.save");
1357 setFont_LabelWidget(findChild_Widget(div, "feedcfg.save"), uiLabelBold_FontId);
1348 } 1358 }
1349 addChild_Widget(dlg, iClob(div)); 1359 addChild_Widget(dlg, iClob(div));
1350 arrange_Widget(dlg); 1360 arrange_Widget(dlg);
@@ -1421,10 +1431,11 @@ iWidget *makeIdentityCreation_Widget(void) {
1421 iWidget *div = new_Widget(); { 1431 iWidget *div = new_Widget(); {
1422 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1432 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1423 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 1433 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
1424 addChild_Widget( 1434 iLabelWidget *accept = addChild_Widget(
1425 div, 1435 div,
1426 iClob(newKeyMods_LabelWidget( 1436 iClob(newKeyMods_LabelWidget(
1427 uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); 1437 uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept")));
1438 setFont_LabelWidget(accept, uiLabelBold_FontId);
1428 } 1439 }
1429 addChild_Widget(dlg, iClob(div)); 1440 addChild_Widget(dlg, iClob(div));
1430 addChild_Widget(get_Window()->root, iClob(dlg)); 1441 addChild_Widget(get_Window()->root, iClob(dlg));