From dd1663e6273bb2c8fdf61a5347c2b2d68c02d3b9 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Mon, 8 Nov 2021 17:36:39 +0000 Subject: [PATCH] theme: add menu.overlap.{x,y} --- docs/labwc-theme.5.scd | 10 ++++++++++ docs/themerc | 2 ++ include/theme.h | 6 +++++- src/menu/menu.c | 9 +++++---- src/theme.c | 8 ++++++++ 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index fce1ee65..700635e5 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -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 diff --git a/docs/themerc b/docs/themerc index f3e851ec..ec8c001e 100644 --- a/docs/themerc +++ b/docs/themerc @@ -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 diff --git a/include/theme.h b/include/theme.h index 8ece8ae9..aa5fd8b1 100644 --- a/include/theme.h +++ b/include/theme.h @@ -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; diff --git a/src/menu/menu.c b/src/menu/menu.c index 5b3337fe..6f94d9fb 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -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); } } diff --git a/src/theme.c b/src/theme.c index 4fdf017d..79e8c535 100644 --- a/src/theme.c +++ b/src/theme.c @@ -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); -- 2.52.0