From: Moises Lima Date: Mon, 2 Oct 2023 15:44:30 +0000 (-0300) Subject: Refactor title height to use 'titlebar.height' from themerc X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=47a80fc4f286f1ce2d5ad75d9b6dcef4dc8a95b1;p=proto%2Flabwc.git Refactor title height to use 'titlebar.height' from themerc --- diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index 3ccae3c8..73be8d27 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -47,6 +47,10 @@ labwc-config(5). Vertical padding size, used for spacing out elements in the window decorations. 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* Horizontal padding of menu text entries in pixels. 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. -# 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 labwc(1), labwc-config(5), labwc-actions(5) diff --git a/docs/themerc b/docs/themerc index 2062256c..87c8868e 100644 --- a/docs/themerc +++ b/docs/themerc @@ -9,6 +9,10 @@ border.width: 1 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.active.border.color: #dddad6 window.inactive.border.color: #f6f5f4 diff --git a/include/theme.h b/include/theme.h index 47ef3b9f..e211d0f0 100644 --- a/include/theme.h +++ b/include/theme.h @@ -20,6 +20,7 @@ enum lab_justification { struct theme { int border_width; int padding_height; + int title_height; int menu_overlap_x; int menu_overlap_y; @@ -92,7 +93,6 @@ struct theme { struct lab_data_buffer *corner_top_right_inactive_normal; /* not set in rc.xml/themerc, but derived from font & padding_height */ - int title_height; int osd_window_switcher_item_height; }; diff --git a/src/theme.c b/src/theme.c index 37dc8037..634519d4 100644 --- a/src/theme.c +++ b/src/theme.c @@ -213,6 +213,7 @@ theme_builtin(struct theme *theme) { theme->border_width = 1; theme->padding_height = 3; + theme->title_height = INT_MIN; theme->menu_overlap_x = 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")) { theme->padding_height = atoi(value); } + if (match_glob(key, "titlebar.height")) { + theme->title_height = atoi(value); + } if (match_glob(key, "menu.items.padding.x")) { theme->menu_item_padding_x = atoi(value); } @@ -750,8 +754,11 @@ create_corners(struct theme *theme) static void post_processing(struct theme *theme) { - theme->title_height = font_height(&rc.font_activewindow) - + 2 * theme->padding_height; + int h = font_height(&rc.font_activewindow); + if (theme->title_height < h) { + theme->title_height = h + 2 * theme->padding_height; + } + 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_active_border_width;