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
This commit is contained in:
Florian Müllner 2014-10-01 05:44:19 +02:00 committed by Jasper St. Pierre
parent 75105e254f
commit db04ac9eb7
2 changed files with 19 additions and 9 deletions

View File

@ -176,6 +176,9 @@ struct _MetaFrameLayout
/** Space around buttons */
GtkBorder button_border;
/** Space between titlebar elements */
guint titlebar_spacing;
/** scale factor for title text */
double title_scale;

View File

@ -136,6 +136,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;
@ -681,13 +685,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 */
@ -784,7 +786,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);
@ -802,7 +804,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
@ -810,7 +812,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;
}
@ -828,7 +833,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;
@ -852,7 +857,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);