summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gmdocument.c86
-rw-r--r--src/ui/color.c2
-rw-r--r--src/ui/documentwidget.c21
3 files changed, 72 insertions, 37 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
608void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { 608void 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)) {
diff --git a/src/ui/color.c b/src/ui/color.c
index 723e9805..04f7881f 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -242,7 +242,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
242 copy_(uiAnnotation_ColorId, gray50_ColorId); 242 copy_(uiAnnotation_ColorId, gray50_ColorId);
243 copy_(uiIcon_ColorId, brown_ColorId); 243 copy_(uiIcon_ColorId, brown_ColorId);
244 copy_(uiIconHover_ColorId, brown_ColorId); 244 copy_(uiIconHover_ColorId, brown_ColorId);
245 copy_(uiSeparator_ColorId, gray75_ColorId); 245 copy_(uiSeparator_ColorId, gray50_ColorId);
246 copy_(uiMarked_ColorId, cyan_ColorId); 246 copy_(uiMarked_ColorId, cyan_ColorId);
247 copy_(uiMatching_ColorId, orange_ColorId); 247 copy_(uiMatching_ColorId, orange_ColorId);
248 break; 248 break;
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index c7056383..437e9468 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1367,7 +1367,8 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1367 ev->key.repeat != 0); 1367 ev->key.repeat != 0);
1368 return iTrue; 1368 return iTrue;
1369#if 1 1369#if 1
1370 case SDLK_KP_1: { 1370 case SDLK_KP_1:
1371 case '`': {
1371 iBlock *seed = new_Block(64); 1372 iBlock *seed = new_Block(64);
1372 for (size_t i = 0; i < 64; ++i) { 1373 for (size_t i = 0; i < 64; ++i) {
1373 setByte_Block(seed, i, iRandom(0, 255)); 1374 setByte_Block(seed, i, iRandom(0, 255));
@@ -1636,12 +1637,20 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1636 init_String(&bannerText); 1637 init_String(&bannerText);
1637 iInt2 bpos = add_I2(visPos, init_I2(0, lineHeight_Text(banner_FontId) / 2)); 1638 iInt2 bpos = add_I2(visPos, init_I2(0, lineHeight_Text(banner_FontId) / 2));
1638 if (icon) { 1639 if (icon) {
1640// appendChar_String(&bannerText, 0x2b24); // icon);
1641// const iRect iconRect = visualBounds_Text(hugeBold_FontId, range_String(&bannerText));
1642// drawRange_Text(hugeBold_FontId, /*run->font,*/
1643// addY_I2(bpos, -mid_Rect(iconRect).y + lineHeight_Text(run->font) / 2),
1644// tmBannerIcon_ColorId,
1645// range_String(&bannerText));
1646// clear_String(&bannerText);
1639 appendChar_String(&bannerText, icon); 1647 appendChar_String(&bannerText, icon);
1640 const iRect iconRect = visualBounds_Text(banner_FontId, range_String(&bannerText)); 1648 const iRect iconRect = visualBounds_Text(run->font, range_String(&bannerText));
1641 drawRange_Text(run->font, 1649 drawRange_Text(
1642 addY_I2(bpos, -mid_Rect(iconRect).y + lineHeight_Text(run->font) / 2), 1650 run->font,
1643 tmBannerIcon_ColorId, 1651 addY_I2(bpos, -mid_Rect(iconRect).y + lineHeight_Text(run->font) / 2),
1644 range_String(&bannerText)); 1652 tmBannerIcon_ColorId,
1653 range_String(&bannerText));
1645 bpos.x += right_Rect(iconRect) + 3 * gap_Text; 1654 bpos.x += right_Rect(iconRect) + 3 * gap_Text;
1646 } 1655 }
1647 drawRange_Text(run->font, 1656 drawRange_Text(run->font,