Refactor title height to use 'titlebar.height' from themerc

This commit is contained in:
Moises Lima 2023-10-02 12:44:30 -03:00 committed by Johan Malm
parent 0acdf041b8
commit 47a80fc4f2
4 changed files with 18 additions and 8 deletions

View file

@ -47,6 +47,10 @@ labwc-config(5).
Vertical padding size, used for spacing out elements in the window decorations. Vertical padding size, used for spacing out elements in the window decorations.
Default is 3. Default is 3.
*titlebar.height*
Window title bar height.
Default equals the vertical font extents of the title plus 2x padding.height.
*menu.items.padding.x* *menu.items.padding.x*
Horizontal padding of menu text entries in pixels. Horizontal padding of menu text entries in pixels.
Default is 7. Default is 7.
@ -202,11 +206,6 @@ with the respective titlebar colors. For example: "close-active.png"
The handle is the window edge decoration at the bottom of the window. The handle is the window edge decoration at the bottom of the window.
# DERIVED DIMENSIONS
The window title bar height is equal to the vertical font extents of the title.
Padding will be added to this later.
# SEE ALSO # SEE ALSO
labwc(1), labwc-config(5), labwc-actions(5) labwc(1), labwc-config(5), labwc-actions(5)

View file

@ -9,6 +9,10 @@
border.width: 1 border.width: 1
padding.height: 3 padding.height: 3
# The following options has no default, but fallbacks back to
# font-height + 2x padding.height if not set.
# titlebar.height:
# window border # window border
window.active.border.color: #dddad6 window.active.border.color: #dddad6
window.inactive.border.color: #f6f5f4 window.inactive.border.color: #f6f5f4

View file

@ -20,6 +20,7 @@ enum lab_justification {
struct theme { struct theme {
int border_width; int border_width;
int padding_height; int padding_height;
int title_height;
int menu_overlap_x; int menu_overlap_x;
int menu_overlap_y; int menu_overlap_y;
@ -92,7 +93,6 @@ struct theme {
struct lab_data_buffer *corner_top_right_inactive_normal; struct lab_data_buffer *corner_top_right_inactive_normal;
/* not set in rc.xml/themerc, but derived from font & padding_height */ /* not set in rc.xml/themerc, but derived from font & padding_height */
int title_height;
int osd_window_switcher_item_height; int osd_window_switcher_item_height;
}; };

View file

@ -213,6 +213,7 @@ theme_builtin(struct theme *theme)
{ {
theme->border_width = 1; theme->border_width = 1;
theme->padding_height = 3; theme->padding_height = 3;
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;
@ -291,6 +292,9 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "padding.height")) { if (match_glob(key, "padding.height")) {
theme->padding_height = atoi(value); theme->padding_height = atoi(value);
} }
if (match_glob(key, "titlebar.height")) {
theme->title_height = atoi(value);
}
if (match_glob(key, "menu.items.padding.x")) { if (match_glob(key, "menu.items.padding.x")) {
theme->menu_item_padding_x = atoi(value); theme->menu_item_padding_x = atoi(value);
} }
@ -750,8 +754,11 @@ create_corners(struct theme *theme)
static void static void
post_processing(struct theme *theme) post_processing(struct theme *theme)
{ {
theme->title_height = font_height(&rc.font_activewindow) int h = font_height(&rc.font_activewindow);
+ 2 * theme->padding_height; if (theme->title_height < h) {
theme->title_height = h + 2 * theme->padding_height;
}
theme->osd_window_switcher_item_height = font_height(&rc.font_osd) theme->osd_window_switcher_item_height = font_height(&rc.font_osd)
+ 2 * theme->osd_window_switcher_item_padding_y + 2 * theme->osd_window_switcher_item_padding_y
+ 2 * theme->osd_window_switcher_item_active_border_width; + 2 * theme->osd_window_switcher_item_active_border_width;