summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-05 22:53:10 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-05 22:53:10 +0200
commit78dcb6d388155454cfd042072419eb03080ad57d (patch)
tree73c0eb31abfa00c999ec500e3c9f8ebcf335913c /src
parentb9d8c68236b14bda918e3089f5965fdfd60ecba4 (diff)
UI color tuning; menu item backgrounds
Diffstat (limited to 'src')
-rw-r--r--src/ui/color.c7
-rw-r--r--src/ui/color.h1
-rw-r--r--src/ui/labelwidget.c6
-rw-r--r--src/ui/util.c9
-rw-r--r--src/ui/widget.c4
5 files changed, 17 insertions, 10 deletions
diff --git a/src/ui/color.c b/src/ui/color.c
index 51dcdc44..02ee59d6 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -87,6 +87,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
87 copy_(uiBackgroundFramelessHover_ColorId, accentLo); 87 copy_(uiBackgroundFramelessHover_ColorId, accentLo);
88 set_Color(uiBackgroundSidebar_ColorId, 88 set_Color(uiBackgroundSidebar_ColorId,
89 mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.55f)); 89 mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.55f));
90 copy_(uiBackgroundMenu_ColorId, uiBackground_ColorId);
90 copy_(uiText_ColorId, gray75_ColorId); 91 copy_(uiText_ColorId, gray75_ColorId);
91 copy_(uiTextPressed_ColorId, black_ColorId); 92 copy_(uiTextPressed_ColorId, black_ColorId);
92 copy_(uiTextStrong_ColorId, white_ColorId); 93 copy_(uiTextStrong_ColorId, white_ColorId);
@@ -136,6 +137,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
136 copy_(uiBackgroundFramelessHover_ColorId, accentLo); 137 copy_(uiBackgroundFramelessHover_ColorId, accentLo);
137 set_Color(uiBackgroundSidebar_ColorId, 138 set_Color(uiBackgroundSidebar_ColorId,
138 mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.75f)); 139 mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.75f));
140 copy_(uiBackgroundMenu_ColorId, uiBackground_ColorId);
139 copy_(uiText_ColorId, gray75_ColorId); 141 copy_(uiText_ColorId, gray75_ColorId);
140 copy_(uiTextPressed_ColorId, black_ColorId); 142 copy_(uiTextPressed_ColorId, black_ColorId);
141 copy_(uiTextStrong_ColorId, white_ColorId); 143 copy_(uiTextStrong_ColorId, white_ColorId);
@@ -185,6 +187,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
185 copy_(uiBackgroundFramelessHover_ColorId, accentHi); 187 copy_(uiBackgroundFramelessHover_ColorId, accentHi);
186 set_Color(uiBackgroundSidebar_ColorId, 188 set_Color(uiBackgroundSidebar_ColorId,
187 mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); 189 mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f));
190 copy_(uiBackgroundMenu_ColorId, white_ColorId);
188 copy_(uiText_ColorId, black_ColorId); 191 copy_(uiText_ColorId, black_ColorId);
189 copy_(uiTextStrong_ColorId, black_ColorId); 192 copy_(uiTextStrong_ColorId, black_ColorId);
190 copy_(uiTextDim_ColorId, gray25_ColorId); 193 copy_(uiTextDim_ColorId, gray25_ColorId);
@@ -234,6 +237,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
234 copy_(uiBackgroundFramelessHover_ColorId, accentHi); 237 copy_(uiBackgroundFramelessHover_ColorId, accentHi);
235 set_Color(uiBackgroundSidebar_ColorId, 238 set_Color(uiBackgroundSidebar_ColorId,
236 mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); 239 mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f));
240 copy_(uiBackgroundMenu_ColorId, uiBackground_ColorId);
237 set_Color(uiText_ColorId, 241 set_Color(uiText_ColorId,
238 mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.5f)); 242 mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.5f));
239 copy_(uiTextPressed_ColorId, black_ColorId); 243 copy_(uiTextPressed_ColorId, black_ColorId);
@@ -290,6 +294,9 @@ void setThemePalette_Color(enum iColorTheme theme) {
290 theme == pureBlack_ColorTheme ? -1 294 theme == pureBlack_ColorTheme ? -1
291 : theme == dark_ColorTheme ? -0.04 295 : theme == dark_ColorTheme ? -0.04
292 : -0.075)); 296 : -0.075));
297 set_Color(uiTextShortcut_ColorId, mix_Color(get_Color(uiTextShortcut_ColorId),
298 get_Color(uiBackground_ColorId),
299 0.4f));
293 palette_[uiMarked_ColorId].a = 128; 300 palette_[uiMarked_ColorId].a = 128;
294 palette_[uiMatching_ColorId].a = 128; 301 palette_[uiMatching_ColorId].a = 128;
295} 302}
diff --git a/src/ui/color.h b/src/ui/color.h
index 8556cd72..695e6302 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -114,6 +114,7 @@ enum iColorId {
114 uiSubheading_ColorId, 114 uiSubheading_ColorId,
115 uiTextAppTitle_ColorId, 115 uiTextAppTitle_ColorId,
116 uiBackgroundSidebar_ColorId, 116 uiBackgroundSidebar_ColorId,
117 uiBackgroundMenu_ColorId,
117 118
118 /* content theme colors */ 119 /* content theme colors */
119 tmFirst_ColorId, 120 tmFirst_ColorId,
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 4de00ec1..ffb0b7c2 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -224,8 +224,9 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
224 init_Paint(&p); 224 init_Paint(&p);
225 int bg, fg, frame, frame2; 225 int bg, fg, frame, frame2;
226 getColors_LabelWidget_(d, &bg, &fg, &frame, &frame2); 226 getColors_LabelWidget_(d, &bg, &fg, &frame, &frame2);
227 const iBool isCaution = startsWith_String(&d->label, uiTextCaution_ColorEscape);
227 if (bg >= 0) { 228 if (bg >= 0) {
228 fillRect_Paint(&p, rect, bg); 229 fillRect_Paint(&p, rect, isCaution && isHover ? uiMarked_ColorId : bg);
229 } 230 }
230 if (~flags & frameless_WidgetFlag) { 231 if (~flags & frameless_WidgetFlag) {
231 iRect frameRect = adjusted_Rect(rect, zero_I2(), init1_I2(-1)); 232 iRect frameRect = adjusted_Rect(rect, zero_I2(), init1_I2(-1));
@@ -249,8 +250,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) {
249 (flags & extraPadding_WidgetFlag ? -2 : -1) * gap_UI), 250 (flags & extraPadding_WidgetFlag ? -2 : -1) * gap_UI),
250 init_I2(iconPad, lineHeight_Text(d->font)) }, 251 init_I2(iconPad, lineHeight_Text(d->font)) },
251 iTrue, 252 iTrue,
252 startsWith_String(&d->label, uiTextCaution_ColorEscape) 253 isCaution ? uiTextCaution_ColorId
253 ? uiTextCaution_ColorId
254 : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg 254 : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg
255 : isHover ? uiIconHover_ColorId 255 : isHover ? uiIconHover_ColorId
256 : uiIcon_ColorId, 256 : uiIcon_ColorId,
diff --git a/src/ui/util.c b/src/ui/util.c
index e8bb95d8..df44cc80 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -478,7 +478,7 @@ iWidget *makeMenu_Widget(iWidget *parent, const iMenuItem *items, size_t n) {
478 iLabelWidget *label = addChildFlags_Widget( 478 iLabelWidget *label = addChildFlags_Widget(
479 menu, 479 menu,
480 iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)), 480 iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)),
481 frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag | itemFlags); 481 noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag | itemFlags);
482 haveIcons |= checkIcon_LabelWidget(label); 482 haveIcons |= checkIcon_LabelWidget(label);
483 updateSize_LabelWidget(label); /* drawKey was set */ 483 updateSize_LabelWidget(label); /* drawKey was set */
484 } 484 }
@@ -1284,7 +1284,7 @@ static void addFontButtons_(iWidget *parent, const char *id) {
1284 &(iMenuItem){ fontNames[i], 0, 0, format_CStr("!%s.set arg:%d", id, i) }); 1284 &(iMenuItem){ fontNames[i], 0, 0, format_CStr("!%s.set arg:%d", id, i) });
1285 } 1285 }
1286 iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans Pro", data_Array(items), size_Array(items)); 1286 iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans Pro", data_Array(items), size_Array(items));
1287// setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundSelected_ColorId); 1287 setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId);
1288 setId_Widget(as_Widget(button), format_CStr("prefs.%s", id)); 1288 setId_Widget(as_Widget(button), format_CStr("prefs.%s", id));
1289 addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag); 1289 addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag);
1290 delete_Array(items); 1290 delete_Array(items);
@@ -1371,6 +1371,7 @@ iWidget *makePreferences_Widget(void) {
1371 makeMenuButton_LabelWidget(themes[1].label, themes, iElemCount(themes)); 1371 makeMenuButton_LabelWidget(themes[1].label, themes, iElemCount(themes));
1372// setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"), 1372// setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"),
1373// uiBackgroundSelected_ColorId); 1373// uiBackgroundSelected_ColorId);
1374 setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId);
1374 setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag), 1375 setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag),
1375 format_CStr("prefs.doctheme.%s", mode)); 1376 format_CStr("prefs.doctheme.%s", mode));
1376 } 1377 }
@@ -1390,13 +1391,9 @@ iWidget *makePreferences_Widget(void) {
1390 /* Fonts. */ { 1391 /* Fonts. */ {
1391 iWidget *fonts; 1392 iWidget *fonts;
1392 addChild_Widget(headings, iClob(makeHeading_Widget("Heading font:"))); 1393 addChild_Widget(headings, iClob(makeHeading_Widget("Heading font:")));
1393// fonts = new_Widget();
1394 addFontButtons_(values, "headingfont"); 1394 addFontButtons_(values, "headingfont");
1395// addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1396 addChild_Widget(headings, iClob(makeHeading_Widget("Body font:"))); 1395 addChild_Widget(headings, iClob(makeHeading_Widget("Body font:")));
1397// fonts = new_Widget();
1398 addFontButtons_(values, "font"); 1396 addFontButtons_(values, "font");
1399// addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1400 addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:"))); 1397 addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:")));
1401 iWidget *mono = new_Widget(); 1398 iWidget *mono = new_Widget();
1402 /* TODO: Needs labels! */ 1399 /* TODO: Needs labels! */
diff --git a/src/ui/widget.c b/src/ui/widget.c
index a676da6e..bb5431eb 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -687,7 +687,9 @@ void drawBackground_Widget(const iWidget *d) {
687 drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect), uiBackgroundFramelessHover_ColorId); 687 drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect), uiBackgroundFramelessHover_ColorId);
688 } 688 }
689 /* Popup menus have a shadowed border. */ 689 /* Popup menus have a shadowed border. */
690 if (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) { 690 const iBool shadowBorder =
691 (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) != 0;
692 if (shadowBorder) {
691 iPaint p; 693 iPaint p;
692 init_Paint(&p); 694 init_Paint(&p);
693 const iBool isLight = isLight_ColorTheme(colorTheme_App()); 695 const iBool isLight = isLight_ColorTheme(colorTheme_App());