From 78dcb6d388155454cfd042072419eb03080ad57d Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Fri, 5 Mar 2021 22:53:10 +0200 Subject: UI color tuning; menu item backgrounds --- src/ui/color.c | 7 +++++++ src/ui/color.h | 1 + src/ui/labelwidget.c | 6 +++--- src/ui/util.c | 9 +++------ src/ui/widget.c | 4 +++- 5 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src') 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) { copy_(uiBackgroundFramelessHover_ColorId, accentLo); set_Color(uiBackgroundSidebar_ColorId, mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.55f)); + copy_(uiBackgroundMenu_ColorId, uiBackground_ColorId); copy_(uiText_ColorId, gray75_ColorId); copy_(uiTextPressed_ColorId, black_ColorId); copy_(uiTextStrong_ColorId, white_ColorId); @@ -136,6 +137,7 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundFramelessHover_ColorId, accentLo); set_Color(uiBackgroundSidebar_ColorId, mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.75f)); + copy_(uiBackgroundMenu_ColorId, uiBackground_ColorId); copy_(uiText_ColorId, gray75_ColorId); copy_(uiTextPressed_ColorId, black_ColorId); copy_(uiTextStrong_ColorId, white_ColorId); @@ -185,6 +187,7 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundFramelessHover_ColorId, accentHi); set_Color(uiBackgroundSidebar_ColorId, mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); + copy_(uiBackgroundMenu_ColorId, white_ColorId); copy_(uiText_ColorId, black_ColorId); copy_(uiTextStrong_ColorId, black_ColorId); copy_(uiTextDim_ColorId, gray25_ColorId); @@ -234,6 +237,7 @@ void setThemePalette_Color(enum iColorTheme theme) { copy_(uiBackgroundFramelessHover_ColorId, accentHi); set_Color(uiBackgroundSidebar_ColorId, mix_Color(get_Color(white_ColorId), get_Color(gray75_ColorId), 0.5f)); + copy_(uiBackgroundMenu_ColorId, uiBackground_ColorId); set_Color(uiText_ColorId, mix_Color(get_Color(black_ColorId), get_Color(gray25_ColorId), 0.5f)); copy_(uiTextPressed_ColorId, black_ColorId); @@ -290,6 +294,9 @@ void setThemePalette_Color(enum iColorTheme theme) { theme == pureBlack_ColorTheme ? -1 : theme == dark_ColorTheme ? -0.04 : -0.075)); + set_Color(uiTextShortcut_ColorId, mix_Color(get_Color(uiTextShortcut_ColorId), + get_Color(uiBackground_ColorId), + 0.4f)); palette_[uiMarked_ColorId].a = 128; palette_[uiMatching_ColorId].a = 128; } 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 { uiSubheading_ColorId, uiTextAppTitle_ColorId, uiBackgroundSidebar_ColorId, + uiBackgroundMenu_ColorId, /* content theme colors */ 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) { init_Paint(&p); int bg, fg, frame, frame2; getColors_LabelWidget_(d, &bg, &fg, &frame, &frame2); + const iBool isCaution = startsWith_String(&d->label, uiTextCaution_ColorEscape); if (bg >= 0) { - fillRect_Paint(&p, rect, bg); + fillRect_Paint(&p, rect, isCaution && isHover ? uiMarked_ColorId : bg); } if (~flags & frameless_WidgetFlag) { iRect frameRect = adjusted_Rect(rect, zero_I2(), init1_I2(-1)); @@ -249,8 +250,7 @@ static void draw_LabelWidget_(const iLabelWidget *d) { (flags & extraPadding_WidgetFlag ? -2 : -1) * gap_UI), init_I2(iconPad, lineHeight_Text(d->font)) }, iTrue, - startsWith_String(&d->label, uiTextCaution_ColorEscape) - ? uiTextCaution_ColorId + isCaution ? uiTextCaution_ColorId : flags & (disabled_WidgetFlag | pressed_WidgetFlag) ? fg : isHover ? uiIconHover_ColorId : 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) { iLabelWidget *label = addChildFlags_Widget( menu, iClob(newKeyMods_LabelWidget(item->label, item->key, item->kmods, item->command)), - frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag | itemFlags); + noBackground_WidgetFlag | frameless_WidgetFlag | alignLeft_WidgetFlag | drawKey_WidgetFlag | itemFlags); haveIcons |= checkIcon_LabelWidget(label); updateSize_LabelWidget(label); /* drawKey was set */ } @@ -1284,7 +1284,7 @@ static void addFontButtons_(iWidget *parent, const char *id) { &(iMenuItem){ fontNames[i], 0, 0, format_CStr("!%s.set arg:%d", id, i) }); } iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans Pro", data_Array(items), size_Array(items)); -// setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundSelected_ColorId); + setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId); setId_Widget(as_Widget(button), format_CStr("prefs.%s", id)); addChildFlags_Widget(parent, iClob(button), alignLeft_WidgetFlag); delete_Array(items); @@ -1371,6 +1371,7 @@ iWidget *makePreferences_Widget(void) { makeMenuButton_LabelWidget(themes[1].label, themes, iElemCount(themes)); // setFrameColor_Widget(findChild_Widget(as_Widget(button), "menu"), // uiBackgroundSelected_ColorId); + setBackgroundColor_Widget(findChild_Widget(as_Widget(button), "menu"), uiBackgroundMenu_ColorId); setId_Widget(addChildFlags_Widget(values, iClob(button), alignLeft_WidgetFlag), format_CStr("prefs.doctheme.%s", mode)); } @@ -1390,13 +1391,9 @@ iWidget *makePreferences_Widget(void) { /* Fonts. */ { iWidget *fonts; addChild_Widget(headings, iClob(makeHeading_Widget("Heading font:"))); -// fonts = new_Widget(); addFontButtons_(values, "headingfont"); -// addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); addChild_Widget(headings, iClob(makeHeading_Widget("Body font:"))); -// fonts = new_Widget(); addFontButtons_(values, "font"); -// addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:"))); iWidget *mono = new_Widget(); /* 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) { drawHLine_Paint(&p, topLeft_Rect(rect), width_Rect(rect), uiBackgroundFramelessHover_ColorId); } /* Popup menus have a shadowed border. */ - if (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) { + const iBool shadowBorder = + (d->flags & keepOnTop_WidgetFlag && ~d->flags & mouseModal_WidgetFlag) != 0; + if (shadowBorder) { iPaint p; init_Paint(&p); const iBool isLight = isLight_ColorTheme(colorTheme_App()); -- cgit v1.2.3