diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-09 08:25:47 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-03-09 08:25:47 +0200 |
commit | d17dba488c5e1218ddff2d7a7d138a28ce25f1e2 (patch) | |
tree | 90e2359d74e15f8336d82b61f2e38ee712a7fb91 | |
parent | 5a1b9c16d4c45b9ae40c107bd2592415b48ded58 (diff) |
GmDocument: Light mode Gray document theme
The Gray theme now has a light and dark variant.
-rw-r--r-- | src/gmdocument.c | 65 | ||||
-rw-r--r-- | src/gmdocument.h | 5 | ||||
-rw-r--r-- | src/ui/color.c | 2 | ||||
-rw-r--r-- | src/ui/text.h | 2 |
4 files changed, 55 insertions, 19 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 660b05fd..a57bbc21 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -35,6 +35,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
35 | 35 | ||
36 | #include <ctype.h> | 36 | #include <ctype.h> |
37 | 37 | ||
38 | iBool isDark_GmDocumentTheme(enum iGmDocumentTheme d) { | ||
39 | if (d == gray_GmDocumentTheme) { | ||
40 | return isDark_ColorTheme(colorTheme_App()); | ||
41 | } | ||
42 | return d == colorfulDark_GmDocumentTheme || d == black_GmDocumentTheme; | ||
43 | } | ||
44 | |||
38 | iDeclareType(GmLink) | 45 | iDeclareType(GmLink) |
39 | 46 | ||
40 | struct Impl_GmLink { | 47 | struct Impl_GmLink { |
@@ -379,7 +386,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
379 | preFont = preformatted_FontId; | 386 | preFont = preformatted_FontId; |
380 | /* Use a smaller font if the block contents are wide. */ | 387 | /* Use a smaller font if the block contents are wide. */ |
381 | if (measurePreformattedBlock_GmDocument_(d, line.start, preFont).x > | 388 | if (measurePreformattedBlock_GmDocument_(d, line.start, preFont).x > |
382 | d->size.x - indents[preformatted_GmLineType] * gap_Text) { | 389 | d->size.x /*- indents[preformatted_GmLineType] * gap_Text*/) { |
383 | preFont = preformattedSmall_FontId; | 390 | preFont = preformattedSmall_FontId; |
384 | } | 391 | } |
385 | trimLine_Rangecc_(&line, type, isNormalized); | 392 | trimLine_Rangecc_(&line, type, isNormalized); |
@@ -906,17 +913,36 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
906 | set_Color(tmBannerIcon_ColorId, get_Color(teal_ColorId)); | 913 | set_Color(tmBannerIcon_ColorId, get_Color(teal_ColorId)); |
907 | } | 914 | } |
908 | else if (theme == gray_GmDocumentTheme) { | 915 | else if (theme == gray_GmDocumentTheme) { |
909 | set_Color(tmBackground_ColorId, mix_Color(get_Color(gray25_ColorId), get_Color(black_ColorId), 0.25f)); | 916 | if (isDark_ColorTheme(colorTheme_App())) { |
910 | set_Color(tmParagraph_ColorId, mix_Color(get_Color(gray75_ColorId), get_Color(white_ColorId), 0.25f)); | 917 | set_Color(tmBackground_ColorId, mix_Color(get_Color(gray25_ColorId), get_Color(black_ColorId), 0.25f)); |
911 | set_Color(tmFirstParagraph_ColorId, mix_Color(get_Color(gray75_ColorId), get_Color(white_ColorId), 0.5f)); | 918 | set_Color(tmParagraph_ColorId, mix_Color(get_Color(gray75_ColorId), get_Color(white_ColorId), 0.25f)); |
912 | set_Color(tmQuote_ColorId, get_Color(orange_ColorId)); | 919 | set_Color(tmFirstParagraph_ColorId, mix_Color(get_Color(gray75_ColorId), get_Color(white_ColorId), 0.5f)); |
913 | set_Color(tmPreformatted_ColorId, get_Color(orange_ColorId)); | 920 | set_Color(tmQuote_ColorId, get_Color(orange_ColorId)); |
914 | set_Color(tmHeading1_ColorId, get_Color(cyan_ColorId)); | 921 | set_Color(tmPreformatted_ColorId, get_Color(orange_ColorId)); |
915 | set_Color(tmHeading2_ColorId, mix_Color(get_Color(cyan_ColorId), get_Color(white_ColorId), 0.66f)); | 922 | set_Color(tmHeading1_ColorId, get_Color(cyan_ColorId)); |
916 | set_Color(tmHeading3_ColorId, get_Color(white_ColorId)); | 923 | set_Color(tmHeading2_ColorId, mix_Color(get_Color(cyan_ColorId), get_Color(white_ColorId), 0.66f)); |
917 | set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(gray25_ColorId), get_Color(black_ColorId), 0.5f)); | 924 | set_Color(tmHeading3_ColorId, get_Color(white_ColorId)); |
918 | set_Color(tmBannerTitle_ColorId, get_Color(teal_ColorId)); | 925 | set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(gray25_ColorId), get_Color(black_ColorId), 0.5f)); |
919 | set_Color(tmBannerIcon_ColorId, get_Color(teal_ColorId)); | 926 | set_Color(tmBannerTitle_ColorId, get_Color(teal_ColorId)); |
927 | set_Color(tmBannerIcon_ColorId, get_Color(teal_ColorId)); | ||
928 | } | ||
929 | else { | ||
930 | set_Color(tmBackground_ColorId, mix_Color(get_Color(gray75_ColorId), get_Color(gray50_ColorId), 0.33f)); | ||
931 | set_Color(tmFirstParagraph_ColorId, mix_Color(get_Color(gray25_ColorId), get_Color(black_ColorId), 0.5f)); | ||
932 | set_Color(tmParagraph_ColorId, get_Color(black_ColorId)); | ||
933 | set_Color(tmQuote_ColorId, get_Color(teal_ColorId)); | ||
934 | set_Color(tmPreformatted_ColorId, get_Color(brown_ColorId)); | ||
935 | set_Color(tmHeading1_ColorId, get_Color(brown_ColorId)); | ||
936 | set_Color(tmHeading2_ColorId, mix_Color(get_Color(brown_ColorId), get_Color(black_ColorId), 0.5f)); | ||
937 | set_Color(tmHeading3_ColorId, get_Color(black_ColorId)); | ||
938 | set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(gray75_ColorId), get_Color(gray50_ColorId), 0.12f)); | ||
939 | set_Color(tmBannerTitle_ColorId, get_Color(orange_ColorId)); | ||
940 | set_Color(tmBannerIcon_ColorId, get_Color(orange_ColorId)); | ||
941 | set_Color(tmLinkIconVisited_ColorId, mix_Color(get_Color(cyan_ColorId), get_Color(black_ColorId), 0.20f)); | ||
942 | set_Color(tmLinkDomain_ColorId, mix_Color(get_Color(cyan_ColorId), get_Color(black_ColorId), 0.33f)); | ||
943 | set_Color(tmHypertextLinkIconVisited_ColorId, mix_Color(get_Color(orange_ColorId), get_Color(black_ColorId), 0.33f)); | ||
944 | set_Color(tmHypertextLinkDomain_ColorId, mix_Color(get_Color(orange_ColorId), get_Color(black_ColorId), 0.33f)); | ||
945 | } | ||
920 | } | 946 | } |
921 | else if (theme == sepia_GmDocumentTheme) { | 947 | else if (theme == sepia_GmDocumentTheme) { |
922 | const iHSLColor base = { 40, 0.6f, 0.9f, 1.0f }; | 948 | const iHSLColor base = { 40, 0.6f, 0.9f, 1.0f }; |
@@ -1110,7 +1136,8 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
1110 | set_Color(tmQuote_ColorId, get_Color(tmPreformatted_ColorId)); | 1136 | set_Color(tmQuote_ColorId, get_Color(tmPreformatted_ColorId)); |
1111 | set_Color(tmInlineContentMetadata_ColorId, get_Color(tmHeading3_ColorId)); | 1137 | set_Color(tmInlineContentMetadata_ColorId, get_Color(tmHeading3_ColorId)); |
1112 | } | 1138 | } |
1113 | else if (theme == black_GmDocumentTheme || theme == gray_GmDocumentTheme) { | 1139 | else if (theme == black_GmDocumentTheme || |
1140 | (theme == gray_GmDocumentTheme && isDark_ColorTheme(colorTheme_App()))) { | ||
1114 | const float primHue = hues[primIndex]; | 1141 | const float primHue = hues[primIndex]; |
1115 | const iHSLColor primBright = { primHue, 1, 0.6f, 1 }; | 1142 | const iHSLColor primBright = { primHue, 1, 0.6f, 1 }; |
1116 | const iHSLColor primDim = { primHue, 1, normLum[primIndex] + (theme == gray_GmDocumentTheme ? 0.0f : -0.3f), 1}; | 1143 | const iHSLColor primDim = { primHue, 1, normLum[primIndex] + (theme == gray_GmDocumentTheme ? 0.0f : -0.3f), 1}; |
@@ -1122,6 +1149,18 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
1122 | setHsl_Color(tmBannerTitle_ColorId, primDim); | 1149 | setHsl_Color(tmBannerTitle_ColorId, primDim); |
1123 | setHsl_Color(tmBannerIcon_ColorId, primDim); | 1150 | setHsl_Color(tmBannerIcon_ColorId, primDim); |
1124 | } | 1151 | } |
1152 | else if (theme == gray_GmDocumentTheme) { /* Light gray. */ | ||
1153 | const float primHue = hues[primIndex]; | ||
1154 | const iHSLColor primBright = { primHue, 1, 0.3f, 1 }; | ||
1155 | const iHSLColor primDim = { primHue, 1, normLum[primIndex] * 0.33f, 1 }; | ||
1156 | const iHSLColor altBright = { altHue, 1, normLum[altIndex[0]] * 0.27f, 1 }; | ||
1157 | setHsl_Color(tmQuote_ColorId, altBright); | ||
1158 | setHsl_Color(tmPreformatted_ColorId, altBright); | ||
1159 | setHsl_Color(tmHeading1_ColorId, primBright); | ||
1160 | set_Color(tmHeading2_ColorId, mix_Color(get_Color(tmHeading1_ColorId), get_Color(black_ColorId), 0.4f)); | ||
1161 | setHsl_Color(tmBannerTitle_ColorId, primDim); | ||
1162 | setHsl_Color(tmBannerIcon_ColorId, primDim); | ||
1163 | } | ||
1125 | 1164 | ||
1126 | /* Adjust colors based on light/dark mode. */ | 1165 | /* Adjust colors based on light/dark mode. */ |
1127 | for (int i = tmFirst_ColorId; i < max_ColorId; i++) { | 1166 | for (int i = tmFirst_ColorId; i < max_ColorId; i++) { |
diff --git a/src/gmdocument.h b/src/gmdocument.h index 92f62ba4..1909460f 100644 --- a/src/gmdocument.h +++ b/src/gmdocument.h | |||
@@ -44,10 +44,7 @@ enum iGmDocumentTheme { | |||
44 | highContrast_GmDocumentTheme, | 44 | highContrast_GmDocumentTheme, |
45 | }; | 45 | }; |
46 | 46 | ||
47 | iLocalDef iBool isDark_GmDocumentTheme(enum iGmDocumentTheme d) { | 47 | iBool isDark_GmDocumentTheme(enum iGmDocumentTheme); |
48 | return d == colorfulDark_GmDocumentTheme || d == black_GmDocumentTheme || | ||
49 | d == gray_GmDocumentTheme; | ||
50 | } | ||
51 | 48 | ||
52 | typedef uint16_t iGmLinkId; | 49 | typedef uint16_t iGmLinkId; |
53 | 50 | ||
diff --git a/src/ui/color.c b/src/ui/color.c index 3c504c14..c751fec2 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -186,7 +186,7 @@ void setThemePalette_Color(enum iColorTheme theme) { | |||
186 | copy_(uiBackgroundPressed_ColorId, altAccentHi); | 186 | copy_(uiBackgroundPressed_ColorId, altAccentHi); |
187 | copy_(uiBackgroundFramelessHover_ColorId, accentHi); | 187 | copy_(uiBackgroundFramelessHover_ColorId, accentHi); |
188 | set_Color(uiBackgroundSidebar_ColorId, | 188 | set_Color(uiBackgroundSidebar_ColorId, |
189 | mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); | 189 | mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.67f)); |
190 | copy_(uiBackgroundMenu_ColorId, white_ColorId); | 190 | copy_(uiBackgroundMenu_ColorId, white_ColorId); |
191 | copy_(uiText_ColorId, black_ColorId); | 191 | copy_(uiText_ColorId, black_ColorId); |
192 | copy_(uiTextStrong_ColorId, black_ColorId); | 192 | copy_(uiTextStrong_ColorId, black_ColorId); |
diff --git a/src/ui/text.h b/src/ui/text.h index 8a023546..99f81d9f 100644 --- a/src/ui/text.h +++ b/src/ui/text.h | |||
@@ -143,7 +143,7 @@ iLocalDef iBool isEmoji_Char(iChar c) { | |||
143 | iLocalDef iBool isDingbats_Char(iChar c) { | 143 | iLocalDef iBool isDingbats_Char(iChar c) { |
144 | return c >= 0x2702 && c <= 0x27b0; | 144 | return c >= 0x2702 && c <= 0x27b0; |
145 | } | 145 | } |
146 | iLocalDef iBool isSymbol_Char(iChar c) { | 146 | iLocalDef iBool isPictograph_Char(iChar c) { |
147 | return (c == 0x21a9) || | 147 | return (c == 0x21a9) || |
148 | (c == 0x2218 || c == 0x2219) || | 148 | (c == 0x2218 || c == 0x2219) || |
149 | (c >= 0x2300 && c <= 0x26ff) || | 149 | (c >= 0x2300 && c <= 0x26ff) || |