[gtk+/wip/matthiasc/gadget] frame: Convert to gadgets



commit 4e9dc14973e243b848995d35e1132b6753aed5d4
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Dec 9 23:00:35 2015 -0500

    frame: Convert to gadgets
    
    As part of this conversion, remove the hardcoded padding around
    the label.
    
    Unfortunately, we cannot use the main gadget for drawing the frame
    decoration, since we want to draw a custom border instead of the
    stock css border that gadgets insist on drawing for us. Therefore,
    add an extra css node with name decoration and use it just for
    rendering the frame.

 gtk/gtkframe.c                           |  419 ++++++++++++++++--------------
 gtk/theme/Adwaita/_common.scss           |    2 +-
 gtk/theme/Adwaita/gtk-contained-dark.css |    6 +-
 gtk/theme/Adwaita/gtk-contained.css      |    6 +-
 4 files changed, 225 insertions(+), 208 deletions(-)
---
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 8909bea..55085ad 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -31,6 +31,12 @@
 #include "gtkintl.h"
 #include "gtkbuildable.h"
 #include "gtkwidgetpath.h"
+#include "gtkcssnodeprivate.h"
+#include "gtkcsscustomgadgetprivate.h"
+#include "gtkwidgetprivate.h"
+#include "gtkcontainerprivate.h"
+#include "gtkstylecontextprivate.h"
+#include "gtkcssstylepropertyprivate.h"
 
 #include "a11y/gtkframeaccessible.h"
 
@@ -79,6 +85,9 @@ struct _GtkFramePrivate
   /* Properties */
   GtkWidget *label_widget;
 
+  GtkCssGadget *gadget;
+  GtkCssNode *decoration_node;
+
   gint16 shadow_type;
   gfloat label_xalign;
   gfloat label_yalign;
@@ -145,6 +154,29 @@ static void gtk_frame_get_preferred_width_for_height(GtkWidget           *layout
                                                     gint                 width,
                                                     gint                *minimum_height,
                                                     gint                *natural_height);
+static void gtk_frame_state_flags_changed (GtkWidget     *widget,
+                                           GtkStateFlags  previous_state);
+
+static void     gtk_frame_measure        (GtkCssGadget        *gadget,
+                                          GtkOrientation       orientation,
+                                          gint                 for_size,
+                                          gint                *minimum_size,
+                                          gint                *natural_size,
+                                          gint                *minimum_baseline,
+                                          gint                *natural_baseline,
+                                          gpointer             data);
+static void     gtk_frame_allocate       (GtkCssGadget        *gadget,
+                                          const GtkAllocation *allocation,
+                                          int                  baseline,
+                                          GtkAllocation       *out_clip,
+                                          gpointer             data);
+static gboolean gtk_frame_render         (GtkCssGadget        *gadget,
+                                          cairo_t             *cr,
+                                          int                  x,
+                                          int                  y,
+                                          int                  width,
+                                          int                  height,
+                                          gpointer             data);
 
 
 G_DEFINE_TYPE_WITH_CODE (GtkFrame, gtk_frame, GTK_TYPE_BIN,
@@ -212,6 +244,7 @@ gtk_frame_class_init (GtkFrameClass *class)
   widget_class->get_preferred_height           = gtk_frame_get_preferred_height;
   widget_class->get_preferred_height_for_width = gtk_frame_get_preferred_height_for_width;
   widget_class->get_preferred_width_for_height = gtk_frame_get_preferred_width_for_height;
+  widget_class->state_flags_changed            = gtk_frame_state_flags_changed;
 
   container_class->remove = gtk_frame_remove;
   container_class->forall = gtk_frame_forall;
@@ -243,9 +276,33 @@ gtk_frame_buildable_add_child (GtkBuildable *buildable,
 }
 
 static void
+node_style_changed_cb (GtkCssNode  *node,
+                       GtkCssStyle *old_style,
+                       GtkCssStyle *new_style,
+                       GtkWidget   *widget)
+{
+  GtkBitmask *changes;
+  static GtkBitmask *affects_size = NULL;
+
+  if (G_UNLIKELY (affects_size == NULL))
+    affects_size = _gtk_css_style_property_get_mask_affecting (GTK_CSS_AFFECTS_SIZE | GTK_CSS_AFFECTS_CLIP);
+
+  changes = _gtk_bitmask_new ();
+  changes = gtk_css_style_add_difference (changes, old_style, new_style);
+
+  if (_gtk_bitmask_intersects (changes, affects_size))
+    gtk_widget_queue_resize (widget);
+  else
+    gtk_widget_queue_draw (widget);
+
+  _gtk_bitmask_free (changes);
+}
+
+static void
 gtk_frame_init (GtkFrame *frame)
 {
   GtkFramePrivate *priv;
+  GtkCssNode *widget_node;
 
   frame->priv = gtk_frame_get_instance_private (frame); 
   priv = frame->priv;
@@ -254,6 +311,21 @@ gtk_frame_init (GtkFrame *frame)
   priv->shadow_type = GTK_SHADOW_ETCHED_IN;
   priv->label_xalign = 0.0;
   priv->label_yalign = 0.5;
+
+  widget_node = gtk_widget_get_css_node (GTK_WIDGET (frame));
+  priv->gadget = gtk_css_custom_gadget_new_for_node (widget_node,
+                                                     GTK_WIDGET (frame),
+                                                     gtk_frame_measure,
+                                                     gtk_frame_allocate,
+                                                     gtk_frame_render,
+                                                     NULL,
+                                                     NULL);
+  priv->decoration_node = gtk_css_node_new ();
+  gtk_css_node_set_name (priv->decoration_node, I_("decoration"));
+  gtk_css_node_set_parent (priv->decoration_node, widget_node);
+  gtk_css_node_set_state (priv->decoration_node, gtk_css_node_get_state (widget_node));
+  g_signal_connect_object (priv->decoration_node, "style-changed", G_CALLBACK (node_style_changed_cb), 
frame, 0);
+  g_object_unref (priv->decoration_node);
 }
 
 static void 
@@ -273,7 +345,7 @@ gtk_frame_set_property (GObject         *object,
     case PROP_LABEL_XALIGN:
       gtk_frame_set_label_align (frame, g_value_get_float (value), 
                                 priv->label_yalign);
-      break;
+     break;
     case PROP_LABEL_YALIGN:
       gtk_frame_set_label_align (frame, priv->label_xalign,
                                 g_value_get_float (value));
@@ -579,8 +651,6 @@ gtk_frame_set_shadow_type (GtkFrame      *frame,
                           GtkShadowType  type)
 {
   GtkFramePrivate *priv;
-  GtkWidget *widget;
-  GtkStyleContext *context;
 
   g_return_if_fail (GTK_IS_FRAME (frame));
 
@@ -588,19 +658,13 @@ gtk_frame_set_shadow_type (GtkFrame      *frame,
 
   if ((GtkShadowType) priv->shadow_type != type)
     {
-      widget = GTK_WIDGET (frame);
       priv->shadow_type = type;
 
-      context = gtk_widget_get_style_context (GTK_WIDGET (frame));
       if (type == GTK_SHADOW_NONE)
-        gtk_style_context_add_class (context, GTK_STYLE_CLASS_FLAT);
+        gtk_css_node_add_class (priv->decoration_node, g_quark_from_static_string (GTK_STYLE_CLASS_FLAT));
       else
-        gtk_style_context_remove_class (context, GTK_STYLE_CLASS_FLAT);
+        gtk_css_node_remove_class (priv->decoration_node, g_quark_from_static_string (GTK_STYLE_CLASS_FLAT));
 
-      if (gtk_widget_is_drawable (widget))
-       gtk_widget_queue_draw (widget);
-
-      gtk_widget_queue_resize (widget);
       g_object_notify_by_pspec (G_OBJECT (frame), frame_props[PROP_SHADOW_TYPE]);
     }
 }
@@ -622,52 +686,32 @@ gtk_frame_get_shadow_type (GtkFrame *frame)
   return frame->priv->shadow_type;
 }
 
-static void
-get_padding_and_border (GtkFrame *frame,
-                        GtkBorder *border)
+static gboolean
+gtk_frame_draw (GtkWidget *widget,
+               cairo_t   *cr)
 {
-  GtkStyleContext *context;
-  GtkStateFlags state;
-
-  context = gtk_widget_get_style_context (GTK_WIDGET (frame));
-  state = gtk_widget_get_state_flags (GTK_WIDGET (frame));
+  gtk_css_gadget_draw (GTK_FRAME (widget)->priv->gadget, cr);
 
-  gtk_style_context_get_padding (context, state, border);
-
-  if (frame->priv->shadow_type != GTK_SHADOW_NONE)
-    {
-      GtkBorder tmp;
-
-      gtk_style_context_get_border (context, state, &tmp);
-      border->top += tmp.top;
-      border->right += tmp.right;
-      border->bottom += tmp.bottom;
-      border->left += tmp.left;
-    }
+  return FALSE;
 }
 
 static gboolean
-gtk_frame_draw (GtkWidget *widget,
-               cairo_t   *cr)
+gtk_frame_render (GtkCssGadget *gadget,
+                  cairo_t      *cr,
+                  int           x,
+                  int           y,
+                  int           width,
+                  int           height,
+                  gpointer      data)
 {
-  GtkFrame *frame;
+  GtkWidget *widget;
   GtkFramePrivate *priv;
   GtkStyleContext *context;
-  gint x, y, width, height;
-  GtkAllocation allocation;
-  GtkBorder padding;
 
-  frame = GTK_FRAME (widget);
-  priv = frame->priv;
-
-  gtk_widget_get_allocation (widget, &allocation);
-  get_padding_and_border (frame, &padding);
+  widget = gtk_css_gadget_get_owner (gadget);
+  priv = GTK_FRAME (widget)->priv;
   context = gtk_widget_get_style_context (widget);
-
-  x = priv->child_allocation.x - allocation.x - padding.left;
-  y = priv->child_allocation.y - allocation.y - padding.top;
-  width = priv->child_allocation.width + padding.left + padding.right;
-  height =  priv->child_allocation.height + padding.top + padding.bottom;
+  gtk_style_context_save_to_node (context, priv->decoration_node);
 
   if (priv->label_widget)
     {
@@ -680,14 +724,11 @@ gtk_frame_draw (GtkWidget *widget,
       else
         xalign = 1 - priv->label_xalign;
 
-      height_extra = MAX (0, priv->label_allocation.height - padding.top)
-          - priv->label_yalign * priv->label_allocation.height;
-      y -= height_extra;
-      height += height_extra;
-
-      x2 = padding.left + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * 
LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
+      height_extra = (1 - priv->label_yalign) * gtk_widget_get_allocated_height (priv->label_widget);
+      y += height_extra;
+      height -= height_extra;
 
-      gtk_render_background (context, cr, x, y, width, height);
+      x2 =  (priv->child_allocation.width - priv->label_allocation.width) * xalign;
 
       /* If the label is completely over or under the frame we can omit the gap */
       if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0)
@@ -695,15 +736,15 @@ gtk_frame_draw (GtkWidget *widget,
       else
         gtk_render_frame_gap (context, cr,
                               x, y, width, height,
-                              GTK_POS_TOP, x2,
-                              x2 + priv->label_allocation.width + 2 * LABEL_PAD);
+                              GTK_POS_TOP, x2, x2 + priv->label_allocation.width);
     }
   else
     {
-      gtk_render_background (context, cr, x, y, width, height);
       gtk_render_frame (context, cr, x, y, width, height);
     }
 
+  gtk_style_context_restore (context);
+
   GTK_WIDGET_CLASS (gtk_frame_parent_class)->draw (widget, cr);
 
   return FALSE;
@@ -713,25 +754,38 @@ static void
 gtk_frame_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
 {
-  GtkFrame *frame = GTK_FRAME (widget);
-  GtkFramePrivate *priv = frame->priv;
-  GtkBin *bin = GTK_BIN (widget);
+  GtkAllocation clip;
+
+  gtk_widget_set_allocation (widget, allocation);
+
+  gtk_css_gadget_allocate (GTK_FRAME (widget)->priv->gadget,
+                           allocation,
+                           gtk_widget_get_allocated_baseline (widget),
+                           &clip);
+
+  gtk_widget_set_clip (widget, &clip);
+}
+
+static void
+gtk_frame_allocate (GtkCssGadget        *gadget,
+                    const GtkAllocation *allocation,
+                    int                  baseline,
+                    GtkAllocation       *out_clip,
+                    gpointer             data)
+{
+  GtkWidget *widget;
+  GtkFrame *frame;
+  GtkFramePrivate *priv;
   GtkAllocation new_allocation;
   GtkWidget *child;
 
-  gtk_widget_set_allocation (widget, allocation);
+  widget = gtk_css_gadget_get_owner (gadget);
+  frame = GTK_FRAME (widget);
+  priv = frame->priv;
 
   gtk_frame_compute_child_allocation (frame, &new_allocation);
 
-  /* If the child allocation changed, that means that the frame is drawn
-   * in a new place, so we must redraw the entire widget.
-   */
-  if (gtk_widget_get_mapped (widget) && !gdk_rectangle_equal (&priv->child_allocation, &new_allocation))
-    {
-      gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
-    }
-
-  child = gtk_bin_get_child (bin);
+  child = gtk_bin_get_child (GTK_BIN (widget));
   if (child && gtk_widget_get_visible (child))
     gtk_widget_size_allocate (child, &new_allocation);
 
@@ -739,35 +793,28 @@ gtk_frame_size_allocate (GtkWidget     *widget,
 
   if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
     {
-      GtkBorder padding;
       gint nat_width, width, height;
       gfloat xalign;
 
-      get_padding_and_border (frame, &padding);
-
       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
        xalign = priv->label_xalign;
       else
        xalign = 1 - priv->label_xalign;
 
       gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
-      width = new_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD;
-      width = MIN (width, nat_width);
-
-      gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
-                                                 &height, NULL);
-
-
-      priv->label_allocation.x = priv->child_allocation.x + LABEL_SIDE_PAD +
-       (new_allocation.width - width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_PAD;
+      width = MIN (new_allocation.width, nat_width);
+      gtk_widget_get_preferred_height_for_width (priv->label_widget, width, &height, NULL);
 
+      priv->label_allocation.x = allocation->x + (new_allocation.width - width) * xalign;
       priv->label_allocation.width = width;
 
-      priv->label_allocation.y = priv->child_allocation.y - MAX (height, padding.top);
+      priv->label_allocation.y = allocation->y;
       priv->label_allocation.height = height;
 
       gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation);
     }
+
+  gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
 }
 
 static void
@@ -787,12 +834,9 @@ gtk_frame_real_compute_child_allocation (GtkFrame      *frame,
   GtkFramePrivate *priv = frame->priv;
   GtkWidget *widget = GTK_WIDGET (frame);
   GtkAllocation allocation;
-  GtkBorder padding;
-  gint top_margin;
-  gint border_width;
+  gint border_width, height;
 
   gtk_widget_get_allocation (widget, &allocation);
-  get_padding_and_border (frame, &padding);
   border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
 
   if (priv->label_widget)
@@ -800,175 +844,148 @@ gtk_frame_real_compute_child_allocation (GtkFrame      *frame,
       gint nat_width, width, height;
 
       gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
-
-      width = allocation.width;
-      width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
-      width -= (border_width * 2) + padding.left + padding.right;
-
-      width = MIN (width, nat_width);
-
-      gtk_widget_get_preferred_height_for_width (priv->label_widget, width,
-                                                 &height, NULL);
-
-      top_margin = MAX (height, padding.top);
+      width = MIN (allocation.width - 2 * border_width, nat_width);
+      gtk_widget_get_preferred_height_for_width (priv->label_widget, width, &height, NULL);
     }
   else
-    top_margin = padding.top;
+    height = 0;
 
-  child_allocation->x = border_width + padding.left;
-  child_allocation->y = border_width + top_margin;
-  child_allocation->width = MAX (1, (gint) (allocation.width - (border_width * 2) -
-                                           padding.left - padding.right));
-  child_allocation->height = MAX (1, (gint) (allocation.height - child_allocation->y -
-                                            border_width - padding.bottom));
-
-  child_allocation->x += allocation.x;
-  child_allocation->y += allocation.y;
+  child_allocation->x = allocation.x + border_width;
+  child_allocation->y = allocation.y + border_width + height;
+  child_allocation->width = MAX (1, allocation.width - 2 * border_width);
+  child_allocation->height = MAX (1, allocation.height - 2 * border_width - height);
 }
 
 static void
-gtk_frame_get_preferred_size (GtkWidget      *widget,
-                              GtkOrientation  orientation,
-                              gint           *minimum_size,
-                              gint           *natural_size)
+gtk_frame_measure (GtkCssGadget   *gadget,
+                   GtkOrientation  orientation,
+                   int             for_size,
+                   int            *minimum,
+                   int            *natural,
+                   int            *minimum_baseline,
+                   int            *natural_baseline,
+                   gpointer        data)
 {
-  GtkFrame *frame = GTK_FRAME (widget);
-  GtkFramePrivate *priv = frame->priv;
-  GtkBorder padding;
+  GtkWidget *widget;
+  GtkFrame *frame;
+  GtkFramePrivate *priv;
   GtkWidget *child;
-  GtkBin *bin = GTK_BIN (widget);
   gint child_min, child_nat;
-  gint minimum, natural;
   guint border_width;
 
-  get_padding_and_border (frame, &padding);
+  widget = gtk_css_gadget_get_owner (gadget);
+  frame = GTK_FRAME (widget);
+  priv = frame->priv;
+
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
   if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
     {
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          gtk_widget_get_preferred_width (priv->label_widget,
-                                          &child_min, &child_nat);
-          minimum = child_min + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
-          natural = child_nat + 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
+          gtk_widget_get_preferred_width (priv->label_widget, &child_min, &child_nat);
+          *minimum = child_min;
+          *natural = child_nat;
         }
       else
         {
-          gtk_widget_get_preferred_height (priv->label_widget,
-                                           &child_min, &child_nat);
-          minimum = MAX (0, child_min - padding.top);
-          natural = MAX (0, child_nat - padding.top);
+          if (for_size > 0)
+            gtk_widget_get_preferred_height_for_width (priv->label_widget,
+                                                       for_size - 2 * border_width, &child_min, &child_nat);
+          else
+            gtk_widget_get_preferred_height (priv->label_widget, &child_min, &child_nat);
+
+          *minimum = child_min;
+          *natural = child_nat;
         }
     }
   else
     {
-      minimum = 0;
-      natural = 0;
+      *minimum = 0;
+      *natural = 0;
     }
 
-  child = gtk_bin_get_child (bin);
+  child = gtk_bin_get_child (GTK_BIN (widget));
   if (child && gtk_widget_get_visible (child))
     {
       if (orientation == GTK_ORIENTATION_HORIZONTAL)
         {
-          gtk_widget_get_preferred_width (child,
-                                          &child_min, &child_nat);
-          minimum = MAX (minimum, child_min);
-          natural = MAX (natural, child_nat);
+          gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+          *minimum = MAX (*minimum, child_min);
+          *natural = MAX (*natural, child_nat);
         }
       else
         {
-          gtk_widget_get_preferred_height (child,
-                                           &child_min, &child_nat);
-          minimum += child_min;
-          natural += child_nat;
-        }
-    }
+          if (for_size > 0)
+            gtk_widget_get_preferred_height_for_width (child, for_size - 2 * border_width, &child_min, 
&child_nat);
+          else
+            gtk_widget_get_preferred_height (child, &child_min, &child_nat);
 
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-      minimum += (border_width * 2) + padding.left + padding.right;
-      natural += (border_width * 2) + padding.left + padding.right;
-    }
-  else
-    {
-      minimum += (border_width * 2) + padding.top + padding.bottom;
-      natural += (border_width * 2) + padding.top + padding.bottom;
+          *minimum += child_min;
+          *natural += child_nat;
+        }
     }
 
-  *minimum_size = minimum;
-  *natural_size = natural;
+  *minimum += 2 * border_width;
+  *natural += 2 * border_width;
 }
 
 static void
 gtk_frame_get_preferred_width (GtkWidget *widget,
-                               gint      *minimum_size,
-                               gint      *natural_size)
+                               gint      *minimum,
+                               gint      *natural)
 {
-  gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_HORIZONTAL, minimum_size, natural_size);
+  gtk_css_gadget_get_preferred_size (GTK_FRAME (widget)->priv->gadget,
+                                     GTK_ORIENTATION_HORIZONTAL,
+                                     -1,
+                                     minimum, natural,
+                                     NULL, NULL);
+}
+
+static void
+gtk_frame_get_preferred_width_for_height (GtkWidget *widget,
+                                          gint       height,
+                                          gint      *minimum,
+                                          gint      *natural)
+{
+  gtk_css_gadget_get_preferred_size (GTK_FRAME (widget)->priv->gadget,
+                                     GTK_ORIENTATION_HORIZONTAL,
+                                     height,
+                                     minimum, natural,
+                                     NULL, NULL);
 }
 
 static void
 gtk_frame_get_preferred_height (GtkWidget *widget,
-                                gint      *minimum_size,
-                                gint      *natural_size)
+                                gint      *minimum,
+                                gint      *natural)
 {
-  gtk_frame_get_preferred_size (widget, GTK_ORIENTATION_VERTICAL, minimum_size, natural_size);
+  gtk_css_gadget_get_preferred_size (GTK_FRAME (widget)->priv->gadget,
+                                     GTK_ORIENTATION_VERTICAL,
+                                     -1,
+                                     minimum, natural,
+                                     NULL, NULL);
 }
 
 
 static void
 gtk_frame_get_preferred_height_for_width (GtkWidget *widget,
                                           gint       width,
-                                          gint      *minimum_height,
-                                          gint      *natural_height)
+                                          gint      *minimum,
+                                          gint      *natural)
 {
-  GtkWidget *child;
-  GtkFrame *frame = GTK_FRAME (widget);
-  GtkFramePrivate *priv = frame->priv;
-  GtkBin *bin = GTK_BIN (widget);
-  GtkBorder padding;
-  gint child_min, child_nat, label_width;
-  gint minimum, natural;
-  guint border_width;
-
-  get_padding_and_border (frame, &padding);
-  border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
-  minimum = (border_width * 2) + padding.top + padding.bottom;
-  natural = (border_width * 2) + padding.top + padding.bottom;
-
-  width -= (border_width * 2) + padding.left + padding.right;
-  label_width = width - 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
-
-  if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
-    {
-      gtk_widget_get_preferred_height_for_width (priv->label_widget,
-                                                 label_width, &child_min, &child_nat);
-      minimum += child_min;
-      natural += child_nat;
-    }
-
-  child = gtk_bin_get_child (bin);
-  if (child && gtk_widget_get_visible (child))
-    {
-      gtk_widget_get_preferred_height_for_width (child,
-                                                 width, &child_min, &child_nat);
-      minimum += child_min;
-      natural += child_nat;
-    }
-
-  *minimum_height = minimum;
-  *natural_height = natural;
+  gtk_css_gadget_get_preferred_size (GTK_FRAME (widget)->priv->gadget,
+                                     GTK_ORIENTATION_VERTICAL,
+                                     width,
+                                     minimum, natural,
+                                     NULL, NULL);
 }
 
 static void
-gtk_frame_get_preferred_width_for_height (GtkWidget *widget,
-                                          gint       height,
-                                          gint      *minimum_width,
-                                          gint      *natural_width)
+gtk_frame_state_flags_changed (GtkWidget     *widget,
+                               GtkStateFlags  previous_state)
 {
-  GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, minimum_width, natural_width);
-}
+  gtk_css_node_set_state (GTK_FRAME (widget)->priv->decoration_node, gtk_widget_get_state_flags (widget));
 
+  GTK_WIDGET_CLASS (gtk_frame_parent_class)->state_flags_changed (widget, previous_state);
+}
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index b5524c7..e2c2dc6 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -2488,7 +2488,7 @@ levelbar {
 /**********
  * Frames *
  **********/
-frame,
+frame decoration,
 .frame {
   border: 1px solid $borders_color;
   &.flat { border-style: none; }
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 14c788b..fa3f513 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -3429,14 +3429,14 @@ levelbar {
 /**********
  * Frames *
  **********/
-frame,
+frame decoration,
 .frame {
   border: 1px solid #1c1f1f;
   padding: 0; }
-  frame.flat,
+  frame decoration.flat,
   .frame.flat {
     border-style: none; }
-  frame:backdrop,
+  frame decoration:backdrop,
   .frame:backdrop {
     border-color: #1f2222; }
 
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index a388bef..1eaf8fc 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -3591,14 +3591,14 @@ levelbar {
 /**********
  * Frames *
  **********/
-frame,
+frame decoration,
 .frame {
   border: 1px solid #a1a1a1;
   padding: 0; }
-  frame.flat,
+  frame decoration.flat,
   .frame.flat {
     border-style: none; }
-  frame:backdrop,
+  frame decoration:backdrop,
   .frame:backdrop {
     border-color: darkgray; }
 


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