]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: rename title_height to titlebar_height
authortokyo4j <hrak1529@gmail.com>
Tue, 12 Nov 2024 03:37:26 +0000 (12:37 +0900)
committerJohan Malm <johanmalm@users.noreply.github.com>
Tue, 12 Nov 2024 17:25:39 +0000 (17:25 +0000)
Also removed the redundant initialization of title_height in
theme_builtin().

include/theme.h
src/ssd/ssd-titlebar.c
src/ssd/ssd.c
src/theme.c
src/view.c

index d1657ea93bb19c39b1b685fd09976d43c04ad7fd..779b9499db7483b33c6a53a36cafc4ef8c575766 100644 (file)
@@ -44,7 +44,7 @@ struct theme {
        int window_titlebar_padding_width;
        int window_titlebar_padding_height;
 
-       int title_height;
+       int titlebar_height;
 
        float window_toggled_keybinds_color[4];
        enum lab_justification window_label_text_justify;
index 3c1c92b9acea9b59a26572b6bdebc7aa2b4bff71..373dd1c45c53959d7a09c64669d9ebf5442929f0 100644 (file)
@@ -52,12 +52,12 @@ ssd_titlebar_create(struct ssd *ssd)
                corner_top_left = &theme->window[active].corner_top_left_normal->base;
                corner_top_right = &theme->window[active].corner_top_right_normal->base;
                wlr_scene_node_set_enabled(&parent->node, active);
-               wlr_scene_node_set_position(&parent->node, 0, -theme->title_height);
+               wlr_scene_node_set_position(&parent->node, 0, -theme->titlebar_height);
                wl_list_init(&subtree->parts);
 
                /* Background */
                add_scene_rect(&subtree->parts, LAB_SSD_PART_TITLEBAR, parent,
-                       width - corner_width * 2, theme->title_height,
+                       width - corner_width * 2, theme->titlebar_height,
                        corner_width, 0, color);
                add_scene_buffer(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_LEFT, parent,
                        corner_top_left, -rc.theme->border_width, -rc.theme->border_width);
@@ -70,7 +70,7 @@ ssd_titlebar_create(struct ssd *ssd)
                int x = theme->window_titlebar_padding_width;
 
                /* Center vertically within titlebar */
-               int y = (theme->title_height - theme->window_button_height) / 2;
+               int y = (theme->titlebar_height - theme->window_button_height) / 2;
 
                wl_list_for_each(b, &rc.title_buttons_left, link) {
                        struct lab_data_buffer **buffers =
@@ -152,8 +152,8 @@ set_squared_corners(struct ssd *ssd, bool enable)
        FOR_EACH_STATE(ssd, subtree) {
                part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
                wlr_scene_node_set_position(part->node, x, 0);
-               wlr_scene_rect_set_size(
-                       wlr_scene_rect_from_node(part->node), width - 2 * x, theme->title_height);
+               wlr_scene_rect_set_size(wlr_scene_rect_from_node(part->node),
+                       width - 2 * x, theme->titlebar_height);
 
                part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR_CORNER_LEFT);
                wlr_scene_node_set_enabled(part->node, !enable);
@@ -291,7 +291,7 @@ ssd_titlebar_update(struct ssd *ssd)
        update_visible_buttons(ssd);
 
        /* Center buttons vertically within titlebar */
-       int y = (theme->title_height - theme->window_button_height) / 2;
+       int y = (theme->titlebar_height - theme->window_button_height) / 2;
        int x;
        struct ssd_part *part;
        struct ssd_sub_tree *subtree;
@@ -301,7 +301,7 @@ ssd_titlebar_update(struct ssd *ssd)
                part = ssd_get_part(&subtree->parts, LAB_SSD_PART_TITLEBAR);
                wlr_scene_rect_set_size(
                        wlr_scene_rect_from_node(part->node),
-                       width - bg_offset * 2, theme->title_height);
+                       width - bg_offset * 2, theme->titlebar_height);
 
                x = theme->window_titlebar_padding_width;
                wl_list_for_each(b, &rc.title_buttons_left, link) {
@@ -386,7 +386,7 @@ ssd_update_title_positions(struct ssd *ssd, int offset_left, int offset_right)
                buffer_width = part->buffer ? part->buffer->width : 0;
                buffer_height = part->buffer ? part->buffer->height : 0;
                x = offset_left;
-               y = (theme->title_height - buffer_height) / 2;
+               y = (theme->titlebar_height - buffer_height) / 2;
 
                if (title_bg_width <= 0) {
                        wlr_scene_node_set_enabled(part->node, false);
index 149bf5863108e774f881917df12b60024976b6e7..49f088b7f6464fe20246c1b8edb1a27a71d66c26 100644 (file)
@@ -39,20 +39,20 @@ ssd_thickness(struct view *view)
        if (view->maximized == VIEW_AXIS_BOTH) {
                struct border thickness = { 0 };
                if (!view->ssd_titlebar_hidden) {
-                       thickness.top += theme->title_height;
+                       thickness.top += theme->titlebar_height;
                }
                return thickness;
        }
 
        struct border thickness = {
-               .top = theme->title_height + theme->border_width,
+               .top = theme->titlebar_height + theme->border_width,
                .bottom = theme->border_width,
                .left = theme->border_width,
                .right = theme->border_width,
        };
 
        if (view->ssd_titlebar_hidden) {
-               thickness.top -= theme->title_height;
+               thickness.top -= theme->titlebar_height;
        }
        return thickness;
 }
@@ -176,7 +176,7 @@ ssd_create(struct view *view, bool active)
        ssd->view = view;
        ssd->tree = wlr_scene_tree_create(view->scene_tree);
        wlr_scene_node_lower_to_bottom(&ssd->tree->node);
-       ssd->titlebar.height = view->server->theme->title_height;
+       ssd->titlebar.height = view->server->theme->titlebar_height;
        ssd_shadow_create(ssd);
        ssd_extents_create(ssd);
        /*
@@ -271,7 +271,7 @@ ssd_set_titlebar(struct ssd *ssd, bool enabled)
                return;
        }
        wlr_scene_node_set_enabled(&ssd->titlebar.tree->node, enabled);
-       ssd->titlebar.height = enabled ? ssd->view->server->theme->title_height : 0;
+       ssd->titlebar.height = enabled ? ssd->view->server->theme->titlebar_height : 0;
        ssd_border_update(ssd);
        ssd_extents_update(ssd);
        ssd_shadow_update(ssd);
index 0e503ce160fc0389c6cb2e48cc7b5268b045d0b9..56d10ebd749dbbf0566c87df61a78d8d8e8ec88d 100644 (file)
@@ -179,7 +179,7 @@ create_rounded_buffer(struct theme *theme, enum corner corner,
         * border. See the picture in #2189 for reference.
         */
        int margin_x = theme->window_titlebar_padding_width;
-       int margin_y = (theme->title_height - theme->window_button_height) / 2;
+       int margin_y = (theme->titlebar_height - theme->window_button_height) / 2;
        float white[4] = {1, 1, 1, 1};
        struct rounded_corner_ctx rounded_ctx = {
                .box = &(struct wlr_box){
@@ -562,7 +562,6 @@ theme_builtin(struct theme *theme, struct server *server)
        theme->border_width = 1;
        theme->window_titlebar_padding_height = 0;
        theme->window_titlebar_padding_width = 0;
-       theme->title_height = INT_MIN;
 
        parse_hexstr("#e1dedb", theme->window[THEME_ACTIVE].border_color);
        parse_hexstr("#f6f5f4", theme->window[THEME_INACTIVE].border_color);
@@ -1243,7 +1242,7 @@ create_corners(struct theme *theme)
                .x = 0,
                .y = 0,
                .width = corner_width + theme->border_width,
-               .height = theme->title_height + theme->border_width,
+               .height = theme->titlebar_height + theme->border_width,
        };
 
        for (int active = THEME_INACTIVE; active <= THEME_ACTIVE; active++) {
@@ -1409,7 +1408,7 @@ create_shadow(struct theme *theme, int active)
                total_size, theme->window[active].shadow_color);
        shadow_corner_gradient(theme->window[active].shadow_corner_top,
                visible_size, total_size,
-               theme->title_height, theme->window[active].shadow_color);
+               theme->titlebar_height, theme->window[active].shadow_color);
        shadow_corner_gradient(theme->window[active].shadow_corner_bottom,
                visible_size, total_size, 0,
                theme->window[active].shadow_color);
@@ -1445,7 +1444,7 @@ get_titlebar_height(struct theme *theme)
 static void
 post_processing(struct theme *theme)
 {
-       theme->title_height = get_titlebar_height(theme);
+       theme->titlebar_height = get_titlebar_height(theme);
 
        theme->menu_item_height = font_height(&rc.font_menuitem)
                + 2 * theme->menu_items_padding_y;
@@ -1457,8 +1456,8 @@ post_processing(struct theme *theme)
                + 2 * theme->osd_window_switcher_item_padding_y
                + 2 * theme->osd_window_switcher_item_active_border_width;
 
-       if (rc.corner_radius >= theme->title_height) {
-               rc.corner_radius = theme->title_height - 1;
+       if (rc.corner_radius >= theme->titlebar_height) {
+               rc.corner_radius = theme->titlebar_height - 1;
        }
 
        int min_button_hover_radius =
index 51b335a70e1be21b734c6f756ce5c318904f4be1..c8ff02752a36617d04c50a29e51f502ddffcbded 100644 (file)
@@ -980,7 +980,7 @@ view_cascade(struct view *view)
        int offset_x = rc.placement_cascade_offset_x;
        int offset_y = rc.placement_cascade_offset_y;
        struct theme *theme = view->server->theme;
-       int default_offset = theme->title_height + theme->border_width + 5;
+       int default_offset = theme->titlebar_height + theme->border_width + 5;
        if (offset_x <= 0) {
                offset_x = default_offset;
        }