[glade] Fixed drag icon rendering bug. for some reason we need a cairo save/restore around our custom draw m



commit 4e9fd1a6be45c708174e1ca62f1be2cf587cbd0a
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Thu Jun 6 20:08:33 2013 -0300

    Fixed drag icon rendering bug. for some reason we need a cairo save/restore
    around our custom draw methods otherwise the children rendering get affected
    by our modifications to the cairo matrix.

 gladeui/glade-design-layout.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index 1d39521..6b84484 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -1902,7 +1902,7 @@ glade_design_layout_finalize (GObject *object)
 }
 
 static gboolean
-on_drag_icon_draw (GtkWidget *widget, cairo_t *cr, GladeDesignLayout *layout)
+on_drag_icon_draw (GtkWidget *widget, cairo_t *cr)
 {
   GtkStyleContext *context = gtk_widget_get_style_context (widget);
   cairo_pattern_t *gradient;
@@ -1910,6 +1910,17 @@ on_drag_icon_draw (GtkWidget *widget, cairo_t *cr, GladeDesignLayout *layout)
   gint x, y, w, h;
   gdouble h2;
   GdkRGBA bg;
+
+  /* Not needed acording to GtkWidget:draw documentation
+   * But seems like there is a bug when used as a drag_icon that makes the
+   * cairo translation used here persist when drawind children.
+   */
+  cairo_save (cr);
+
+  /* Clear BG */
+  cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+  cairo_paint (cr);
+  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
   
   gtk_widget_get_allocation (widget, &alloc);
   x = alloc.x;
@@ -1944,6 +1955,7 @@ on_drag_icon_draw (GtkWidget *widget, cairo_t *cr, GladeDesignLayout *layout)
   cairo_fill (cr);
   
   cairo_pattern_destroy (gradient);
+  cairo_restore (cr);
 
   return FALSE;
 }


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