summaryrefslogtreecommitdiff
path: root/src/gmdocument.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-10-21 22:14:10 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-10-21 22:14:10 +0300
commit812b7415579b37b78728e5d220e25b7657e7a917 (patch)
tree7e37fe7754c7af65e2d78d1b56532595df943732 /src/gmdocument.c
parent7199a3515cb6b23a71a18b8016a65761581bd16c (diff)
Improved hover outline appearance
Theme-specific color selection, and a dividing line for the current position.
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r--src/gmdocument.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 02ca2bba..b8de304f 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -634,16 +634,6 @@ void reset_GmDocument(iGmDocument *d) {
634 d->themeSeed = 0; 634 d->themeSeed = 0;
635} 635}
636 636
637static float dimLightness_(float hue, float baseOffset) {
638 const float blueDiff = iWrapf(hue - 245, -180, 180);
639 float extra = 0.0f;
640 const float maxDiff = 60;
641 if (iAbs(blueDiff) < maxDiff) {
642 extra = 0.2f * (1.0f - iAbs(blueDiff) / maxDiff);
643 }
644 return baseOffset + extra;
645}
646
647static void setDerivedThemeColors_(enum iGmDocumentTheme theme) { 637static void setDerivedThemeColors_(enum iGmDocumentTheme theme) {
648 set_Color(tmQuoteIcon_ColorId, 638 set_Color(tmQuoteIcon_ColorId,
649 mix_Color(get_Color(tmQuote_ColorId), get_Color(tmBackground_ColorId), 0.55f)); 639 mix_Color(get_Color(tmQuote_ColorId), get_Color(tmBackground_ColorId), 0.55f));
@@ -652,6 +642,31 @@ static void setDerivedThemeColors_(enum iGmDocumentTheme theme) {
652 theme == colorfulDark_GmDocumentTheme ? 0.55f : 0)); 642 theme == colorfulDark_GmDocumentTheme ? 0.55f : 0));
653 set_Color(tmOutlineHeadingAbove_ColorId, get_Color(white_ColorId)); 643 set_Color(tmOutlineHeadingAbove_ColorId, get_Color(white_ColorId));
654 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(black_ColorId)); 644 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(black_ColorId));
645 switch (theme) {
646 case colorfulDark_GmDocumentTheme:
647 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(tmBannerTitle_ColorId));
648 if (equal_Color(get_Color(tmOutlineHeadingAbove_ColorId),
649 get_Color(tmOutlineHeadingBelow_ColorId))) {
650 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(tmHeading3_ColorId));
651 }
652 break;
653 case colorfulLight_GmDocumentTheme:
654 case sepia_GmDocumentTheme:
655 set_Color(tmOutlineHeadingAbove_ColorId, get_Color(black_ColorId));
656 set_Color(tmOutlineHeadingBelow_ColorId, mix_Color(get_Color(tmBackground_ColorId), get_Color(black_ColorId), 0.6f));
657 break;
658 case gray_GmDocumentTheme:
659 set_Color(tmOutlineHeadingBelow_ColorId, get_Color(gray75_ColorId));
660 break;
661 case white_GmDocumentTheme:
662 set_Color(tmOutlineHeadingBelow_ColorId, mix_Color(get_Color(tmBannerIcon_ColorId), get_Color(white_ColorId), 0.6f));
663 break;
664 case highContrast_GmDocumentTheme:
665 set_Color(tmOutlineHeadingAbove_ColorId, get_Color(black_ColorId));
666 break;
667 default:
668 break;
669 }
655} 670}
656 671
657void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { 672void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
@@ -723,7 +738,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
723 set_Color(tmHeading1_ColorId, get_Color(white_ColorId)); 738 set_Color(tmHeading1_ColorId, get_Color(white_ColorId));
724 setHsl_Color(tmHeading2_ColorId, addSatLum_HSLColor(base, 0.5f, 0.5f)); 739 setHsl_Color(tmHeading2_ColorId, addSatLum_HSLColor(base, 0.5f, 0.5f));
725 setHsl_Color(tmHeading3_ColorId, addSatLum_HSLColor(base, 1.0f, 0.4f)); 740 setHsl_Color(tmHeading3_ColorId, addSatLum_HSLColor(base, 1.0f, 0.4f));
726 set_Color(tmBannerBackground_ColorId, get_Color(black_ColorId)); 741 setHsl_Color(tmBannerBackground_ColorId, addSatLum_HSLColor(base, 0, -0.05f));
727 set_Color(tmBannerTitle_ColorId, get_Color(white_ColorId)); 742 set_Color(tmBannerTitle_ColorId, get_Color(white_ColorId));
728 set_Color(tmBannerIcon_ColorId, get_Color(orange_ColorId)); 743 set_Color(tmBannerIcon_ColorId, get_Color(orange_ColorId));
729 } 744 }
@@ -970,7 +985,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) {
970 else if (theme == black_GmDocumentTheme || theme == gray_GmDocumentTheme) { 985 else if (theme == black_GmDocumentTheme || theme == gray_GmDocumentTheme) {
971 const float primHue = hues[primIndex]; 986 const float primHue = hues[primIndex];
972 const iHSLColor primBright = { primHue, 1, 0.6f, 1 }; 987 const iHSLColor primBright = { primHue, 1, 0.6f, 1 };
973 const iHSLColor primDim = { primHue, 1, dimLightness_(primHue, theme == black_GmDocumentTheme ? 0.25f : 0.45f), 1}; 988 const iHSLColor primDim = { primHue, 1, normLum[primIndex] + (theme == gray_GmDocumentTheme ? 0.0f : -0.3f), 1};
974 const iHSLColor altBright = { altHue, 1, normLum[altIndex[0]] + (theme == gray_GmDocumentTheme ? 0.1f : 0.0f), 1 }; 989 const iHSLColor altBright = { altHue, 1, normLum[altIndex[0]] + (theme == gray_GmDocumentTheme ? 0.1f : 0.0f), 1 };
975 setHsl_Color(tmQuote_ColorId, altBright); 990 setHsl_Color(tmQuote_ColorId, altBright);
976 setHsl_Color(tmPreformatted_ColorId, altBright); 991 setHsl_Color(tmPreformatted_ColorId, altBright);