summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-10 17:08:42 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-10 17:08:42 +0200
commit11b5e74022461308da506f63f3e1902a64e5496a (patch)
treeb378a1931666e7e1381aee4e29984fa3fc6cef01 /src/gmdocument.c
parentbe1b78651171e9a9386c9fbbf8b8aced2e8dbcac (diff)
GmDocument: Links use a bold, tinted font
Links are important enough to stand out clearly. A bold font can be tinted with the primary theme color without losing readability.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 49a19cb9..17c44105 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -301,6 +301,11 @@ static iBool isNormalized_GmDocument_(const iGmDocument *d) {
301 return iTrue; 301 return iTrue;
302} 302}
303 303
304static enum iGmDocumentTheme currentTheme_(void) {
305 return (isDark_ColorTheme(colorTheme_App()) ? prefs_App()->docThemeDark
306 : prefs_App()->docThemeLight);
307}
308
304static void doLayout_GmDocument_(iGmDocument *d) { 309static void doLayout_GmDocument_(iGmDocument *d) {
305 const iBool isMono = isForcedMonospace_GmDocument_(d); 310 const iBool isMono = isForcedMonospace_GmDocument_(d);
306 const iBool isNarrow = d->size.x < 90 * gap_Text; 311 const iBool isNarrow = d->size.x < 90 * gap_Text;
@@ -313,7 +318,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
313 heading1_FontId, 318 heading1_FontId,
314 heading2_FontId, 319 heading2_FontId,
315 heading3_FontId, 320 heading3_FontId,
316 isMono ? regularMonospace_FontId : regular_FontId, 321 isMono ? regularMonospace_FontId : bold_FontId,
317 }; 322 };
318 static const int colors[max_GmLineType] = { 323 static const int colors[max_GmLineType] = {
319 tmParagraph_ColorId, 324 tmParagraph_ColorId,
@@ -820,8 +825,7 @@ static void updateIconBasedOnUrl_GmDocument_(iGmDocument *d) {
820 825
821void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { 826void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
822 const iPrefs * prefs = prefs_App(); 827 const iPrefs * prefs = prefs_App();
823 enum iGmDocumentTheme theme = 828 enum iGmDocumentTheme theme = currentTheme_();
824 (isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight);
825 static const iChar siteIcons[] = { 829 static const iChar siteIcons[] = {
826 0x203b, 0x2042, 0x205c, 0x2182, 0x25ed, 0x2600, 0x2601, 0x2604, 0x2605, 0x2606, 830 0x203b, 0x2042, 0x205c, 0x2182, 0x25ed, 0x2600, 0x2601, 0x2604, 0x2605, 0x2606,
827 0x265c, 0x265e, 0x2690, 0x2691, 0x2693, 0x2698, 0x2699, 0x26f0, 0x270e, 0x2728, 831 0x265c, 0x265e, 0x2690, 0x2691, 0x2693, 0x2698, 0x2699, 0x26f0, 0x270e, 0x2728,
@@ -971,6 +975,9 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
971 set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(tmBackground_ColorId), get_Color(brown_ColorId), 0.15f)); 975 set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(tmBackground_ColorId), get_Color(brown_ColorId), 0.15f));
972 set_Color(tmBannerTitle_ColorId, get_Color(brown_ColorId)); 976 set_Color(tmBannerTitle_ColorId, get_Color(brown_ColorId));
973 set_Color(tmBannerIcon_ColorId, get_Color(brown_ColorId)); 977 set_Color(tmBannerIcon_ColorId, get_Color(brown_ColorId));
978 set_Color(tmLinkText_ColorId, get_Color(tmHeading2_ColorId));
979 set_Color(tmHypertextLinkText_ColorId, get_Color(tmHeading2_ColorId));
980 set_Color(tmGopherLinkText_ColorId, get_Color(tmHeading2_ColorId));
974 } 981 }
975 else if (theme == white_GmDocumentTheme) { 982 else if (theme == white_GmDocumentTheme) {
976 const iHSLColor base = { 40, 0, 1.0f, 1.0f }; 983 const iHSLColor base = { 40, 0, 1.0f, 1.0f };
@@ -1177,7 +1184,14 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
1177 setHsl_Color(tmBannerTitle_ColorId, primDim); 1184 setHsl_Color(tmBannerTitle_ColorId, primDim);
1178 setHsl_Color(tmBannerIcon_ColorId, primDim); 1185 setHsl_Color(tmBannerIcon_ColorId, primDim);
1179 } 1186 }
1180 1187 /* Tone down the link colors a bit because bold white is quite strong to look at. */
1188 if (isDark_GmDocumentTheme(theme) || theme == white_GmDocumentTheme) {
1189 iHSLColor base = { hues[primIndex], 1.0f, normLum[primIndex], 1.0f };
1190 set_Color(tmLinkText_ColorId, mix_Color(get_Color(tmLinkText_ColorId),
1191 rgb_HSLColor(base), 0.25f));
1192 set_Color(tmHypertextLinkText_ColorId, get_Color(tmLinkText_ColorId));
1193 set_Color(tmGopherLinkText_ColorId, get_Color(tmLinkText_ColorId));
1194 }
1181 /* Adjust colors based on light/dark mode. */ 1195 /* Adjust colors based on light/dark mode. */
1182 for (int i = tmFirst_ColorId; i < max_ColorId; i++) { 1196 for (int i = tmFirst_ColorId; i < max_ColorId; i++) {
1183 iHSLColor color = hsl_Color(get_Color(i)); 1197 iHSLColor color = hsl_Color(get_Color(i));