void
menu_move(struct menu *menu, int x, int y)
{
- menu->x = x;
- menu->y = y;
+ menu->box.x = x;
+ menu->box.y = y;
int offset = 0;
struct menuitem *menuitem;
wl_list_for_each_reverse (menuitem, &menu->menuitems, link) {
- menuitem->box.x = menu->x;
- menuitem->box.y = menu->y + offset;
+ menuitem->box.x = menu->box.x;
+ menuitem->box.y = menu->box.y + offset;
offset += menuitem->box.height;
}
+
+ menu->box.width = MENUWIDTH;
+ menu->box.height = offset;
}
void
render_rootmenu(struct output *output, pixman_region32_t *output_damage)
{
struct server *server = output->server;
+ struct theme *theme = server->theme;
float matrix[9];
struct wlr_output_layout *output_layout = server->output_layout;
double ox = 0, oy = 0;
wlr_output_layout_output_coords(output_layout, output->wlr_output,
&ox, &oy);
+
+ /* background */
+ render_rect(output, output_damage, &server->rootmenu->box,
+ theme->menu_items_bg_color);
+
+ /* items */
struct menuitem *menuitem;
wl_list_for_each (menuitem, &server->rootmenu->menuitems, link) {
- struct wlr_texture *t;
- t = menuitem->selected ? menuitem->texture.active :
- menuitem->texture.inactive;
struct wlr_box box = {
- .x = menuitem->box.x + ox + menuitem->texture.offset_x,
- .y = menuitem->box.y + oy + menuitem->texture.offset_y,
- .width = t->width,
- .height = t->height,
+ .x = menuitem->box.x + menuitem->texture.offset_x + ox,
+ .y = menuitem->box.y + menuitem->texture.offset_y + oy,
+ .width = menuitem->texture.active->width,
+ .height = menuitem->texture.active->height,
};
scale_box(&box, output->wlr_output->scale);
wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL,
0, output->wlr_output->transform_matrix);
- render_texture(output->wlr_output, output_damage, t,
- &box, matrix);
+ if (menuitem->selected) {
+ render_rect(output, output_damage, &menuitem->box,
+ theme->menu_items_active_bg_color);
+ render_texture(output->wlr_output, output_damage,
+ menuitem->texture.active, &box, matrix);
+ } else {
+ render_texture(output->wlr_output, output_damage,
+ menuitem->texture.inactive, &box, matrix);
+ }
}
}