mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
menu: Dynamically adjust menu width based on widest item
Adds two new theme vars: - menu.width.min (menu will never be smaller than this) - menu.width.max (menu will never be wider than this + padding) A fixed menu width can be achieved by setting menu.width.min == menu.width.max.
This commit is contained in:
parent
f0666ba5c9
commit
d00327bc32
7 changed files with 115 additions and 14 deletions
17
src/theme.c
17
src/theme.c
|
|
@ -131,6 +131,9 @@ theme_builtin(struct theme *theme)
|
|||
theme->menu_item_padding_x = 7;
|
||||
theme->menu_item_padding_y = 4;
|
||||
|
||||
theme->menu_min_width = 20;
|
||||
theme->menu_max_width = 200;
|
||||
|
||||
theme->menu_separator_line_thickness = 1;
|
||||
theme->menu_separator_padding_width = 6;
|
||||
theme->menu_separator_padding_height = 3;
|
||||
|
|
@ -260,6 +263,13 @@ entry(struct theme *theme, const char *key, const char *value)
|
|||
theme->window_inactive_button_close_unpressed_image_color);
|
||||
}
|
||||
|
||||
if (match(key, "menu.width.min")) {
|
||||
theme->menu_min_width = atoi(value);
|
||||
}
|
||||
if (match(key, "menu.width.max")) {
|
||||
theme->menu_max_width = atoi(value);
|
||||
}
|
||||
|
||||
if (match(key, "menu.items.bg.color")) {
|
||||
parse_hexstr(value, theme->menu_items_bg_color);
|
||||
}
|
||||
|
|
@ -488,6 +498,13 @@ post_processing(struct theme *theme)
|
|||
theme->title_height = rc.corner_radius + 1;
|
||||
}
|
||||
|
||||
if (theme->menu_max_width < theme->menu_min_width) {
|
||||
wlr_log(WLR_ERROR,
|
||||
"Adjusting menu.width.max: .max (%d) lower than .min (%d)",
|
||||
theme->menu_max_width, theme->menu_min_width);
|
||||
theme->menu_max_width = theme->menu_min_width;
|
||||
}
|
||||
|
||||
/* Inherit OSD settings if not set */
|
||||
if (theme->osd_bg_color[0] == FLT_MIN) {
|
||||
memcpy(theme->osd_bg_color,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue