mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
menu: minor refactor of menu_configure()
This commit is contained in:
parent
138979c506
commit
38a60b04d9
1 changed files with 21 additions and 8 deletions
|
|
@ -593,6 +593,25 @@ menu_get_full_width(struct menu *menu)
|
||||||
return width + max_child_width;
|
return width + max_child_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct wlr_box
|
||||||
|
get_submenu_position(struct menuitem *item, enum menu_align align)
|
||||||
|
{
|
||||||
|
struct wlr_box pos = { 0 };
|
||||||
|
struct menu *menu = item->parent;
|
||||||
|
struct theme *theme = menu->server->theme;
|
||||||
|
int lx = menu->scene_tree->node.x;
|
||||||
|
int ly = menu->scene_tree->node.y;
|
||||||
|
|
||||||
|
if (align & LAB_MENU_OPEN_RIGHT) {
|
||||||
|
pos.x = lx + menu->size.width - theme->menu_overlap_x;
|
||||||
|
} else {
|
||||||
|
pos.x = lx;
|
||||||
|
}
|
||||||
|
int rel_y = item->tree->node.y;
|
||||||
|
pos.y = ly + rel_y - theme->menu_overlap_y;
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
menu_configure(struct menu *menu, int lx, int ly, enum menu_align align)
|
menu_configure(struct menu *menu, int lx, int ly, enum menu_align align)
|
||||||
{
|
{
|
||||||
|
|
@ -650,14 +669,8 @@ menu_configure(struct menu *menu, int lx, int ly, enum menu_align align)
|
||||||
if (!item->submenu) {
|
if (!item->submenu) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (align & LAB_MENU_OPEN_RIGHT) {
|
struct wlr_box pos = get_submenu_position(item, align);
|
||||||
new_lx = lx + menu->size.width - theme->menu_overlap_x;
|
menu_configure(item->submenu, pos.x, pos.y, align);
|
||||||
} else {
|
|
||||||
new_lx = lx;
|
|
||||||
}
|
|
||||||
rel_y = item->tree->node.y;
|
|
||||||
new_ly = ly + rel_y - theme->menu_overlap_y;
|
|
||||||
menu_configure(item->submenu, new_lx, new_ly, align);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue