summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-09-26 09:10:54 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-09-26 09:10:54 +0300
commitfe5c4c70cc19c1636af7b00ddbcbb6ae347acdf9 (patch)
tree1b0196d1b673b787dd54f018b2522f338408b22d /src/ui
parent5843195683f56797d0f637205851f69289047343 (diff)
macOS: Experiment with system accent color
This doesn't quite fit in the palette system currently, but it would be a nice addition later.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/color.c11
-rw-r--r--src/ui/color.h3
-rw-r--r--src/ui/util.c4
3 files changed, 18 insertions, 0 deletions
diff --git a/src/ui/color.c b/src/ui/color.c
index 9da49531..4f275ae5 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -81,6 +81,11 @@ iLocalDef void copy_(enum iColorId dst, enum iColorId src) {
81void setThemePalette_Color(enum iColorTheme theme) { 81void setThemePalette_Color(enum iColorTheme theme) {
82 const iPrefs *prefs = prefs_App(); 82 const iPrefs *prefs = prefs_App();
83 memcpy(uiPalette_, isDark_ColorTheme(theme) ? darkPalette_ : lightPalette_, sizeof(darkPalette_)); 83 memcpy(uiPalette_, isDark_ColorTheme(theme) ? darkPalette_ : lightPalette_, sizeof(darkPalette_));
84 if (prefs->accent == system_ColorAccent) {
85 iColor systemColor = systemAccent_Color();
86 memcpy(&uiPalette_[cyan_ColorId], &systemColor, sizeof(iColor));
87 memcpy(&uiPalette_[orange_ColorId], &systemColor, sizeof(iColor));
88 }
84 const int accentHi = (prefs->accent == cyan_ColorAccent ? cyan_ColorId : orange_ColorId); 89 const int accentHi = (prefs->accent == cyan_ColorAccent ? cyan_ColorId : orange_ColorId);
85 const int accentLo = (prefs->accent == cyan_ColorAccent ? teal_ColorId : brown_ColorId); 90 const int accentLo = (prefs->accent == cyan_ColorAccent ? teal_ColorId : brown_ColorId);
86 const int altAccentHi = (prefs->accent == cyan_ColorAccent ? orange_ColorId : cyan_ColorId); 91 const int altAccentHi = (prefs->accent == cyan_ColorAccent ? orange_ColorId : cyan_ColorId);
@@ -903,3 +908,9 @@ iBool loadPalette_Color(const char *path) {
903 iRelease(f); 908 iRelease(f);
904 return wasLoaded; 909 return wasLoaded;
905} 910}
911
912#if !defined (iPlatformAppleDesktop)
913iColor systemAccent_Color(void) {
914 return (iColor){ 255, 255, 255, 255 };
915}
916#endif
diff --git a/src/ui/color.h b/src/ui/color.h
index b6571c86..179db3e9 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -36,6 +36,7 @@ enum iColorTheme {
36enum iColorAccent { 36enum iColorAccent {
37 cyan_ColorAccent, 37 cyan_ColorAccent,
38 orange_ColorAccent, 38 orange_ColorAccent,
39 system_ColorAccent,
39 max_ColorAccent 40 max_ColorAccent
40}; 41};
41 42
@@ -251,3 +252,5 @@ void setThemePalette_Color (enum iColorTheme theme);
251iColor ansiForeground_Color (iRangecc escapeSequence, int fallback); 252iColor ansiForeground_Color (iRangecc escapeSequence, int fallback);
252const char * escape_Color (int color); 253const char * escape_Color (int color);
253enum iColorId parseEscape_Color (const char *cstr, const char **endp); 254enum iColorId parseEscape_Color (const char *cstr, const char **endp);
255
256iColor systemAccent_Color (void); /* platform-specific impl */
diff --git a/src/ui/util.c b/src/ui/util.c
index 872a91ab..2a0c89dc 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -2416,6 +2416,10 @@ iWidget *makePreferences_Widget(void) {
2416 iWidget *accent = new_Widget(); { 2416 iWidget *accent = new_Widget(); {
2417 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.teal}", "accent.set arg:0"))), "prefs.accent.0"); 2417 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.teal}", "accent.set arg:0"))), "prefs.accent.0");
2418 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.orange}", "accent.set arg:1"))), "prefs.accent.1"); 2418 setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.orange}", "accent.set arg:1"))), "prefs.accent.1");
2419#if defined (iPlatformApple)
2420 /* TODO: Needs some tweaking. */
2421// setId_Widget(addChild_Widget(accent, iClob(new_LabelWidget("${prefs.accent.system}", "accent.set arg:2"))), "prefs.accent.2");
2422#endif
2419 } 2423 }
2420 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.accent}"))); 2424 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.accent}")));
2421 addChildFlags_Widget(values, iClob(accent), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 2425 addChildFlags_Widget(values, iClob(accent), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);