theme: add button padding and spacing (#2127)

While at it, separate corner width from button
width. Both are independed and having them
separately improves readability.
This commit is contained in:
Jens Peters 2024-09-09 17:43:38 +02:00 committed by Johan Malm
parent 8850368ab9
commit 824b0fa4e3
13 changed files with 105 additions and 39 deletions

View file

@ -617,8 +617,7 @@ view_adjust_size(struct view *view, int *w, int *h)
{
assert(view);
struct view_size_hints hints = view_get_size_hints(view);
int min_view_width = rc.theme->window_button_width * (
wl_list_length(&rc.title_buttons_left) + wl_list_length(&rc.title_buttons_right));
int min_width = view_get_min_width();
/*
* "If a base size is not provided, the minimum size is to be
@ -641,7 +640,7 @@ view_adjust_size(struct view *view, int *w, int *h)
* This is currently always the case for xdg-shell views.
*/
if (hints.min_width < 1) {
hints.min_width = min_view_width;
hints.min_width = min_width;
}
if (hints.min_height < 1) {
hints.min_height = LAB_MIN_VIEW_HEIGHT;
@ -2279,6 +2278,17 @@ view_reload_ssd(struct view *view)
}
}
int
view_get_min_width(void)
{
int button_count_left = wl_list_length(&rc.title_buttons_left);
int button_count_right = wl_list_length(&rc.title_buttons_right);
return (rc.theme->window_button_width * (button_count_left + button_count_right)) +
(rc.theme->window_button_spacing * MAX((button_count_right - 1), 0)) +
(rc.theme->window_button_spacing * MAX((button_count_left - 1), 0)) +
(2 * rc.theme->padding_width);
}
void
view_toggle_keybinds(struct view *view)
{