diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-21 11:05:04 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-21 11:05:04 +0300 |
commit | bbba0d93270cc8a4ca71295cb1e0ab99e86e320d (patch) | |
tree | efba4f61cbae25173d11548d1fe21e7d038598a7 | |
parent | 9721a5f46bd2e3b1cc564cf615ef716658ef9c1a (diff) |
Document theme color saturation preference
-rw-r--r-- | src/app.c | 101 | ||||
-rw-r--r-- | src/gmdocument.c | 4 | ||||
-rw-r--r-- | src/ui/util.c | 29 |
3 files changed, 77 insertions, 57 deletions
@@ -164,6 +164,7 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
164 | appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); | 164 | appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); |
165 | appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); | 165 | appendFormat_String(str, "theme.set arg:%d auto:1\n", d->prefs.theme); |
166 | appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme); | 166 | appendFormat_String(str, "ostheme arg:%d\n", d->prefs.useSystemTheme); |
167 | appendFormat_String(str, "saturation.set arg:%d\n", (int) ((d->prefs.saturation * 100) + 0.5f)); | ||
167 | appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); | 168 | appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); |
168 | appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); | 169 | appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); |
169 | appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir)); | 170 | appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir)); |
@@ -799,7 +800,58 @@ iBool handleCommand_App(const char *cmd) { | |||
799 | d->prefs.retainWindowSize = arg_Command(cmd); | 800 | d->prefs.retainWindowSize = arg_Command(cmd); |
800 | return iTrue; | 801 | return iTrue; |
801 | } | 802 | } |
802 | else if (equal_Command(cmd, "downloads")) { | 803 | else if (equal_Command(cmd, "zoom.set")) { |
804 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | ||
805 | d->prefs.zoomPercent = arg_Command(cmd); | ||
806 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); | ||
807 | postCommand_App("font.changed"); | ||
808 | postCommand_App("window.unfreeze"); | ||
809 | return iTrue; | ||
810 | } | ||
811 | else if (equal_Command(cmd, "zoom.delta")) { | ||
812 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | ||
813 | int delta = arg_Command(cmd); | ||
814 | if (d->prefs.zoomPercent < 100 || (delta < 0 && d->prefs.zoomPercent == 100)) { | ||
815 | delta /= 2; | ||
816 | } | ||
817 | d->prefs.zoomPercent = iClamp(d->prefs.zoomPercent + delta, 50, 200); | ||
818 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); | ||
819 | postCommand_App("font.changed"); | ||
820 | postCommand_App("window.unfreeze"); | ||
821 | return iTrue; | ||
822 | } | ||
823 | else if (equal_Command(cmd, "forcewrap.toggle")) { | ||
824 | d->prefs.forceLineWrap = !d->prefs.forceLineWrap; | ||
825 | updateSize_DocumentWidget(document_App()); | ||
826 | return iTrue; | ||
827 | } | ||
828 | else if (equal_Command(cmd, "theme.set")) { | ||
829 | const int isAuto = argLabel_Command(cmd, "auto"); | ||
830 | d->prefs.theme = arg_Command(cmd); | ||
831 | if (!isAuto) { | ||
832 | postCommand_App("ostheme arg:0"); | ||
833 | } | ||
834 | setThemePalette_Color(d->prefs.theme); | ||
835 | postCommandf_App("theme.changed auto:%d", isAuto); | ||
836 | return iTrue; | ||
837 | } | ||
838 | else if (equal_Command(cmd, "ostheme")) { | ||
839 | d->prefs.useSystemTheme = arg_Command(cmd); | ||
840 | return iTrue; | ||
841 | } | ||
842 | else if (equal_Command(cmd, "saturation.set")) { | ||
843 | d->prefs.saturation = (float) arg_Command(cmd) / 100.0f; | ||
844 | postCommandf_App("theme.changed auto:1"); | ||
845 | return iTrue; | ||
846 | } | ||
847 | else if (equal_Command(cmd, "proxy.gopher")) { | ||
848 | setCStr_String(&d->prefs.gopherProxy, suffixPtr_Command(cmd, "address")); | ||
849 | return iTrue; | ||
850 | } | ||
851 | else if (equal_Command(cmd, "proxy.http")) { | ||
852 | setCStr_String(&d->prefs.httpProxy, suffixPtr_Command(cmd, "address")); | ||
853 | return iTrue; | ||
854 | } else if (equal_Command(cmd, "downloads")) { | ||
803 | setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path")); | 855 | setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path")); |
804 | return iTrue; | 856 | return iTrue; |
805 | } | 857 | } |
@@ -936,31 +988,6 @@ iBool handleCommand_App(const char *cmd) { | |||
936 | } | 988 | } |
937 | return iTrue; | 989 | return iTrue; |
938 | } | 990 | } |
939 | else if (equal_Command(cmd, "zoom.set")) { | ||
940 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | ||
941 | d->prefs.zoomPercent = arg_Command(cmd); | ||
942 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); | ||
943 | postCommand_App("font.changed"); | ||
944 | postCommand_App("window.unfreeze"); | ||
945 | return iTrue; | ||
946 | } | ||
947 | else if (equal_Command(cmd, "zoom.delta")) { | ||
948 | setFreezeDraw_Window(get_Window(), iTrue); /* no intermediate draws before docs updated */ | ||
949 | int delta = arg_Command(cmd); | ||
950 | if (d->prefs.zoomPercent < 100 || (delta < 0 && d->prefs.zoomPercent == 100)) { | ||
951 | delta /= 2; | ||
952 | } | ||
953 | d->prefs.zoomPercent = iClamp(d->prefs.zoomPercent + delta, 50, 200); | ||
954 | setContentFontSize_Text((float) d->prefs.zoomPercent / 100.0f); | ||
955 | postCommand_App("font.changed"); | ||
956 | postCommand_App("window.unfreeze"); | ||
957 | return iTrue; | ||
958 | } | ||
959 | else if (equal_Command(cmd, "forcewrap.toggle")) { | ||
960 | d->prefs.forceLineWrap = !d->prefs.forceLineWrap; | ||
961 | updateSize_DocumentWidget(document_App()); | ||
962 | return iTrue; | ||
963 | } | ||
964 | else if (equal_Command(cmd, "bookmark.add")) { | 991 | else if (equal_Command(cmd, "bookmark.add")) { |
965 | iDocumentWidget *doc = document_App(); | 992 | iDocumentWidget *doc = document_App(); |
966 | makeBookmarkCreation_Widget(url_DocumentWidget(doc), | 993 | makeBookmarkCreation_Widget(url_DocumentWidget(doc), |
@@ -995,20 +1022,6 @@ iBool handleCommand_App(const char *cmd) { | |||
995 | postCommand_App("idents.changed"); | 1022 | postCommand_App("idents.changed"); |
996 | return iTrue; | 1023 | return iTrue; |
997 | } | 1024 | } |
998 | else if (equal_Command(cmd, "theme.set")) { | ||
999 | const int isAuto = argLabel_Command(cmd, "auto"); | ||
1000 | d->prefs.theme = arg_Command(cmd); | ||
1001 | if (!isAuto) { | ||
1002 | postCommand_App("ostheme arg:0"); | ||
1003 | } | ||
1004 | setThemePalette_Color(d->prefs.theme); | ||
1005 | postCommandf_App("theme.changed auto:%d", isAuto); | ||
1006 | return iTrue; | ||
1007 | } | ||
1008 | else if (equal_Command(cmd, "ostheme")) { | ||
1009 | d->prefs.useSystemTheme = arg_Command(cmd); | ||
1010 | return iTrue; | ||
1011 | } | ||
1012 | else if (equal_Command(cmd, "os.theme.changed")) { | 1025 | else if (equal_Command(cmd, "os.theme.changed")) { |
1013 | if (d->prefs.useSystemTheme) { | 1026 | if (d->prefs.useSystemTheme) { |
1014 | const int dark = argLabel_Command(cmd, "dark"); | 1027 | const int dark = argLabel_Command(cmd, "dark"); |
@@ -1019,14 +1032,6 @@ iBool handleCommand_App(const char *cmd) { | |||
1019 | } | 1032 | } |
1020 | return iFalse; | 1033 | return iFalse; |
1021 | } | 1034 | } |
1022 | else if (equal_Command(cmd, "proxy.gopher")) { | ||
1023 | setCStr_String(&d->prefs.gopherProxy, suffixPtr_Command(cmd, "address")); | ||
1024 | return iTrue; | ||
1025 | } | ||
1026 | else if (equal_Command(cmd, "proxy.http")) { | ||
1027 | setCStr_String(&d->prefs.httpProxy, suffixPtr_Command(cmd, "address")); | ||
1028 | return iTrue; | ||
1029 | } | ||
1030 | else { | 1035 | else { |
1031 | return iFalse; | 1036 | return iFalse; |
1032 | } | 1037 | } |
diff --git a/src/gmdocument.c b/src/gmdocument.c index 0129db64..4414b04f 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -897,7 +897,9 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
897 | } | 897 | } |
898 | } | 898 | } |
899 | /* Modify overall saturation. */ | 899 | /* Modify overall saturation. */ |
900 | color.sat *= prefs->saturation; | 900 | if (!isLink_ColorId(i)) { |
901 | color.sat *= prefs->saturation; | ||
902 | } | ||
901 | setHsl_Color(i, color); | 903 | setHsl_Color(i, color); |
902 | } | 904 | } |
903 | } | 905 | } |
diff --git a/src/ui/util.c b/src/ui/util.c index 52107d81..c341a11d 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -843,9 +843,6 @@ static void expandInputFieldWidth_(iInputWidget *input) { | |||
843 | iWidget *page = as_Widget(input)->parent->parent->parent->parent; /* tabs > page > values > input */ | 843 | iWidget *page = as_Widget(input)->parent->parent->parent->parent; /* tabs > page > values > input */ |
844 | as_Widget(input)->rect.size.x = | 844 | as_Widget(input)->rect.size.x = |
845 | right_Rect(bounds_Widget(page)) - left_Rect(bounds_Widget(constAs_Widget(input))); | 845 | right_Rect(bounds_Widget(page)) - left_Rect(bounds_Widget(constAs_Widget(input))); |
846 | printf("expand to %s, %d - %d\n", cstr_String(id_Widget(page)), | ||
847 | right_Rect(bounds_Widget(page)), left_Rect(bounds_Widget(constAs_Widget(input)))); | ||
848 | fflush(stdout); | ||
849 | } | 846 | } |
850 | 847 | ||
851 | iWidget *makePreferences_Widget(void) { | 848 | iWidget *makePreferences_Widget(void) { |
@@ -881,18 +878,34 @@ iWidget *makePreferences_Widget(void) { | |||
881 | /* Layout. */ { | 878 | /* Layout. */ { |
882 | appendTwoColumnPage_(tabs, "Layout", &headings, &values); | 879 | appendTwoColumnPage_(tabs, "Layout", &headings, &values); |
883 | addChild_Widget(headings, iClob(makeHeading_Widget("Line width:"))); | 880 | addChild_Widget(headings, iClob(makeHeading_Widget("Line width:"))); |
884 | addChild_Widget(values, iClob(new_LabelWidget("Normal", 0, 0, NULL))); | 881 | iWidget *widths = new_Widget(); |
885 | addChild_Widget(headings, iClob(makeHeading_Widget("First paragaph:"))); | 882 | /* Line widths. */ { |
886 | addChild_Widget(values, iClob(new_LabelWidget("Emphasized", 0, 0, NULL))); | 883 | addChild_Widget(widths, iClob(new_LabelWidget("\u20132", 0, 0, "linewidth.set arg:-2"))); |
884 | addChild_Widget(widths, iClob(new_LabelWidget("\u20131", 0, 0, "linewidth.set arg:-1"))); | ||
885 | addChild_Widget(widths, iClob(new_LabelWidget("Normal", 0, 0, "linewidth.set arg:0"))); | ||
886 | addChild_Widget(widths, iClob(new_LabelWidget("+1", 0, 0, "linewidth.set arg:1"))); | ||
887 | addChild_Widget(widths, iClob(new_LabelWidget("+2", 0, 0, "linewidth.set arg:2"))); | ||
888 | addChild_Widget(widths, iClob(new_LabelWidget("Window", 0, 0, "linewidth.set arg:1000"))); | ||
889 | } | ||
890 | addChildFlags_Widget(values, iClob(widths), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | ||
891 | addChild_Widget(headings, iClob(makeHeading_Widget("Big 1st paragaph:"))); | ||
892 | addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede"))); | ||
887 | } | 893 | } |
888 | /* Colors. */ { | 894 | /* Colors. */ { |
889 | appendTwoColumnPage_(tabs, "Colors", &headings, &values); | 895 | appendTwoColumnPage_(tabs, "Colors", &headings, &values); |
890 | addChild_Widget(headings, iClob(makeHeading_Widget("Saturation:"))); | ||
891 | addChild_Widget(values, iClob(new_LabelWidget("Full", 0, 0, 0))); | ||
892 | addChild_Widget(headings, iClob(makeHeading_Widget("Dark theme:"))); | 896 | addChild_Widget(headings, iClob(makeHeading_Widget("Dark theme:"))); |
893 | addChild_Widget(values, iClob(new_LabelWidget("Colorful", 0, 0, 0))); | 897 | addChild_Widget(values, iClob(new_LabelWidget("Colorful", 0, 0, 0))); |
894 | addChild_Widget(headings, iClob(makeHeading_Widget("Light theme:"))); | 898 | addChild_Widget(headings, iClob(makeHeading_Widget("Light theme:"))); |
895 | addChild_Widget(values, iClob(new_LabelWidget("White", 0, 0, 0))); | 899 | addChild_Widget(values, iClob(new_LabelWidget("White", 0, 0, 0))); |
900 | addChild_Widget(headings, iClob(makeHeading_Widget("Saturation:"))); | ||
901 | iWidget *sats = new_Widget(); | ||
902 | /* Saturation levels. */ { | ||
903 | addChild_Widget(sats, iClob(new_LabelWidget("Full", 0, 0, "saturation.set arg:100"))); | ||
904 | addChild_Widget(sats, iClob(new_LabelWidget("Reduced", 0, 0, "saturation.set arg:66"))); | ||
905 | addChild_Widget(sats, iClob(new_LabelWidget("Minimal", 0, 0, "saturation.set arg:33"))); | ||
906 | addChild_Widget(sats, iClob(new_LabelWidget("Monochrome", 0, 0, "saturation.set arg:0"))); | ||
907 | } | ||
908 | addChildFlags_Widget(values, iClob(sats), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | ||
896 | } | 909 | } |
897 | /* Proxies. */ { | 910 | /* Proxies. */ { |
898 | appendTwoColumnPage_(tabs, "Proxies", &headings, &values); | 911 | appendTwoColumnPage_(tabs, "Proxies", &headings, &values); |