mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
theme: add window.titlebar.padding.{width,height}
...to replace padding.{width,height} to minimize breaking changes with the
visual appearance of the titlebar.
With the diverging labwc specification for the titlebar (listed below)
we have to choose between (a) not supporting the padding.{width,height}
option which exist in many extant Openbox themes to keep titlebar height
(almost) the same; or (b) making the allocated button areas much smaller
and not keeping the default hover going all the way to the edges. All in
all it just seems a lot simpler and cleaner to break this link to the
openbox spec.
Examples of previous change driving the requirement for this change:
- SVG and PNG support which often results in large icons with hover
effects.
- Theme option window.button.{height,width}
- Larger default areas for icons (26x26)
In way of an example, Numix theme sets a padding.height of 6 which would
have resulted in a titlebar 12px taller without this change.
This commit is contained in:
parent
383fb20bf4
commit
e16e78e7a4
6 changed files with 36 additions and 29 deletions
|
|
@ -50,14 +50,13 @@ labwc-config(5).
|
||||||
Line width (integer) of border drawn around window frames.
|
Line width (integer) of border drawn around window frames.
|
||||||
Default is 1.
|
Default is 1.
|
||||||
|
|
||||||
*padding.width*
|
*window.titlebar.padding.width*
|
||||||
Horizontal padding size, in pixels, between border and first
|
Horizontal titlebar padding size, in pixels, between border and first
|
||||||
button on the left/right.
|
button on the left/right.
|
||||||
Default is 0.
|
Default is 0.
|
||||||
|
|
||||||
*padding.height*
|
*window.titlebar.padding.height*
|
||||||
Vertical padding size, in pixels, used for spacing out elements
|
Vertical titlebar padding size, in pixels.
|
||||||
in the window decorations.
|
|
||||||
Default is 0.
|
Default is 0.
|
||||||
|
|
||||||
*menu.items.padding.x*
|
*menu.items.padding.x*
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,13 @@
|
||||||
|
|
||||||
# general
|
# general
|
||||||
border.width: 1
|
border.width: 1
|
||||||
padding.width: 0
|
|
||||||
padding.height: 0
|
#
|
||||||
|
# We do not support the global padding.{width,height} of openbox because
|
||||||
|
# the default labwc button geometry has deviates from that of openbox
|
||||||
|
#
|
||||||
|
window.titlebar.padding.width: 0
|
||||||
|
window.titlebar.padding.height: 0
|
||||||
|
|
||||||
# window border
|
# window border
|
||||||
window.active.border.color: #e1dedb
|
window.active.border.color: #e1dedb
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ struct theme {
|
||||||
* the space between title bar border and
|
* the space between title bar border and
|
||||||
* buttons on the left/right/top
|
* buttons on the left/right/top
|
||||||
*/
|
*/
|
||||||
int padding_width;
|
int window_titlebar_padding_width;
|
||||||
int padding_height;
|
int window_titlebar_padding_height;
|
||||||
|
|
||||||
int title_height;
|
int title_height;
|
||||||
int menu_overlap_x;
|
int menu_overlap_x;
|
||||||
|
|
@ -156,7 +156,10 @@ struct theme {
|
||||||
struct lab_data_buffer *shadow_corner_bottom_inactive;
|
struct lab_data_buffer *shadow_corner_bottom_inactive;
|
||||||
struct lab_data_buffer *shadow_edge_inactive;
|
struct lab_data_buffer *shadow_edge_inactive;
|
||||||
|
|
||||||
/* not set in rc.xml/themerc, but derived from font & padding_height */
|
/*
|
||||||
|
* Not set in rc.xml/themerc, but derived from the tallest titlebar
|
||||||
|
* object plus 2 * window_titlebar_padding_height
|
||||||
|
*/
|
||||||
int osd_window_switcher_item_height;
|
int osd_window_switcher_item_height;
|
||||||
|
|
||||||
/* magnifier */
|
/* magnifier */
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ ssd_titlebar_create(struct ssd *ssd)
|
||||||
|
|
||||||
/* Buttons */
|
/* Buttons */
|
||||||
struct title_button *b;
|
struct title_button *b;
|
||||||
int x = theme->padding_width;
|
int x = theme->window_titlebar_padding_width;
|
||||||
|
|
||||||
/* Center vertically within titlebar */
|
/* Center vertically within titlebar */
|
||||||
int y = (theme->title_height - theme->window_button_height) / 2;
|
int y = (theme->title_height - theme->window_button_height) / 2;
|
||||||
|
|
@ -87,7 +87,7 @@ ssd_titlebar_create(struct ssd *ssd)
|
||||||
x += theme->window_button_width + theme->window_button_spacing;
|
x += theme->window_button_width + theme->window_button_spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
x = width - theme->padding_width + theme->window_button_spacing;
|
x = width - theme->window_titlebar_padding_width + theme->window_button_spacing;
|
||||||
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
|
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
|
||||||
x -= theme->window_button_width + theme->window_button_spacing;
|
x -= theme->window_button_width + theme->window_button_spacing;
|
||||||
struct lab_data_buffer **buffers =
|
struct lab_data_buffer **buffers =
|
||||||
|
|
@ -211,7 +211,7 @@ static void
|
||||||
update_visible_buttons(struct ssd *ssd)
|
update_visible_buttons(struct ssd *ssd)
|
||||||
{
|
{
|
||||||
struct view *view = ssd->view;
|
struct view *view = ssd->view;
|
||||||
int width = view->current.width - (2 * view->server->theme->padding_width);
|
int width = view->current.width - (2 * view->server->theme->window_titlebar_padding_width);
|
||||||
int button_width = view->server->theme->window_button_width;
|
int button_width = view->server->theme->window_button_width;
|
||||||
int button_spacing = view->server->theme->window_button_spacing;
|
int button_spacing = view->server->theme->window_button_spacing;
|
||||||
int button_count_left = wl_list_length(&rc.title_buttons_left);
|
int button_count_left = wl_list_length(&rc.title_buttons_left);
|
||||||
|
|
@ -310,7 +310,7 @@ ssd_titlebar_update(struct ssd *ssd)
|
||||||
wlr_scene_rect_from_node(part->node),
|
wlr_scene_rect_from_node(part->node),
|
||||||
width - bg_offset * 2, theme->title_height);
|
width - bg_offset * 2, theme->title_height);
|
||||||
|
|
||||||
x = theme->padding_width;
|
x = theme->window_titlebar_padding_width;
|
||||||
wl_list_for_each(b, &rc.title_buttons_left, link) {
|
wl_list_for_each(b, &rc.title_buttons_left, link) {
|
||||||
part = ssd_get_part(&subtree->parts, b->type);
|
part = ssd_get_part(&subtree->parts, b->type);
|
||||||
wlr_scene_node_set_position(part->node, x, y);
|
wlr_scene_node_set_position(part->node, x, y);
|
||||||
|
|
@ -321,7 +321,7 @@ ssd_titlebar_update(struct ssd *ssd)
|
||||||
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_RIGHT);
|
part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_RIGHT);
|
||||||
wlr_scene_node_set_position(part->node, x, -rc.theme->border_width);
|
wlr_scene_node_set_position(part->node, x, -rc.theme->border_width);
|
||||||
|
|
||||||
x = width - theme->padding_width + theme->window_button_spacing;
|
x = width - theme->window_titlebar_padding_width + theme->window_button_spacing;
|
||||||
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
|
wl_list_for_each_reverse(b, &rc.title_buttons_right, link) {
|
||||||
part = ssd_get_part(&subtree->parts, b->type);
|
part = ssd_get_part(&subtree->parts, b->type);
|
||||||
x -= theme->window_button_width + theme->window_button_spacing;
|
x -= theme->window_button_width + theme->window_button_spacing;
|
||||||
|
|
@ -432,7 +432,7 @@ get_title_offsets(struct ssd *ssd, int *offset_left, int *offset_right)
|
||||||
struct ssd_sub_tree *subtree = &ssd->titlebar.active;
|
struct ssd_sub_tree *subtree = &ssd->titlebar.active;
|
||||||
int button_width = ssd->view->server->theme->window_button_width;
|
int button_width = ssd->view->server->theme->window_button_width;
|
||||||
int button_spacing = ssd->view->server->theme->window_button_spacing;
|
int button_spacing = ssd->view->server->theme->window_button_spacing;
|
||||||
int padding_width = ssd->view->server->theme->padding_width;
|
int padding_width = ssd->view->server->theme->window_titlebar_padding_width;
|
||||||
*offset_left = padding_width;
|
*offset_left = padding_width;
|
||||||
*offset_right = padding_width;
|
*offset_right = padding_width;
|
||||||
|
|
||||||
|
|
@ -609,7 +609,7 @@ ssd_update_window_icon(struct ssd *ssd)
|
||||||
*/
|
*/
|
||||||
int hpad = theme->window_button_width / 10;
|
int hpad = theme->window_button_width / 10;
|
||||||
int icon_size = MIN(theme->window_button_width - 2 * hpad,
|
int icon_size = MIN(theme->window_button_width - 2 * hpad,
|
||||||
theme->title_height - 2 * theme->padding_height);
|
theme->title_height - 2 * theme->window_titlebar_padding_height);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Load/render icons at the max scale of any usable output (at
|
* Load/render icons at the max scale of any usable output (at
|
||||||
|
|
|
||||||
22
src/theme.c
22
src/theme.c
|
|
@ -180,7 +180,7 @@ create_rounded_buffer(struct theme *theme, enum corner corner,
|
||||||
float white[4] = {1, 1, 1, 1};
|
float white[4] = {1, 1, 1, 1};
|
||||||
struct rounded_corner_ctx rounded_ctx = {
|
struct rounded_corner_ctx rounded_ctx = {
|
||||||
.box = &(struct wlr_box){
|
.box = &(struct wlr_box){
|
||||||
.width = theme->padding_width + width,
|
.width = theme->window_titlebar_padding_width + width,
|
||||||
.height = height,
|
.height = height,
|
||||||
},
|
},
|
||||||
.radius = rc.corner_radius,
|
.radius = rc.corner_radius,
|
||||||
|
|
@ -191,7 +191,7 @@ create_rounded_buffer(struct theme *theme, enum corner corner,
|
||||||
};
|
};
|
||||||
int mask_offset;
|
int mask_offset;
|
||||||
if (corner == LAB_CORNER_TOP_LEFT) {
|
if (corner == LAB_CORNER_TOP_LEFT) {
|
||||||
mask_offset = -theme->padding_width;
|
mask_offset = -theme->window_titlebar_padding_width;
|
||||||
} else {
|
} else {
|
||||||
mask_offset = 0;
|
mask_offset = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -573,7 +573,8 @@ static void
|
||||||
theme_builtin(struct theme *theme, struct server *server)
|
theme_builtin(struct theme *theme, struct server *server)
|
||||||
{
|
{
|
||||||
theme->border_width = 1;
|
theme->border_width = 1;
|
||||||
theme->padding_height = 0;
|
theme->window_titlebar_padding_height = 0;
|
||||||
|
theme->window_titlebar_padding_width = 0;
|
||||||
theme->title_height = INT_MIN;
|
theme->title_height = INT_MIN;
|
||||||
theme->menu_overlap_x = 0;
|
theme->menu_overlap_x = 0;
|
||||||
theme->menu_overlap_y = 0;
|
theme->menu_overlap_y = 0;
|
||||||
|
|
@ -591,7 +592,6 @@ theme_builtin(struct theme *theme, struct server *server)
|
||||||
theme->window_label_text_justify = parse_justification("Center");
|
theme->window_label_text_justify = parse_justification("Center");
|
||||||
theme->menu_title_text_justify = parse_justification("Center");
|
theme->menu_title_text_justify = parse_justification("Center");
|
||||||
|
|
||||||
theme->padding_width = 0;
|
|
||||||
theme->window_button_width = 26;
|
theme->window_button_width = 26;
|
||||||
theme->window_button_height = 26;
|
theme->window_button_height = 26;
|
||||||
theme->window_button_spacing = 0;
|
theme->window_button_spacing = 0;
|
||||||
|
|
@ -707,13 +707,13 @@ entry(struct theme *theme, const char *key, const char *value)
|
||||||
theme->border_width = get_int_if_positive(
|
theme->border_width = get_int_if_positive(
|
||||||
value, "border.width");
|
value, "border.width");
|
||||||
}
|
}
|
||||||
if (match_glob(key, "padding.width")) {
|
if (match_glob(key, "window.titlebar.padding.width")) {
|
||||||
theme->padding_width = get_int_if_positive(
|
theme->window_titlebar_padding_width = get_int_if_positive(
|
||||||
value, "padding.width");
|
value, "window.titlebar.padding.width");
|
||||||
}
|
}
|
||||||
if (match_glob(key, "padding.height")) {
|
if (match_glob(key, "window.titlebar.padding.height")) {
|
||||||
theme->padding_height = get_int_if_positive(
|
theme->window_titlebar_padding_height = get_int_if_positive(
|
||||||
value, "padding.height");
|
value, "window.titlebar.padding.height");
|
||||||
}
|
}
|
||||||
if (match_glob(key, "menu.items.padding.x")) {
|
if (match_glob(key, "menu.items.padding.x")) {
|
||||||
theme->menu_item_padding_x = get_int_if_positive(
|
theme->menu_item_padding_x = get_int_if_positive(
|
||||||
|
|
@ -1474,7 +1474,7 @@ get_titlebar_height(struct theme *theme)
|
||||||
if (h < theme->window_button_height) {
|
if (h < theme->window_button_height) {
|
||||||
h = theme->window_button_height;
|
h = theme->window_button_height;
|
||||||
}
|
}
|
||||||
h += 2 * theme->padding_height;
|
h += 2 * theme->window_titlebar_padding_height;
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2284,7 +2284,7 @@ view_get_min_width(void)
|
||||||
return (rc.theme->window_button_width * (button_count_left + button_count_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_right - 1), 0)) +
|
||||||
(rc.theme->window_button_spacing * MAX((button_count_left - 1), 0)) +
|
(rc.theme->window_button_spacing * MAX((button_count_left - 1), 0)) +
|
||||||
(2 * rc.theme->padding_width);
|
(2 * rc.theme->window_titlebar_padding_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue