]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: support different colored buttons
authorJohan Malm <jgm323@gmail.com>
Wed, 11 Aug 2021 19:58:35 +0000 (20:58 +0100)
committerJohan Malm <jgm323@gmail.com>
Wed, 11 Aug 2021 19:58:35 +0000 (20:58 +0100)
Add the following theme keys:

- window.active.button.iconify.unpressed.image.color
- window.active.button.max.unpressed.image.color
- window.active.button.close.unpressed.image.color
- window.inactive.button.iconify.unpressed.image.color
- window.inactive.button.max.unpressed.image.color
- window.inactive.button.close.unpressed.image.color

As far as I can tell, the openbox documentation does not mention the
entries listed above, but openbox does support them and some themes
do use them.

include/theme.h
src/theme.c
src/xbm/xbm.c

index a00c7b3389542e616f0162d25c568f4dd44ea61f..95954a3a6e97863dc70825e0b65b7d71896d3507 100644 (file)
@@ -20,8 +20,14 @@ struct theme {
        float window_active_title_bg_color[4];
        float window_inactive_title_bg_color[4];
 
-       float window_active_button_unpressed_image_color[4];
-       float window_inactive_button_unpressed_image_color[4];
+       /* buttons */
+       float window_active_button_iconify_unpressed_image_color[4];
+       float window_active_button_max_unpressed_image_color[4];
+       float window_active_button_close_unpressed_image_color[4];
+       float window_inactive_button_iconify_unpressed_image_color[4];
+       float window_inactive_button_max_unpressed_image_color[4];
+       float window_inactive_button_close_unpressed_image_color[4];
+       /* TODO: add pressed and hover colors for buttons */
 
        float menu_items_bg_color[4];
        float menu_items_text_color[4];
index 8d51c084fcc62b06c3b09d23c1e6a825fc8ad633..989b3121a97cf6f66deb18fcb1a4accfa797e29a 100644 (file)
@@ -84,8 +84,12 @@ theme_builtin(struct theme *theme)
        parse_hexstr("#dddad6", theme->window_active_title_bg_color);
        parse_hexstr("#f6f5f4", theme->window_inactive_title_bg_color);
 
-       parse_hexstr("#000000", theme->window_active_button_unpressed_image_color);
-       parse_hexstr("#000000", theme->window_inactive_button_unpressed_image_color);
+       parse_hexstr("#000000", theme->window_active_button_iconify_unpressed_image_color);
+       parse_hexstr("#000000", theme->window_active_button_max_unpressed_image_color);
+       parse_hexstr("#000000", theme->window_active_button_close_unpressed_image_color);
+       parse_hexstr("#000000", theme->window_inactive_button_iconify_unpressed_image_color);
+       parse_hexstr("#000000", theme->window_inactive_button_max_unpressed_image_color);
+       parse_hexstr("#000000", theme->window_inactive_button_close_unpressed_image_color);
 
        parse_hexstr("#fcfbfa", theme->menu_items_bg_color);
        parse_hexstr("#000000", theme->menu_items_text_color);
@@ -131,11 +135,36 @@ entry(struct theme *theme, const char *key, const char *value)
                parse_hexstr(value, theme->window_inactive_title_bg_color);
        }
 
+       /* universal button */
        if (match(key, "window.active.button.unpressed.image.color")) {
-               parse_hexstr(value, theme->window_active_button_unpressed_image_color);
+               parse_hexstr(value, theme->window_active_button_iconify_unpressed_image_color);
+               parse_hexstr(value, theme->window_active_button_max_unpressed_image_color);
+               parse_hexstr(value, theme->window_active_button_close_unpressed_image_color);
        }
        if (match(key, "window.inactive.button.unpressed.image.color")) {
-               parse_hexstr(value, theme->window_inactive_button_unpressed_image_color);
+               parse_hexstr(value, theme->window_inactive_button_iconify_unpressed_image_color);
+               parse_hexstr(value, theme->window_inactive_button_max_unpressed_image_color);
+               parse_hexstr(value, theme->window_inactive_button_close_unpressed_image_color);
+       }
+
+       /* individual buttons */
+       if (match(key, "window.active.button.iconify.unpressed.image.color")) {
+               parse_hexstr(value, theme->window_active_button_iconify_unpressed_image_color);
+       }
+       if (match(key, "window.active.button.max.unpressed.image.color")) {
+               parse_hexstr(value, theme->window_active_button_max_unpressed_image_color);
+       }
+       if (match(key, "window.active.button.close.unpressed.image.color")) {
+               parse_hexstr(value, theme->window_active_button_close_unpressed_image_color);
+       }
+       if (match(key, "window.inactive.button.iconify.unpressed.image.color")) {
+               parse_hexstr(value, theme->window_inactive_button_iconify_unpressed_image_color);
+       }
+       if (match(key, "window.inactive.button.max.unpressed.image.color")) {
+               parse_hexstr(value, theme->window_inactive_button_max_unpressed_image_color);
+       }
+       if (match(key, "window.inactive.button.close.unpressed.image.color")) {
+               parse_hexstr(value, theme->window_inactive_button_close_unpressed_image_color);
        }
 
        if (match(key, "menu.items.bg.color")) {
index e815366e55f53dd823c08256312d332f3571459f..9ea540aab72c536aaf9369d51745cce3d87f93e0 100644 (file)
@@ -86,19 +86,23 @@ out:
 void
 xbm_load(struct theme *theme, struct wlr_renderer *r)
 {
-       parse_set_color(theme->window_active_button_unpressed_image_color);
-       load_button(r, "close.xbm", &theme->xbm_close_active_unpressed,
-                   close_button_normal);
-       load_button(r, "max.xbm", &theme->xbm_maximize_active_unpressed,
-                   max_button_normal);
+       parse_set_color(theme->window_active_button_iconify_unpressed_image_color);
        load_button(r, "iconify.xbm", &theme->xbm_iconify_active_unpressed,
                    iconify_button_normal);
-
-       parse_set_color(theme->window_inactive_button_unpressed_image_color);
-       load_button(r, "close.xbm", &theme->xbm_close_inactive_unpressed,
-                   close_button_normal);
-       load_button(r, "max.xbm", &theme->xbm_maximize_inactive_unpressed,
+       parse_set_color(theme->window_active_button_max_unpressed_image_color);
+       load_button(r, "max.xbm", &theme->xbm_maximize_active_unpressed,
                    max_button_normal);
+       parse_set_color(theme->window_active_button_close_unpressed_image_color);
+       load_button(r, "close.xbm", &theme->xbm_close_active_unpressed,
+                   close_button_normal);
+
+       parse_set_color(theme->window_inactive_button_iconify_unpressed_image_color);
        load_button(r, "iconify.xbm", &theme->xbm_iconify_inactive_unpressed,
                    iconify_button_normal);
+       parse_set_color(theme->window_inactive_button_max_unpressed_image_color);
+       load_button(r, "max.xbm", &theme->xbm_maximize_inactive_unpressed,
+                   max_button_normal);
+       parse_set_color(theme->window_inactive_button_close_unpressed_image_color);
+       load_button(r, "close.xbm", &theme->xbm_close_inactive_unpressed,
+                   close_button_normal);
 }