[mutter/wip/gtk-theming: 4/19] theme: Add titlebar_spacing



commit 385be22ec421b82a15825252e8fe40178cfdddcc
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Oct 1 05:44:19 2014 +0200

    theme: Add titlebar_spacing
    
    Rather than defining the space to the left and right of buttons, add a
    simple spacing property that defines the space between buttons, which is
    what GTK+ does for client-side decorations (e.g. GtkButtons in a GtkBox).
    Unfortunately the value is hardcoded in GTK+; if it is exposed in the
    theme in the future, we should pick it up from there, but for now we
    just use the same value as GTK+.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=741917

 src/ui/theme-private.h |    3 +++
 src/ui/theme.c         |   25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 178772f..bd482ba 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -181,6 +181,9 @@ struct _MetaFrameLayout
   /** Space around buttons */
   GtkBorder button_border;
 
+  /** Space between titlebar elements */
+  guint titlebar_spacing;
+
   /** scale factor for title text */
   double title_scale;
 
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 1722c10..c9ba282 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -137,6 +137,10 @@ meta_frame_layout_new  (void)
   layout->button_width = -1;
   layout->button_height = -1;
 
+  /* Spacing as hardcoded in GTK+:
+   * https://git.gnome.org/browse/gtk+/tree/gtk/gtkheaderbar.c?h=gtk-3-14#n53
+   */
+  layout->titlebar_spacing = 6;
   layout->has_title = TRUE;
   layout->title_scale = 1.0;
 
@@ -682,13 +686,11 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
 
       space_used_by_buttons += button_width * n_left;
       space_used_by_buttons += (button_width * 0.75) * n_left_spacers;
-      space_used_by_buttons += layout->button_border.left * n_left;
-      space_used_by_buttons += layout->button_border.right * n_left;
+      space_used_by_buttons += layout->titlebar_spacing * MAX (n_left - 1, 0);
 
       space_used_by_buttons += button_width * n_right;
       space_used_by_buttons += (button_width * 0.75) * n_right_spacers;
-      space_used_by_buttons += layout->button_border.left * n_right;
-      space_used_by_buttons += layout->button_border.right * n_right;
+      space_used_by_buttons += layout->titlebar_spacing * MAX (n_right - 1, 0);
 
       if (space_used_by_buttons <= space_available)
         break; /* Everything fits, bail out */
@@ -785,7 +787,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
         break;
 
       rect = right_func_rects[i];
-      rect->visible.x = x - layout->button_border.right - button_width;
+      rect->visible.x = x - button_width;
       if (right_buttons_has_spacer[i])
         rect->visible.x -= (button_width * 0.75);
 
@@ -803,7 +805,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
           rect->clickable.height = button_height + button_y;
 
           if (i == n_right - 1)
-            rect->clickable.width += layout->right_titlebar_edge + layout->right_width + 
layout->button_border.right;
+            rect->clickable.width += layout->right_titlebar_edge + layout->right_width;
 
         }
       else
@@ -811,7 +813,10 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
 
       *(right_bg_rects[i]) = rect->visible;
 
-      x = rect->visible.x - layout->button_border.left;
+      x = rect->visible.x;
+
+      if (i > 0)
+        x -= layout->titlebar_spacing;
 
       --i;
     }
@@ -829,7 +834,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
 
       rect = left_func_rects[i];
 
-      rect->visible.x = x + layout->button_border.left;
+      rect->visible.x = x;
       rect->visible.y = button_y;
       rect->visible.width = button_width;
       rect->visible.height = button_height;
@@ -853,7 +858,9 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout  *layout,
       else
         g_memmove (&(rect->clickable), &(rect->visible), sizeof(rect->clickable));
 
-      x = rect->visible.x + rect->visible.width + layout->button_border.right;
+      x = rect->visible.x + rect->visible.width;
+      if (i < n_left - 1)
+        x += layout->titlebar_spacing;
       if (left_buttons_has_spacer[i])
         x += (button_width * 0.75);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]