mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
menu: Convert hardcoded item padding to theme vars
Adds two new theme vars: - menu.items.padding.x - menu.items.padding.y
This commit is contained in:
parent
3da7cfd8c6
commit
f0666ba5c9
4 changed files with 23 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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 <item></item> */
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue