[mutter/wip/fmuellner/theme-updates: 1/3] theme: Consider minimum sizes



commit 0d5f17e994832074ea4cb90e4ff45468f9c1039c
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jan 14 15:25:49 2016 +0100

    theme: Consider minimum sizes
    
    GTK+ improved its CSS support, and the default theme started to make
    use of it, so we must update our theming code accordingly. Start by
    supporting min-width/min-height where it makes sense.

 src/ui/theme-private.h |    5 +++++
 src/ui/theme.c         |   28 ++++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 61d151d..ea3c532 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -60,6 +60,11 @@ struct _MetaFrameLayout
   /** Border/padding of titlebar buttons */
   GtkBorder button_border;
 
+  /** Min size of titlebar region */
+  GtkRequisition titlebar_min_size;
+  /** Min size of titlebar buttons */
+  GtkRequisition button_min_size;
+
   /** Size of images in buttons */
   guint icon_size;
 
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 1f33c3e..712a841 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -80,9 +80,10 @@ meta_frame_layout_get_borders (const MetaFrameLayout *layout,
   if (!layout->has_title)
     text_height = 0;
 
-  buttons_height = layout->icon_size +
+  buttons_height = MAX (layout->icon_size, layout->button_min_size.height) +
     layout->button_border.top + layout->button_border.bottom;
-  content_height = MAX (buttons_height, text_height) +
+  content_height = MAX (buttons_height, text_height);
+  content_height = MAX (content_height, layout->titlebar_min_size.height) +
                    layout->titlebar_border.top + layout->titlebar_border.bottom;
 
   borders->visible.top    = layout->frame_border.top + content_height;
@@ -235,6 +236,16 @@ get_padding_and_border (GtkStyleContext *style,
 }
 
 static void
+get_min_size (GtkStyleContext *style,
+              GtkRequisition  *requisition)
+{
+  gtk_style_context_get (style, gtk_style_context_get_state (style),
+                         "min-width", &requisition->width,
+                         "min-height", &requisition->height,
+                         NULL);
+}
+
+static void
 scale_border (GtkBorder *border,
               double     factor)
 {
@@ -251,6 +262,7 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
 {
   GtkStyleContext *style;
   GtkBorder border;
+  GtkRequisition requisition;
   int border_radius, max_radius;
 
   meta_style_info_set_flags (style_info, flags);
@@ -281,14 +293,17 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
   max_radius = MIN (layout->frame_border.bottom, layout->frame_border.right);
   layout->bottom_right_corner_rounded_radius = MAX (border_radius, max_radius);
 
+  get_min_size (style, &layout->titlebar_min_size);
   get_padding_and_border (style, &layout->titlebar_border);
   scale_border (&layout->titlebar_border, layout->title_scale);
 
   style = style_info->styles[META_STYLE_ELEMENT_BUTTON];
+  get_min_size (style, &layout->button_min_size);
   get_padding_and_border (style, &layout->button_border);
   scale_border (&layout->button_border, layout->title_scale);
 
   style = style_info->styles[META_STYLE_ELEMENT_IMAGE];
+  get_min_size (style, &requisition);
   get_padding_and_border (style, &border);
   scale_border (&border, layout->title_scale);
 
@@ -296,6 +311,11 @@ meta_frame_layout_sync_with_style (MetaFrameLayout *layout,
   layout->button_border.right += border.right;
   layout->button_border.top += border.top;
   layout->button_border.bottom += border.bottom;
+
+  layout->button_min_size.width = MAX(layout->button_min_size.width,
+                                      requisition.width);
+  layout->button_min_size.height = MAX(layout->button_min_size.height,
+                                       requisition.height);
 }
 
 static void
@@ -359,9 +379,9 @@ meta_frame_layout_calc_geometry (MetaFrameLayout        *layout,
                   (fgeom->content_border.right + borders.invisible.right);
   content_height = borders.visible.top - fgeom->content_border.top - fgeom->content_border.bottom;
 
-  button_width = layout->icon_size +
+  button_width = MAX (layout->icon_size, layout->button_min_size.width) +
                  layout->button_border.left + layout->button_border.right;
-  button_height = layout->icon_size +
+  button_height = MAX (layout->icon_size, layout->button_min_size.height) +
                   layout->button_border.top + layout->button_border.bottom;
   button_width *= scale;
   button_height *= scale;


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