From bc04f50d14bab5fcf106ad7046e3caa383ad4c8e Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Tue, 16 Feb 2021 20:43:20 +0000 Subject: [PATCH] Add basic menu theme options --- docs/labwc-theme.5.md | 16 ++++++++++++++++ docs/themerc | 4 ++++ include/theme/theme.h | 5 +++++ src/menu/menu.c | 10 +++++----- src/theme/theme-builtin.c | 4 ++++ src/theme/theme.c | 8 ++++++++ 6 files changed, 42 insertions(+), 5 deletions(-) diff --git a/docs/labwc-theme.5.md b/docs/labwc-theme.5.md index e32ae95f..a7db572e 100644 --- a/docs/labwc-theme.5.md +++ b/docs/labwc-theme.5.md @@ -54,6 +54,22 @@ compatibility. : Color of the images in titlebar buttons in their default, unpressed, state. This element is for non-focused windows. +`menu.items.bg.color` + +: Background color of inactive menu items + +`menu.items.text.color` + +: Text color of inactive menu item + +`menu.items.active.bg.color` + +: Background color of active menu items + +`menu.items.active.text.color` + +: Text color of active menu item + # DEFINITIONS The `handle` is the window decoration placed on the bottom of the window. diff --git a/docs/themerc b/docs/themerc index 6b505707..3f823f12 100644 --- a/docs/themerc +++ b/docs/themerc @@ -6,3 +6,7 @@ window.inactive.title.bg.color: #efece6 window.active.button.unpressed.image.color = #ffffff window.inactive.button.unpressed.image.color = #000000 +menu.items.bg.color = #fcfbfa +menu.items.text.color = #000000 +menu.items.active.bg.color = #4a90d9 +menu.items.active.text.color = #ffffff diff --git a/include/theme/theme.h b/include/theme/theme.h index 5483ccd1..58890c05 100644 --- a/include/theme/theme.h +++ b/include/theme/theme.h @@ -19,6 +19,11 @@ struct theme { float window_active_button_unpressed_image_color[4]; float window_inactive_button_unpressed_image_color[4]; + float menu_items_bg_color[4]; + float menu_items_text_color[4]; + float menu_items_active_bg_color[4]; + float menu_items_active_text_color[4]; + struct wlr_texture *xbm_close_active_unpressed; struct wlr_texture *xbm_maximize_active_unpressed; struct wlr_texture *xbm_iconify_active_unpressed; diff --git a/src/menu/menu.c b/src/menu/menu.c index eb9d7263..bc260f8c 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -7,10 +7,9 @@ #include "common/font.h" #include "labwc.h" #include "menu/menu.h" +#include "theme/theme.h" -static float background[4] = { 0.3f, 0.1f, 0.1f, 1.0f }; -static float foreground[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; -static const char font[] = "Sans 10"; +static const char font[] = "Sans 8"; #define MENUWIDTH (100) #define MENUHEIGHT (25) @@ -70,9 +69,10 @@ menuitem_create(struct server *server, struct menu *menu, const char *text, menuitem->geo_box.width = MENUWIDTH; menuitem->geo_box.height = MENUHEIGHT; menuitem->active_texture = texture_create(server, &menuitem->geo_box, - text, background, foreground); + text, theme.menu_items_active_bg_color, + theme.menu_items_active_text_color); menuitem->inactive_texture = texture_create(server, &menuitem->geo_box, - text, foreground, background); + text, theme.menu_items_bg_color, theme.menu_items_text_color); wl_list_insert(&menu->menuitems, &menuitem->link); return menuitem; } diff --git a/src/theme/theme-builtin.c b/src/theme/theme-builtin.c index e1f93e67..a5dd0ddf 100644 --- a/src/theme/theme-builtin.c +++ b/src/theme/theme-builtin.c @@ -18,4 +18,8 @@ void theme_builtin(void) parse_hexstr("#efece6", theme.window_inactive_title_bg_color); parse_hexstr("#ffffff", theme.window_active_button_unpressed_image_color); parse_hexstr("#000000", theme.window_inactive_button_unpressed_image_color); + parse_hexstr("#fcfbfa", theme.menu_items_bg_color); + parse_hexstr("#000000", theme.menu_items_text_color); + parse_hexstr("#4a90d9", theme.menu_items_active_bg_color); + parse_hexstr("#ffffff", theme.menu_items_active_text_color); } diff --git a/src/theme/theme.c b/src/theme/theme.c index 2c349465..f72b1e2b 100644 --- a/src/theme/theme.c +++ b/src/theme/theme.c @@ -63,6 +63,14 @@ static void entry(const char *key, const char *value) parse_hexstr(value, theme.window_active_button_unpressed_image_color); } else if (match(key, "window.inactive.button.unpressed.image.color")) { parse_hexstr(value, theme.window_inactive_button_unpressed_image_color); + } else if (match(key, "menu.items.bg.color")) { + parse_hexstr(value, theme.menu_items_bg_color); + } else if (match(key, "menu.items.text.color")) { + parse_hexstr(value, theme.menu_items_text_color); + } else if (match(key, "menu.items.active.bg.color")) { + parse_hexstr(value, theme.menu_items_active_bg_color); + } else if (match(key, "menu.items.active.text.color")) { + parse_hexstr(value, theme.menu_items_active_text_color); } } -- 2.52.0