]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add basic menu theme options
authorJohan Malm <jgm323@gmail.com>
Tue, 16 Feb 2021 20:43:20 +0000 (20:43 +0000)
committerJohan Malm <jgm323@gmail.com>
Tue, 16 Feb 2021 20:43:20 +0000 (20:43 +0000)
docs/labwc-theme.5.md
docs/themerc
include/theme/theme.h
src/menu/menu.c
src/theme/theme-builtin.c
src/theme/theme.c

index e32ae95f0f784529e0ae655469cdf4cccc601d94..a7db572e9ab3ad07a91479f45f4593ae28cfddb1 100644 (file)
@@ -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.
index 6b5057079aeed5ff8fddd12c9776af0b294e93fc..3f823f1287541993d4e69b3f71885a457f9ed35e 100644 (file)
@@ -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
index 5483ccd1cd1303d8bf215e56a4697b087d039cba..58890c0519c197c824ba47abe9b79e9b4a390b93 100644 (file)
@@ -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;
index eb9d726379d21be3b1b9ab4cd02b3f9a2250b37d..bc260f8c44a6a26d8c3b77b54bf1153248333414 100644 (file)
@@ -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;
 }
index e1f93e6783dc6ff3738a07b6522faa41f34819ff..a5dd0ddfdd16a1f048cb7c85cb81598a685cd7ed 100644 (file)
@@ -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);
 }
index 2c34946533eca2bd0b94881fd22f45d6d1b68b2e..f72b1e2bc61eb3a8eb42855f75285ebc1687d30b 100644 (file)
@@ -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);
        }
 }