]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Refactor title height to use 'titlebar.height' from themerc
authorMoises Lima <mozlima@gmail.com>
Mon, 2 Oct 2023 15:44:30 +0000 (12:44 -0300)
committerJohan Malm <johanmalm@users.noreply.github.com>
Fri, 6 Oct 2023 21:19:16 +0000 (22:19 +0100)
docs/labwc-theme.5.scd
docs/themerc
include/theme.h
src/theme.c

index 3ccae3c8625c2aa9d36740fff2c51b8520929b74..73be8d27cac3b1219ad58a6a927dbef3ddb89fbb 100644 (file)
@@ -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)
index 2062256c1456ed608123b72ec2e662d406bc263b..87c8868ecb2f0760611b5ee807f75393c492fbc9 100644 (file)
@@ -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
index 47ef3b9f33b08b892aac5b934b27d04af3efd5ed..e211d0f047f87ee686f91de918cd88ecf9973ef3 100644 (file)
@@ -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;
 };
 
index 37dc803751ed2345857393be3c9508db4f177e81..634519d4b7163b305829e48091898dd3d84a5f3d 100644 (file)
@@ -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;