struct wlr_scene_node *hover;
struct wlr_scene_node *toggled;
struct wlr_scene_node *toggled_hover;
- struct wlr_scene_node *background;
struct wlr_scene_tree *icon_tree;
struct wlr_scene_tree *hover_tree;
struct wlr_scene_tree *parent, struct wlr_buffer *buffer, int x, int y);
struct ssd_part *add_scene_button(
struct wl_list *part_list, enum ssd_part_type type,
- struct wlr_scene_tree *parent, float *bg_color,
- struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer,
- int x, struct view *view);
+ struct wlr_scene_tree *parent, struct wlr_buffer *icon_buffer,
+ struct wlr_buffer *hover_buffer, int x, struct view *view);
void add_toggled_icon(struct ssd_button *button, struct wl_list *part_list,
enum ssd_part_type type, struct wlr_buffer *icon_buffer,
struct wlr_buffer *hover_buffer);
-struct ssd_part *add_scene_button_corner(
- struct wl_list *part_list, enum ssd_part_type type,
- enum ssd_part_type corner_type, struct wlr_scene_tree *parent,
- struct wlr_buffer *corner_buffer, struct wlr_buffer *icon_buffer,
- struct wlr_buffer *hover_buffer, int x, struct view *view);
/* SSD internal helpers */
struct ssd_part *ssd_get_part(
return part;
}
-struct ssd_part *
-add_scene_button_corner(struct wl_list *part_list, enum ssd_part_type type,
- enum ssd_part_type corner_type, struct wlr_scene_tree *parent,
- struct wlr_buffer *corner_buffer, struct wlr_buffer *icon_buffer,
- struct wlr_buffer *hover_buffer, int x, struct view *view)
-{
- int offset_x;
- float invisible[4] = { 0, 0, 0, 0 };
-
- if (corner_type == LAB_SSD_PART_CORNER_TOP_LEFT) {
- offset_x = rc.theme->border_width;
- } else if (corner_type == LAB_SSD_PART_CORNER_TOP_RIGHT) {
- offset_x = 0;
- } else {
- assert(false && "invalid corner button type");
- wlr_log(WLR_ERROR, "invalid corner button type");
- abort();
- }
-
- struct ssd_part *button_root = add_scene_part(part_list, corner_type);
- parent = wlr_scene_tree_create(parent);
- button_root->node = &parent->node;
- wlr_scene_node_set_position(button_root->node, x, 0);
-
- /*
- * Background, x and y adjusted for border_width which is
- * already included in rendered theme.c / corner_buffer
- */
- add_scene_buffer(part_list, corner_type, parent, corner_buffer,
- -offset_x, -rc.theme->border_width);
-
- /* Finally just put a usual theme button on top, using an invisible hitbox */
- add_scene_button(part_list, type, parent, invisible, icon_buffer, hover_buffer, 0, view);
- return button_root;
-}
-
static struct wlr_box
get_scale_box(struct wlr_buffer *buffer, double container_width,
double container_height)
struct ssd_part *
add_scene_button(struct wl_list *part_list, enum ssd_part_type type,
- struct wlr_scene_tree *parent, float *bg_color,
- struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer,
- int x, struct view *view)
+ struct wlr_scene_tree *parent, struct wlr_buffer *icon_buffer,
+ struct wlr_buffer *hover_buffer, int x, struct view *view)
{
struct ssd_part *button_root = add_scene_part(part_list, type);
parent = wlr_scene_tree_create(parent);
button_root->node = &parent->node;
wlr_scene_node_set_position(button_root->node, x, 0);
- /* Background */
- struct ssd_part *bg_rect = add_scene_rect(part_list, type, parent,
+ /* Hitbox */
+ float invisible[4] = { 0, 0, 0, 0 };
+ add_scene_rect(part_list, type, parent,
rc.theme->window_button_width, rc.theme->title_height, 0, 0,
- bg_color);
+ invisible);
/* Icon */
struct wlr_scene_tree *icon_tree = wlr_scene_tree_create(parent);
button->view = view;
button->normal = icon_part->node;
button->hover = hover_part->node;
- button->background = bg_rect->node;
button->toggled = NULL;
button->toggled_hover = NULL;
button->icon_tree = icon_tree;
}
wl_list_init(&subtree->parts);
- /* Title */
+ /* Background */
add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent,
- width - theme->window_button_width * SSD_BUTTON_COUNT,
- theme->title_height, theme->window_button_width, 0, color);
+ width - theme->window_button_width * 2, theme->title_height,
+ theme->window_button_width, 0, color);
+ add_scene_buffer(&subtree->parts, LAB_SSD_PART_CORNER_TOP_LEFT, parent,
+ corner_top_left, -rc.theme->border_width, -rc.theme->border_width);
+ add_scene_buffer(&subtree->parts, LAB_SSD_PART_CORNER_TOP_RIGHT, parent,
+ corner_top_right, width - theme->window_button_width,
+ -rc.theme->border_width);
+
/* Buttons */
- add_scene_button_corner(&subtree->parts,
- LAB_SSD_BUTTON_WINDOW_MENU, LAB_SSD_PART_CORNER_TOP_LEFT, parent,
- corner_top_left, menu_button_unpressed, menu_button_hover, 0, view);
+ add_scene_button(&subtree->parts, LAB_SSD_BUTTON_WINDOW_MENU, parent,
+ menu_button_unpressed, menu_button_hover, 0, view);
add_scene_button(&subtree->parts, LAB_SSD_BUTTON_ICONIFY, parent,
- color, iconify_button_unpressed, iconify_button_hover,
+ iconify_button_unpressed, iconify_button_hover,
width - theme->window_button_width * 3, view);
/* Maximize button has an alternate state when maximized */
struct ssd_part *btn_max_root = add_scene_button(
&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE, parent,
- color, maximize_button_unpressed, maximize_button_hover,
+ maximize_button_unpressed, maximize_button_hover,
width - theme->window_button_width * 2, view);
struct ssd_button *btn_max = node_ssd_button_from_node(btn_max_root->node);
add_toggled_icon(btn_max, &subtree->parts, LAB_SSD_BUTTON_MAXIMIZE,
restore_button_unpressed, restore_button_hover);
- add_scene_button_corner(&subtree->parts,
- LAB_SSD_BUTTON_CLOSE, LAB_SSD_PART_CORNER_TOP_RIGHT, parent,
- corner_top_right, close_button_unpressed, close_button_hover,
+ add_scene_button(&subtree->parts, LAB_SSD_BUTTON_CLOSE, parent,
+ close_button_unpressed, close_button_hover,
width - theme->window_button_width * 1, view);
} FOR_EACH_END
static void
set_squared_corners(struct ssd *ssd, bool enable)
{
+ struct view *view = ssd->view;
+ int width = view->current.width;
+ struct theme *theme = view->server->theme;
+
struct ssd_part *part;
struct ssd_sub_tree *subtree;
- enum ssd_part_type ssd_type[2] = { LAB_SSD_BUTTON_WINDOW_MENU, LAB_SSD_BUTTON_CLOSE };
+ int x = enable ? 0 : theme->window_button_width;
FOR_EACH_STATE(ssd, subtree) {
- for (size_t i = 0; i < ARRAY_SIZE(ssd_type); i++) {
- part = ssd_get_part(&subtree->parts, ssd_type[i]);
- struct ssd_button *button = node_ssd_button_from_node(part->node);
-
- /* Toggle background between invisible and titlebar background color */
- struct wlr_scene_rect *rect = wlr_scene_rect_from_node(button->background);
- wlr_scene_rect_set_color(rect, !enable ? (float[4]) {0, 0, 0, 0} : (
- subtree == &ssd->titlebar.active
- ? rc.theme->window_active_title_bg_color
- : rc.theme->window_inactive_title_bg_color));
-
- /* Toggle rounded corner image itself */
- struct wlr_scene_node *rounded_corner =
- wl_container_of(part->node->link.prev, rounded_corner, link);
- wlr_scene_node_set_enabled(rounded_corner, !enable);
- }
+ part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
+ wlr_scene_node_set_position(part->node, x, 0);
+ wlr_scene_rect_set_size(
+ wlr_scene_rect_from_node(part->node), width - 2 * x, theme->title_height);
+
+ part = ssd_get_part(&subtree->parts, LAB_SSD_PART_CORNER_TOP_LEFT);
+ wlr_scene_node_set_enabled(part->node, !enable);
+
+ part = ssd_get_part(&subtree->parts, LAB_SSD_PART_CORNER_TOP_RIGHT);
+ wlr_scene_node_set_enabled(part->node, !enable);
} FOR_EACH_END
}
struct ssd_part *part;
struct ssd_sub_tree *subtree;
+ int bg_offset = maximized || tiled_not_maximized ? 0 : theme->window_button_width;
FOR_EACH_STATE(ssd, subtree) {
wl_list_for_each(part, &subtree->parts, link) {
switch (part->type) {
case LAB_SSD_PART_TITLEBAR:
wlr_scene_rect_set_size(
wlr_scene_rect_from_node(part->node),
- width - theme->window_button_width * SSD_BUTTON_COUNT,
- theme->title_height);
+ width - bg_offset * 2, theme->title_height);
continue;
case LAB_SSD_BUTTON_ICONIFY:
if (is_direct_child(part->node, subtree)) {
width - theme->window_button_width * 2, 0);
}
continue;
- case LAB_SSD_PART_CORNER_TOP_RIGHT:
+ case LAB_SSD_BUTTON_CLOSE:
if (is_direct_child(part->node, subtree)) {
wlr_scene_node_set_position(part->node,
width - theme->window_button_width * 1, 0);
}
continue;
+ case LAB_SSD_PART_CORNER_TOP_RIGHT:
+ if (is_direct_child(part->node, subtree)) {
+ wlr_scene_node_set_position(part->node,
+ width - theme->window_button_width * 1,
+ -rc.theme->border_width);
+ }
+ continue;
default:
continue;
}