mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
menu: use theme->menu_item_height instead of menu->item_height
...and set it in theme.c post_processing()
This commit is contained in:
parent
0552c6b7f0
commit
9bc381d9e8
4 changed files with 12 additions and 14 deletions
|
|
@ -54,7 +54,6 @@ struct menuitem {
|
||||||
struct menu {
|
struct menu {
|
||||||
char *id;
|
char *id;
|
||||||
char *label;
|
char *label;
|
||||||
int item_height;
|
|
||||||
struct menu *parent;
|
struct menu *parent;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ struct theme {
|
||||||
|
|
||||||
int menu_item_padding_x;
|
int menu_item_padding_x;
|
||||||
int menu_item_padding_y;
|
int menu_item_padding_y;
|
||||||
|
int menu_item_height;
|
||||||
|
|
||||||
float menu_items_bg_color[4];
|
float menu_items_bg_color[4];
|
||||||
float menu_items_text_color[4];
|
float menu_items_text_color[4];
|
||||||
|
|
|
||||||
|
|
@ -210,12 +210,7 @@ item_create(struct menu *menu, const char *text, bool show_arrow)
|
||||||
|
|
||||||
const char *arrow = show_arrow ? "›" : NULL;
|
const char *arrow = show_arrow ? "›" : NULL;
|
||||||
|
|
||||||
/* TODO: Consider setting this somewhere else */
|
menuitem->height = theme->menu_item_height;
|
||||||
if (!menu->item_height) {
|
|
||||||
menu->item_height = font_height(&rc.font_menuitem)
|
|
||||||
+ 2 * theme->menu_item_padding_y;
|
|
||||||
}
|
|
||||||
menuitem->height = menu->item_height;
|
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
menuitem->native_width = font_width(&rc.font_menuitem, text);
|
menuitem->native_width = font_width(&rc.font_menuitem, text);
|
||||||
|
|
@ -235,11 +230,11 @@ item_create(struct menu *menu, const char *text, bool show_arrow)
|
||||||
/* Item background nodes */
|
/* Item background nodes */
|
||||||
menuitem->normal.background = &wlr_scene_rect_create(
|
menuitem->normal.background = &wlr_scene_rect_create(
|
||||||
menuitem->normal.tree,
|
menuitem->normal.tree,
|
||||||
menu->size.width, menu->item_height,
|
menu->size.width, theme->menu_item_height,
|
||||||
theme->menu_items_bg_color)->node;
|
theme->menu_items_bg_color)->node;
|
||||||
menuitem->selected.background = &wlr_scene_rect_create(
|
menuitem->selected.background = &wlr_scene_rect_create(
|
||||||
menuitem->selected.tree,
|
menuitem->selected.tree,
|
||||||
menu->size.width, menu->item_height,
|
menu->size.width, theme->menu_item_height,
|
||||||
theme->menu_items_active_bg_color)->node;
|
theme->menu_items_active_bg_color)->node;
|
||||||
|
|
||||||
/* Font nodes */
|
/* Font nodes */
|
||||||
|
|
@ -268,9 +263,9 @@ item_create(struct menu *menu, const char *text, bool show_arrow)
|
||||||
|
|
||||||
/* Center font nodes */
|
/* Center font nodes */
|
||||||
x = theme->menu_item_padding_x;
|
x = theme->menu_item_padding_x;
|
||||||
y = (menu->item_height - menuitem->normal.buffer->height) / 2;
|
y = (theme->menu_item_height - menuitem->normal.buffer->height) / 2;
|
||||||
wlr_scene_node_set_position(menuitem->normal.text, x, y);
|
wlr_scene_node_set_position(menuitem->normal.text, x, y);
|
||||||
y = (menu->item_height - menuitem->selected.buffer->height) / 2;
|
y = (theme->menu_item_height - menuitem->selected.buffer->height) / 2;
|
||||||
wlr_scene_node_set_position(menuitem->selected.text, x, y);
|
wlr_scene_node_set_position(menuitem->selected.text, x, y);
|
||||||
|
|
||||||
/* Position the item in relation to its menu */
|
/* Position the item in relation to its menu */
|
||||||
|
|
@ -299,7 +294,7 @@ separator_create(struct menu *menu, const char *label)
|
||||||
struct theme *theme = server->theme;
|
struct theme *theme = server->theme;
|
||||||
|
|
||||||
if (menuitem->type == LAB_MENU_TITLE) {
|
if (menuitem->type == LAB_MENU_TITLE) {
|
||||||
menuitem->height = menu->item_height;
|
menuitem->height = theme->menu_item_height;
|
||||||
menuitem->native_width = font_width(&rc.font_menuitem, label);
|
menuitem->native_width = font_width(&rc.font_menuitem, label);
|
||||||
} else if (menuitem->type == LAB_MENU_SEPARATOR_LINE) {
|
} else if (menuitem->type == LAB_MENU_SEPARATOR_LINE) {
|
||||||
menuitem->height = theme->menu_separator_line_thickness +
|
menuitem->height = theme->menu_separator_line_thickness +
|
||||||
|
|
@ -338,7 +333,7 @@ separator_create(struct menu *menu, const char *label)
|
||||||
/* Center font nodes */
|
/* Center font nodes */
|
||||||
int x, y;
|
int x, y;
|
||||||
x = theme->menu_item_padding_x;
|
x = theme->menu_item_padding_x;
|
||||||
y = (menu->item_height - menuitem->normal.buffer->height) / 2;
|
y = (theme->menu_item_height - menuitem->normal.buffer->height) / 2;
|
||||||
wlr_scene_node_set_position(menuitem->normal.text, x, y);
|
wlr_scene_node_set_position(menuitem->normal.text, x, y);
|
||||||
} else {
|
} else {
|
||||||
int nominal_width = theme->menu_min_width;
|
int nominal_width = theme->menu_min_width;
|
||||||
|
|
@ -849,7 +844,7 @@ menu_configure(struct menu *menu, int lx, int ly, enum menu_align align)
|
||||||
ly -= menu->size.height;
|
ly -= menu->size.height;
|
||||||
if (menu->parent) {
|
if (menu->parent) {
|
||||||
/* For submenus adjust y to bottom left corner */
|
/* For submenus adjust y to bottom left corner */
|
||||||
ly += menu->item_height;
|
ly += theme->menu_item_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wlr_scene_node_set_position(&menu->scene_tree->node, lx, ly);
|
wlr_scene_node_set_position(&menu->scene_tree->node, lx, ly);
|
||||||
|
|
|
||||||
|
|
@ -1305,6 +1305,9 @@ post_processing(struct theme *theme)
|
||||||
theme->title_height = h + 2 * theme->padding_height;
|
theme->title_height = h + 2 * theme->padding_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
theme->menu_item_height = font_height(&rc.font_menuitem)
|
||||||
|
+ 2 * theme->menu_item_padding_y;
|
||||||
|
|
||||||
theme->osd_window_switcher_item_height = font_height(&rc.font_osd)
|
theme->osd_window_switcher_item_height = font_height(&rc.font_osd)
|
||||||
+ 2 * theme->osd_window_switcher_item_padding_y
|
+ 2 * theme->osd_window_switcher_item_padding_y
|
||||||
+ 2 * theme->osd_window_switcher_item_active_border_width;
|
+ 2 * theme->osd_window_switcher_item_active_border_width;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue