]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: add menu.overlap.{x,y}
authorJohan Malm <jgm323@gmail.com>
Mon, 8 Nov 2021 17:36:39 +0000 (17:36 +0000)
committerJohan Malm <jgm323@gmail.com>
Mon, 8 Nov 2021 17:36:39 +0000 (17:36 +0000)
docs/labwc-theme.5.scd
docs/themerc
include/theme.h
src/menu/menu.c
src/theme.c

index fce1ee653176831cb4557bb7011cbe98f64f7fa5..700635e5e37f736f651bad6a8daa6435b8039bd4 100644 (file)
@@ -41,6 +41,16 @@ A theme consists of a themerc file and optionally some xbm icons.
        Vertical padding size, used for spacing out elements in the window decorations.
        Default is 3.
 
+*menu.overlap.x*
+       Horizontal overlap in pixels between submenus and their parents. A
+       positive value move submenus over the top of their parents, whereas a
+       negative value creates a gap between submenus and their parents.
+       Default is 0.
+
+*menu.overlap.y*
+       Vertical offset in pixels between submenus and their parents. Positive
+       values for downwards and negative for upwards. Default is 0.
+
 *window.active.border.color*
        Border color of active window
 
index f3e851ec775a41c60bed22671dfeb6fe710a9127..ec8c001e7309967da8bb4953a862f5f2f7f26c9f 100644 (file)
@@ -1,6 +1,8 @@
 # general
 border.width: 1
 padding.height: 3
+menu.overlap.x: 0
+menu.overlap.y: 0
 
 # window border
 window.active.border.color: #dddad6
index 8ece8ae9efd7d5f111820b16db08fa0936a1955d..aa5fd8b18461f1f5e8077fde7490deb6867bab38 100644 (file)
@@ -19,7 +19,10 @@ enum lab_justification {
 struct theme {
        int border_width;
        int padding_height;
+       int menu_overlap_x;
+       int menu_overlap_y;
 
+       /* colors */
        float window_active_border_color[4];
        float window_inactive_border_color[4];
 
@@ -30,7 +33,7 @@ struct theme {
        float window_inactive_label_text_color[4];
        enum lab_justification window_label_text_justify;
 
-       /* buttons */
+       /* button colors */
        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];
@@ -47,6 +50,7 @@ struct theme {
        float osd_bg_color[4];
        float osd_label_text_color[4];
 
+       /* textures */
        struct wlr_texture *xbm_close_active_unpressed;
        struct wlr_texture *xbm_maximize_active_unpressed;
        struct wlr_texture *xbm_iconify_active_unpressed;
index 5b3337fec86a0cd53ca36ea1fe050753e1872c0f..6f94d9fb2db46e3050b8c02784abea5e0414db62 100644 (file)
@@ -276,6 +276,8 @@ err:
 static void
 menu_configure(struct menu *menu, int x, int y)
 {
+       struct theme *theme = menu->server->theme;
+
        menu->box.x = x;
        menu->box.y = y;
 
@@ -286,10 +288,9 @@ menu_configure(struct menu *menu, int x, int y)
                menuitem->box.y = menu->box.y + offset;
                offset += menuitem->box.height;
                if (menuitem->submenu) {
-                       /* TODO: add offset to rc.xml */
-                       menu_configure(menuitem->submenu,
-                               menuitem->box.x + MENUWIDTH + 10,
-                               menuitem->box.y);
+                       menu_configure(menuitem->submenu, menuitem->box.x
+                               + MENUWIDTH - theme->menu_overlap_x,
+                               menuitem->box.y + theme->menu_overlap_y);
                }
        }
 
index 4fdf017d9929eb07e79e44839b52a2a756307095..79e8c5355e4fca96449460e4af566f59e8861c82 100644 (file)
@@ -91,6 +91,8 @@ theme_builtin(struct theme *theme)
 {
        theme->border_width = 1;
        theme->padding_height = 3;
+       theme->menu_overlap_x = 0;
+       theme->menu_overlap_y = 0;
 
        parse_hexstr("#dddad6", theme->window_active_border_color);
        parse_hexstr("#f6f5f4", theme->window_inactive_border_color);
@@ -152,6 +154,12 @@ entry(struct theme *theme, const char *key, const char *value)
        if (match(key, "padding.height")) {
                theme->padding_height = atoi(value);
        }
+       if (match(key, "menu.overlap.x")) {
+               theme->menu_overlap_x = atoi(value);
+       }
+       if (match(key, "menu.overlap.y")) {
+               theme->menu_overlap_y = atoi(value);
+       }
 
        if (match(key, "window.active.border.color")) {
                parse_hexstr(value, theme->window_active_border_color);