diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-03 19:16:05 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-03 19:16:05 +0300 |
commit | 6d03cbb784b39ca457bcfce5f12de31972102790 (patch) | |
tree | 087f72f33f6259a932a75f610d4b3fc5e15844a9 /src/gmdocument.c | |
parent | 814c513984965d2732ef36215ba3fad97875af51 (diff) |
GmDocument: Light theme cleanup
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index eea0d1f9..b246d398 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -606,7 +606,9 @@ void reset_GmDocument(iGmDocument *d) { | |||
606 | } | 606 | } |
607 | 607 | ||
608 | void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | 608 | void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { |
609 | const float saturationLevel = 1.0f; /* TODO: user setting */ | ||
609 | const iBool isLightMode = isLight_ColorTheme(colorTheme_App()); | 610 | const iBool isLightMode = isLight_ColorTheme(colorTheme_App()); |
611 | const iBool isDarkMode = !isLightMode; | ||
610 | static const iChar siteIcons[] = { | 612 | static const iChar siteIcons[] = { |
611 | 0x203b, 0x2042, 0x205c, 0x2182, 0x25ed, 0x2600, 0x2601, 0x2604, 0x2605, 0x2606, | 613 | 0x203b, 0x2042, 0x205c, 0x2182, 0x25ed, 0x2600, 0x2601, 0x2604, 0x2605, 0x2606, |
612 | 0x265c, 0x265e, 0x2690, 0x2691, 0x2693, 0x2698, 0x2699, 0x26f0, 0x270e, 0x2728, | 614 | 0x265c, 0x265e, 0x2690, 0x2691, 0x2693, 0x2698, 0x2699, 0x26f0, 0x270e, 0x2728, |
@@ -616,7 +618,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
616 | 0x1f533, 0x1f657, 0x1f659, 0x1f665, 0x1f668, 0x1f66b, 0x1f78b, 0x1f796, 0x1f79c, | 618 | 0x1f533, 0x1f657, 0x1f659, 0x1f665, 0x1f668, 0x1f66b, 0x1f78b, 0x1f796, 0x1f79c, |
617 | }; | 619 | }; |
618 | /* Default colors. */ { | 620 | /* Default colors. */ { |
619 | if (!isLightMode) { | 621 | if (isDarkMode) { |
620 | const iHSLColor base = { 200, 0, 0.15f, 1.0f }; | 622 | const iHSLColor base = { 200, 0, 0.15f, 1.0f }; |
621 | setHsl_Color(tmBackground_ColorId, base); | 623 | setHsl_Color(tmBackground_ColorId, base); |
622 | set_Color(tmParagraph_ColorId, get_Color(gray75_ColorId)); | 624 | set_Color(tmParagraph_ColorId, get_Color(gray75_ColorId)); |
@@ -663,7 +665,6 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
663 | set_Color(tmBannerTitle_ColorId, get_Color(gray50_ColorId)); | 665 | set_Color(tmBannerTitle_ColorId, get_Color(gray50_ColorId)); |
664 | set_Color(tmBannerIcon_ColorId, get_Color(teal_ColorId)); | 666 | set_Color(tmBannerIcon_ColorId, get_Color(teal_ColorId)); |
665 | set_Color(tmInlineContentMetadata_ColorId, get_Color(brown_ColorId)); | 667 | set_Color(tmInlineContentMetadata_ColorId, get_Color(brown_ColorId)); |
666 | |||
667 | set_Color(tmLinkText_ColorId, get_Color(black_ColorId)); | 668 | set_Color(tmLinkText_ColorId, get_Color(black_ColorId)); |
668 | set_Color(tmLinkIcon_ColorId, get_Color(teal_ColorId)); | 669 | set_Color(tmLinkIcon_ColorId, get_Color(teal_ColorId)); |
669 | set_Color(tmLinkTextHover_ColorId, get_Color(teal_ColorId)); | 670 | set_Color(tmLinkTextHover_ColorId, get_Color(teal_ColorId)); |
@@ -691,7 +692,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
691 | } | 692 | } |
692 | else { | 693 | else { |
693 | d->themeSeed = 0; | 694 | d->themeSeed = 0; |
694 | d->siteIcon = 0; //0x1f310; /* globe */ | 695 | d->siteIcon = 0; |
695 | } | 696 | } |
696 | /* Set up colors. */ | 697 | /* Set up colors. */ |
697 | if (d->themeSeed) { | 698 | if (d->themeSeed) { |
@@ -726,49 +727,73 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
726 | { 8, 9 }, /* violet */ | 727 | { 8, 9 }, /* violet */ |
727 | { 7, 8 }, /* pink */ | 728 | { 7, 8 }, /* pink */ |
728 | }; | 729 | }; |
729 | const iBool isBannerLighter = (d->themeSeed & 0x4000) != 0; | ||
730 | const size_t primIndex = d->themeSeed ? (d->themeSeed & 0xff) % iElemCount(hues) : 2; | 730 | const size_t primIndex = d->themeSeed ? (d->themeSeed & 0xff) % iElemCount(hues) : 2; |
731 | const float saturationLevel = 1.0f; /* TODO: user setting */ | 731 | |
732 | const iBool isDarkBgSat = | 732 | const int altIndex[2] = { (d->themeSeed & 0x4) != 0, (d->themeSeed & 0x40) != 0 }; |
733 | const float altHue = hues[d->themeSeed ? altHues[primIndex].index[altIndex[0]] : 8]; | ||
734 | const float altHue2 = hues[d->themeSeed ? altHues[primIndex].index[altIndex[1]] : 8]; | ||
735 | |||
736 | const iBool isBannerLighter = (d->themeSeed & 0x4000) != 0; | ||
737 | const iBool isDarkBgSat = | ||
733 | (d->themeSeed & 0x200000) != 0 && (primIndex < 1 || primIndex > 4); | 738 | (d->themeSeed & 0x200000) != 0 && (primIndex < 1 || primIndex > 4); |
734 | iHSLColor base = { hues[primIndex], | 739 | |
735 | 0.8f * (d->themeSeed >> 24) / 255.0f, | ||
736 | 0.06f + 0.09f * ((d->themeSeed >> 5) & 0x7) / 7.0f, | ||
737 | 1.0f }; | ||
738 | // printf("background: %d %f %f\n", (int) base.hue, base.sat, base.lum); | 740 | // printf("background: %d %f %f\n", (int) base.hue, base.sat, base.lum); |
739 | // printf("isDarkBgSat: %d\n", isDarkBgSat); | 741 | // printf("isDarkBgSat: %d\n", isDarkBgSat); |
740 | iHSLColor bgBase = base; | ||
741 | setHsl_Color(tmBackground_ColorId, bgBase); | ||
742 | 742 | ||
743 | setHsl_Color(tmBannerBackground_ColorId, addSatLum_HSLColor(bgBase, 0.1f, 0.04f * (isBannerLighter ? 1 : -1))); | 743 | if (isDarkMode) { |
744 | setHsl_Color(tmBannerTitle_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.1f, 0), 0.55f)); | 744 | iHSLColor base = { hues[primIndex], |
745 | setHsl_Color(tmBannerIcon_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.35f, 0), 0.65f)); | 745 | 0.8f * (d->themeSeed >> 24) / 255.0f, |
746 | 0.06f + 0.09f * ((d->themeSeed >> 5) & 0x7) / 7.0f, | ||
747 | 1.0f }; | ||
748 | iHSLColor altBase = { altHue, base.sat, base.lum, 1 }; | ||
749 | |||
750 | setHsl_Color(tmBackground_ColorId, base); | ||
746 | 751 | ||
747 | const int altIndex[2] = { (d->themeSeed & 0x4) != 0, | 752 | setHsl_Color(tmBannerBackground_ColorId, addSatLum_HSLColor(base, 0.1f, 0.04f * (isBannerLighter ? 1 : -1))); |
748 | (d->themeSeed & 0x40) != 0 }; | 753 | setHsl_Color(tmBannerTitle_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.1f, 0), 0.55f)); |
754 | setHsl_Color(tmBannerIcon_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.35f, 0), 0.65f)); | ||
749 | 755 | ||
750 | // printf("primHue: %zu alts: %d %d\n", | 756 | // printf("primHue: %zu alts: %d %d\n", |
751 | // primIndex, | 757 | // primIndex, |
752 | // altHues[primIndex].index[altIndex[0]], | 758 | // altHues[primIndex].index[altIndex[0]], |
753 | // altHues[primIndex].index[altIndex[1]]); | 759 | // altHues[primIndex].index[altIndex[1]]); |
754 | const float altHue = hues[d->themeSeed ? altHues[primIndex].index[altIndex[0]] : 8]; | 760 | |
755 | const float altHue2 = hues[d->themeSeed ? altHues[primIndex].index[altIndex[1]] : 8]; | 761 | const float titleLum = 0.2f * ((d->themeSeed >> 17) & 0x7) / 7.0f; |
756 | iHSLColor altBase = { altHue, base.sat, base.lum, 1 }; | 762 | setHsl_Color(tmHeading1_ColorId, setLum_HSLColor(altBase, titleLum + 0.80f)); |
757 | const float titleLum = 0.2f * ((d->themeSeed >> 17) & 0x7) / 7.0f; | 763 | setHsl_Color(tmHeading2_ColorId, setLum_HSLColor(altBase, titleLum + 0.70f)); |
758 | setHsl_Color(tmHeading1_ColorId, setLum_HSLColor(altBase, titleLum + 0.80f)); | 764 | setHsl_Color(tmHeading3_ColorId, setLum_HSLColor(altBase, titleLum + 0.60f)); |
759 | setHsl_Color(tmHeading2_ColorId, setLum_HSLColor(altBase, titleLum + 0.70f)); | 765 | |
760 | setHsl_Color(tmHeading3_ColorId, setLum_HSLColor(altBase, titleLum + 0.60f)); | 766 | setHsl_Color(tmParagraph_ColorId, addSatLum_HSLColor(base, 0.1f, 0.6f)); |
761 | 767 | setHsl_Color(tmFirstParagraph_ColorId, addSatLum_HSLColor(base, 0.2f, 0.72f)); | |
762 | setHsl_Color(tmParagraph_ColorId, addSatLum_HSLColor(base, 0.1f, 0.6f)); | 768 | setHsl_Color(tmPreformatted_ColorId, (iHSLColor){ altHue2, 1.0f, 0.75f, 1.0f }); |
763 | setHsl_Color(tmFirstParagraph_ColorId, addSatLum_HSLColor(base, 0.2f, 0.72f)); | 769 | set_Color(tmQuote_ColorId, get_Color(tmPreformatted_ColorId)); |
764 | setHsl_Color(tmPreformatted_ColorId, (iHSLColor){ altHue2, 1.0f, 0.75f, 1.0f }); | 770 | set_Color(tmInlineContentMetadata_ColorId, get_Color(tmHeading3_ColorId)); |
765 | set_Color(tmQuote_ColorId, get_Color(tmPreformatted_ColorId)); | 771 | } |
766 | set_Color(tmInlineContentMetadata_ColorId, get_Color(tmHeading3_ColorId)); | 772 | else { |
773 | iHSLColor base = { hues[primIndex], 1.0f, 0.3f, 1.0f }; | ||
774 | iHSLColor altBase = { altHue, base.sat, base.lum - 0.1f, 1 }; | ||
775 | |||
776 | set_Color(tmBackground_ColorId, get_Color(white_ColorId)); | ||
777 | set_Color(tmBannerBackground_ColorId, get_Color(white_ColorId)); | ||
778 | setHsl_Color(tmBannerTitle_ColorId, addSatLum_HSLColor(base, -0.6f, 0.25f)); | ||
779 | setHsl_Color(tmBannerIcon_ColorId, addSatLum_HSLColor(base, 0, 0)); | ||
780 | |||
781 | setHsl_Color(tmHeading1_ColorId, base); //addSatLum_HSLColor(base, -0.5f, 0.125f)); | ||
782 | set_Color(tmHeading2_ColorId, mix_Color(rgb_HSLColor(base), rgb_HSLColor(altBase), 0.5f)); | ||
783 | setHsl_Color(tmHeading3_ColorId, altBase); | ||
784 | |||
785 | setHsl_Color(tmParagraph_ColorId, addSatLum_HSLColor(base, 0, -0.25f)); | ||
786 | setHsl_Color(tmFirstParagraph_ColorId, addSatLum_HSLColor(base, 0, -0.1f)); | ||
787 | setHsl_Color(tmPreformatted_ColorId, (iHSLColor){ altHue2, 1.0f, 0.25f, 1.0f }); | ||
788 | set_Color(tmQuote_ColorId, get_Color(tmPreformatted_ColorId)); | ||
789 | set_Color(tmInlineContentMetadata_ColorId, get_Color(tmHeading3_ColorId)); | ||
790 | } | ||
767 | 791 | ||
768 | /* Adjust colors based on light/dark mode. */ | 792 | /* Adjust colors based on light/dark mode. */ |
769 | for (int i = tmFirst_ColorId; i < max_ColorId; i++) { | 793 | for (int i = tmFirst_ColorId; i < max_ColorId; i++) { |
770 | iHSLColor color = hsl_Color(get_Color(i)); | 794 | iHSLColor color = hsl_Color(get_Color(i)); |
771 | if (isLightMode) { | 795 | if (isLightMode) { |
796 | #if 0 | ||
772 | if (isLink_ColorId(i)) continue; | 797 | if (isLink_ColorId(i)) continue; |
773 | color.lum = 1.0f - color.lum; /* All colors invert lightness. */ | 798 | color.lum = 1.0f - color.lum; /* All colors invert lightness. */ |
774 | if (isRegularText_ColorId(i)) { | 799 | if (isRegularText_ColorId(i)) { |
@@ -793,6 +818,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
793 | color.sat = 0.9f; | 818 | color.sat = 0.9f; |
794 | color.lum = (9 * color.lum + 0.5f) / 10; | 819 | color.lum = (9 * color.lum + 0.5f) / 10; |
795 | } | 820 | } |
821 | #endif | ||
796 | } | 822 | } |
797 | else { /* dark mode */ | 823 | else { /* dark mode */ |
798 | if (!isLink_ColorId(i)) { | 824 | if (!isLink_ColorId(i)) { |