[gtk+/wip/matthiasc/gadget] frame: Some fixes



commit 88238d5529342d4526dd4c24c60b58dcc1c2b137
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Dec 10 00:00:18 2015 -0500

    frame: Some fixes
    
    The gadget conversion broke GtkAspectFrame, this makes it
    working again. Also, avoid unintentional inheritance of
    border radius from window decorations.

 gtk/gtkframe.c                           |   29 +++++++++++++++++++----------
 gtk/theme/Adwaita/_common.scss           |    1 +
 gtk/theme/Adwaita/gtk-contained-dark.css |    1 +
 gtk/theme/Adwaita/gtk-contained.css      |    1 +
 4 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 55085ad..e59a498 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -707,12 +707,21 @@ gtk_frame_render (GtkCssGadget *gadget,
   GtkWidget *widget;
   GtkFramePrivate *priv;
   GtkStyleContext *context;
+  GtkAllocation allocation;
 
   widget = gtk_css_gadget_get_owner (gadget);
   priv = GTK_FRAME (widget)->priv;
+
   context = gtk_widget_get_style_context (widget);
   gtk_style_context_save_to_node (context, priv->decoration_node);
 
+
+  gtk_widget_get_allocation (widget, &allocation);
+  x = priv->child_allocation.x - allocation.x;
+  y = priv->child_allocation.y - allocation.y;
+  width = priv->child_allocation.width;
+  height = priv->child_allocation.height;
+
   if (priv->label_widget)
     {
       gfloat xalign;
@@ -724,11 +733,11 @@ gtk_frame_render (GtkCssGadget *gadget,
       else
         xalign = 1 - priv->label_xalign;
 
-      height_extra = (1 - priv->label_yalign) * gtk_widget_get_allocated_height (priv->label_widget);
-      y += height_extra;
-      height -= height_extra;
+      height_extra = (1 - priv->label_yalign) * priv->label_allocation.height;
+      y -= height_extra;
+      height += height_extra;
 
-      x2 =  (priv->child_allocation.width - priv->label_allocation.width) * xalign;
+      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)
@@ -736,7 +745,8 @@ gtk_frame_render (GtkCssGadget *gadget,
       else
         gtk_render_frame_gap (context, cr,
                               x, y, width, height,
-                              GTK_POS_TOP, x2, x2 + priv->label_allocation.width);
+                              GTK_POS_TOP,
+                              x2, x2 + priv->label_allocation.width);
     }
   else
     {
@@ -805,11 +815,10 @@ gtk_frame_allocate (GtkCssGadget        *gadget,
       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 = allocation->y;
+      priv->label_allocation.x = new_allocation.x + (new_allocation.width - width) * xalign;
+      priv->label_allocation.y = new_allocation.y - height;
       priv->label_allocation.height = height;
+      priv->label_allocation.width = width;
 
       gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation);
     }
@@ -841,7 +850,7 @@ gtk_frame_real_compute_child_allocation (GtkFrame      *frame,
 
   if (priv->label_widget)
     {
-      gint nat_width, width, height;
+      gint nat_width, width;
 
       gtk_widget_get_preferred_width (priv->label_widget, NULL, &nat_width);
       width = MIN (allocation.width - 2 * border_width, nat_width);
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index e2c2dc6..2187070 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -2490,6 +2490,7 @@ levelbar {
  **********/
 frame decoration,
 .frame {
+  border-radius: 0;
   border: 1px solid $borders_color;
   &.flat { border-style: none; }
   &:backdrop { border-color: $backdrop_borders_color; }
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index fa3f513..faee2a5 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -3431,6 +3431,7 @@ levelbar {
  **********/
 frame decoration,
 .frame {
+  border-radius: 0;
   border: 1px solid #1c1f1f;
   padding: 0; }
   frame decoration.flat,
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 1eaf8fc..9669221 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -3593,6 +3593,7 @@ levelbar {
  **********/
 frame decoration,
 .frame {
+  border-radius: 0;
   border: 1px solid #a1a1a1;
   padding: 0; }
   frame decoration.flat,


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