summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-09 08:25:47 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-09 08:25:47 +0200
commitd17dba488c5e1218ddff2d7a7d138a28ce25f1e2 (patch)
tree90e2359d74e15f8336d82b61f2e38ee712a7fb91 /src/gmdocument.c
parent5a1b9c16d4c45b9ae40c107bd2592415b48ded58 (diff)
GmDocument: Light mode Gray document theme
The Gray theme now has a light and dark variant.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c65
1 files changed, 52 insertions, 13 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
38iBool 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
38iDeclareType(GmLink) 45iDeclareType(GmLink)
39 46
40struct Impl_GmLink { 47struct 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++) {