theme: add menu.overlap.{x,y}

This commit is contained in:
Johan Malm 2021-11-08 17:36:39 +00:00
parent cd31283ba3
commit dd1663e627
5 changed files with 30 additions and 5 deletions

View 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. Vertical padding size, used for spacing out elements in the window decorations.
Default is 3. 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* *window.active.border.color*
Border color of active window Border color of active window

View file

@ -1,6 +1,8 @@
# general # general
border.width: 1 border.width: 1
padding.height: 3 padding.height: 3
menu.overlap.x: 0
menu.overlap.y: 0
# window border # window border
window.active.border.color: #dddad6 window.active.border.color: #dddad6

View file

@ -19,7 +19,10 @@ enum lab_justification {
struct theme { struct theme {
int border_width; int border_width;
int padding_height; int padding_height;
int menu_overlap_x;
int menu_overlap_y;
/* colors */
float window_active_border_color[4]; float window_active_border_color[4];
float window_inactive_border_color[4]; float window_inactive_border_color[4];
@ -30,7 +33,7 @@ struct theme {
float window_inactive_label_text_color[4]; float window_inactive_label_text_color[4];
enum lab_justification window_label_text_justify; enum lab_justification window_label_text_justify;
/* buttons */ /* button colors */
float window_active_button_iconify_unpressed_image_color[4]; float window_active_button_iconify_unpressed_image_color[4];
float window_active_button_max_unpressed_image_color[4]; float window_active_button_max_unpressed_image_color[4];
float window_active_button_close_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_bg_color[4];
float osd_label_text_color[4]; float osd_label_text_color[4];
/* textures */
struct wlr_texture *xbm_close_active_unpressed; struct wlr_texture *xbm_close_active_unpressed;
struct wlr_texture *xbm_maximize_active_unpressed; struct wlr_texture *xbm_maximize_active_unpressed;
struct wlr_texture *xbm_iconify_active_unpressed; struct wlr_texture *xbm_iconify_active_unpressed;

View file

@ -276,6 +276,8 @@ err:
static void static void
menu_configure(struct menu *menu, int x, int y) menu_configure(struct menu *menu, int x, int y)
{ {
struct theme *theme = menu->server->theme;
menu->box.x = x; menu->box.x = x;
menu->box.y = y; menu->box.y = y;
@ -286,10 +288,9 @@ menu_configure(struct menu *menu, int x, int y)
menuitem->box.y = menu->box.y + offset; menuitem->box.y = menu->box.y + offset;
offset += menuitem->box.height; offset += menuitem->box.height;
if (menuitem->submenu) { if (menuitem->submenu) {
/* TODO: add offset to rc.xml */ menu_configure(menuitem->submenu, menuitem->box.x
menu_configure(menuitem->submenu, + MENUWIDTH - theme->menu_overlap_x,
menuitem->box.x + MENUWIDTH + 10, menuitem->box.y + theme->menu_overlap_y);
menuitem->box.y);
} }
} }

View file

@ -91,6 +91,8 @@ theme_builtin(struct theme *theme)
{ {
theme->border_width = 1; theme->border_width = 1;
theme->padding_height = 3; theme->padding_height = 3;
theme->menu_overlap_x = 0;
theme->menu_overlap_y = 0;
parse_hexstr("#dddad6", theme->window_active_border_color); parse_hexstr("#dddad6", theme->window_active_border_color);
parse_hexstr("#f6f5f4", theme->window_inactive_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")) { if (match(key, "padding.height")) {
theme->padding_height = atoi(value); 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")) { if (match(key, "window.active.border.color")) {
parse_hexstr(value, theme->window_active_border_color); parse_hexstr(value, theme->window_active_border_color);