mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
ssd: use dynamic titlebar height based on font size and padding
This commit is contained in:
parent
3bb44fc9f2
commit
e4f1f9a975
9 changed files with 23 additions and 18 deletions
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "common/buf.h"
|
||||
#include "config/libinput.h"
|
||||
#include "theme.h"
|
||||
|
||||
struct rcxml {
|
||||
|
||||
|
|
@ -29,6 +30,8 @@ struct rcxml {
|
|||
int font_size_activewindow;
|
||||
int font_size_menuitem;
|
||||
int font_size_osd;
|
||||
/* Pointer to current theme */
|
||||
struct theme *theme;
|
||||
|
||||
/* keyboard */
|
||||
int repeat_rate;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include "buffer.h"
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
#define SSD_HEIGHT 26 /* TODO: use theme->title_height */
|
||||
#define BUTTON_COUNT 4
|
||||
#define BUTTON_WIDTH 26
|
||||
#define EXTENDED_AREA 8
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ main(int argc, char *argv[])
|
|||
|
||||
struct theme theme = { 0 };
|
||||
theme_init(&theme, rc.theme_name);
|
||||
rc.theme = &theme;
|
||||
server.theme = &theme;
|
||||
|
||||
menu_init_rootmenu(&server);
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@
|
|||
#include "theme.h"
|
||||
#include "ssd.h"
|
||||
|
||||
/* TODO: use theme->title_height instead of SSD_HEIGHT */
|
||||
struct border
|
||||
ssd_thickness(struct view *view)
|
||||
{
|
||||
struct theme *theme = view->server->theme;
|
||||
struct border border = {
|
||||
.top = SSD_HEIGHT,
|
||||
.top = theme->title_height,
|
||||
.bottom = theme->border_width,
|
||||
.left = theme->border_width,
|
||||
.right = theme->border_width,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ ssd_border_create(struct view *view)
|
|||
0, height, color);
|
||||
add_scene_rect(&subtree->parts, LAB_SSD_PART_TOP, parent,
|
||||
full_width - 2 * BUTTON_WIDTH, theme->border_width,
|
||||
BUTTON_WIDTH, -SSD_HEIGHT, color);
|
||||
BUTTON_WIDTH, -theme->title_height, color);
|
||||
} FOR_EACH_END
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ ssd_border_update(struct view *view)
|
|||
full_width - 2 * BUTTON_WIDTH,
|
||||
theme->border_width);
|
||||
wlr_scene_node_set_position(part->node,
|
||||
BUTTON_WIDTH, -SSD_HEIGHT);
|
||||
BUTTON_WIDTH, -theme->title_height);
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ ssd_extents_create(struct view *view)
|
|||
struct wl_list *part_list = &view->ssd.extents.parts;
|
||||
int width = view->w;
|
||||
int height = view->h;
|
||||
int full_height = height + theme->border_width + SSD_HEIGHT;
|
||||
int full_height = height + theme->border_width + theme->title_height;
|
||||
int full_width = width + 2 * theme->border_width;
|
||||
int extended_area = EXTENDED_AREA;
|
||||
int corner_size = extended_area + theme->border_width + BUTTON_WIDTH / 2;
|
||||
|
|
@ -26,8 +26,8 @@ ssd_extents_create(struct view *view)
|
|||
wlr_scene_node_set_enabled(parent, false);
|
||||
}
|
||||
wl_list_init(&view->ssd.extents.parts);
|
||||
wlr_scene_node_set_position(parent,
|
||||
-(theme->border_width + extended_area), -(SSD_HEIGHT + extended_area));
|
||||
wlr_scene_node_set_position(parent, -(theme->border_width + extended_area),
|
||||
-(theme->title_height + extended_area));
|
||||
|
||||
/* Top */
|
||||
add_scene_rect(part_list, LAB_SSD_PART_CORNER_TOP_LEFT, parent,
|
||||
|
|
@ -75,7 +75,7 @@ ssd_extents_update(struct view *view)
|
|||
|
||||
int width = view->w;
|
||||
int height = view->h;
|
||||
int full_height = height + theme->border_width + SSD_HEIGHT;
|
||||
int full_height = height + theme->border_width + theme->title_height;
|
||||
int full_width = width + 2 * theme->border_width;
|
||||
int extended_area = EXTENDED_AREA;
|
||||
int corner_size = extended_area + theme->border_width + BUTTON_WIDTH / 2;
|
||||
|
|
|
|||
|
|
@ -54,12 +54,12 @@ finish_scene_button(struct wl_list *part_list, enum ssd_part_type type,
|
|||
/* Icon */
|
||||
add_scene_buffer(part_list, type, parent, icon_buffer,
|
||||
(BUTTON_WIDTH - icon_buffer->width) / 2,
|
||||
(SSD_HEIGHT - icon_buffer->height) / 2);
|
||||
(rc.theme->title_height - icon_buffer->height) / 2);
|
||||
|
||||
/* Hover overlay */
|
||||
struct ssd_part *hover_part;
|
||||
hover_part = add_scene_rect(part_list, type, parent,
|
||||
BUTTON_WIDTH, SSD_HEIGHT, 0, 0, hover_bg);
|
||||
BUTTON_WIDTH, rc.theme->title_height, 0, 0, hover_bg);
|
||||
wlr_scene_node_set_enabled(hover_part->node, false);
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ add_scene_button(struct wl_list *part_list, enum ssd_part_type type,
|
|||
struct ssd_part *part;
|
||||
/* Background */
|
||||
part = add_scene_rect(part_list, type, parent,
|
||||
BUTTON_WIDTH, SSD_HEIGHT, x, 0, bg_color);
|
||||
BUTTON_WIDTH, rc.theme->title_height, x, 0, bg_color);
|
||||
finish_scene_button(part_list, type, part->node, icon_buffer);
|
||||
return part;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ ssd_titlebar_create(struct view *view)
|
|||
FOR_EACH_STATE(view, subtree) {
|
||||
subtree->tree = wlr_scene_tree_create(&view->ssd.tree->node);
|
||||
parent = &subtree->tree->node;
|
||||
wlr_scene_node_set_position(parent, -theme->border_width, -SSD_HEIGHT);
|
||||
wlr_scene_node_set_position(parent,
|
||||
-theme->border_width, -theme->title_height);
|
||||
if (subtree == &view->ssd.titlebar.active) {
|
||||
color = theme->window_active_title_bg_color;
|
||||
corner_top_left = &theme->corner_top_left_active_normal->base;
|
||||
|
|
@ -44,7 +45,7 @@ ssd_titlebar_create(struct view *view)
|
|||
|
||||
/* Title */
|
||||
add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent,
|
||||
full_width - BUTTON_WIDTH * BUTTON_COUNT, SSD_HEIGHT,
|
||||
full_width - BUTTON_WIDTH * BUTTON_COUNT, theme->title_height,
|
||||
BUTTON_WIDTH, 0, color);
|
||||
/* Buttons */
|
||||
add_scene_button_corner(&subtree->parts, LAB_SSD_BUTTON_WINDOW_MENU,
|
||||
|
|
@ -76,7 +77,8 @@ ssd_titlebar_update(struct view *view)
|
|||
if (width == view->ssd.state.width) {
|
||||
return;
|
||||
}
|
||||
int full_width = width + 2 * view->server->theme->border_width;
|
||||
struct theme *theme = view->server->theme;
|
||||
int full_width = width + 2 * theme->border_width;
|
||||
|
||||
struct ssd_part *part;
|
||||
struct ssd_sub_tree *subtree;
|
||||
|
|
@ -85,7 +87,8 @@ ssd_titlebar_update(struct view *view)
|
|||
switch (part->type) {
|
||||
case LAB_SSD_PART_TITLEBAR:
|
||||
wlr_scene_rect_set_size(lab_wlr_scene_get_rect(part->node),
|
||||
full_width - BUTTON_WIDTH * BUTTON_COUNT, SSD_HEIGHT);
|
||||
full_width - BUTTON_WIDTH * BUTTON_COUNT,
|
||||
theme->title_height);
|
||||
continue;
|
||||
case LAB_SSD_BUTTON_ICONIFY:
|
||||
if (is_direct_child(part->node, subtree)) {
|
||||
|
|
@ -159,7 +162,7 @@ ssd_update_title_positions(struct view *view)
|
|||
}
|
||||
|
||||
x = 0;
|
||||
y = (SSD_HEIGHT - part->buffer->base.height) / 2;
|
||||
y = (theme->title_height - part->buffer->base.height) / 2;
|
||||
rect = lab_wlr_scene_get_rect(part->node->parent);
|
||||
if (rect->width <= 0) {
|
||||
wlr_scene_node_set_position(part->node, x, y);
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ create_corners(struct theme *theme)
|
|||
.x = 0,
|
||||
.y = 0,
|
||||
.width = BUTTON_WIDTH,
|
||||
.height = SSD_HEIGHT,
|
||||
.height = theme->title_height,
|
||||
};
|
||||
|
||||
struct rounded_corner_ctx ctx = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue