diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index 6593728b..af431479 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -41,6 +41,14 @@ 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.items.padding.x* + Horizontal padding of menu text entries in pixels. + Default is 7. + +*menu.items.padding.y* + Vertical padding of menu text entries in pixels. + Default is 4. + *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 diff --git a/include/theme.h b/include/theme.h index d8692349..35972481 100644 --- a/include/theme.h +++ b/include/theme.h @@ -45,6 +45,9 @@ struct theme { float window_inactive_button_close_unpressed_image_color[4]; /* TODO: add pressed and hover colors for buttons */ + int menu_item_padding_x; + int menu_item_padding_y; + float menu_items_bg_color[4]; float menu_items_text_color[4]; float menu_items_active_bg_color[4]; diff --git a/src/menu/menu.c b/src/menu/menu.c index b27c6331..f02939ef 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -24,8 +24,6 @@ #include "theme.h" #define MENUWIDTH (110) -#define MENU_ITEM_PADDING_Y (4) -#define MENU_ITEM_PADDING_X (7) /* state-machine variables for processing */ static bool in_item; @@ -88,12 +86,12 @@ item_create(struct menu *menu, const char *text, bool show_arrow) if (!menu->item_height) { menu->item_height = font_height(&rc.font_menuitem) - + 2 * MENU_ITEM_PADDING_Y; + + 2 * theme->menu_item_padding_y; } menuitem->height = menu->item_height; int x, y; - int item_max_width = MENUWIDTH - 2 * MENU_ITEM_PADDING_X; + int item_max_width = MENUWIDTH - 2 * theme->menu_item_padding_x; /* Menu item root node */ menuitem->tree = wlr_scene_tree_create(menu->scene_tree); @@ -138,7 +136,7 @@ item_create(struct menu *menu, const char *text, bool show_arrow) &rc.font_menuitem, theme->menu_items_active_text_color, arrow); /* Center font nodes */ - x = MENU_ITEM_PADDING_X; + x = theme->menu_item_padding_x; y = (menu->item_height - menuitem->normal.buffer->height) / 2; wlr_scene_node_set_position(menuitem->normal.text, x, y); y = (menu->item_height - menuitem->selected.buffer->height) / 2; diff --git a/src/theme.c b/src/theme.c index f56ba8e5..5ae471ce 100644 --- a/src/theme.c +++ b/src/theme.c @@ -128,6 +128,9 @@ theme_builtin(struct theme *theme) parse_hexstr("#dddad6", theme->menu_items_active_bg_color); parse_hexstr("#000000", theme->menu_items_active_text_color); + theme->menu_item_padding_x = 7; + theme->menu_item_padding_y = 4; + theme->menu_separator_line_thickness = 1; theme->menu_separator_padding_width = 6; theme->menu_separator_padding_height = 3; @@ -167,6 +170,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.items.padding.x")) { + theme->menu_item_padding_x = atoi(value); + } + if (match(key, "menu.items.padding.y")) { + theme->menu_item_padding_y = atoi(value); + } if (match(key, "menu.overlap.x")) { theme->menu_overlap_x = atoi(value); }