[gtk+/rendering-cleanup: 94/95] style: Apply same matrix conversion as gdk_draw_layout() did



commit 01a10ceb59a7cd79a7ea001124bbe81ddfff1441
Author: Benjamin Otte <otte redhat com>
Date:   Sat Aug 7 02:14:10 2010 +0200

    style: Apply same matrix conversion as gdk_draw_layout() did
    
    This is only necessary for GtkLabel with an angle set as no other widget
    rotates text.
    Note that the label code does not need these adjustments as those paths
    are only taken when the label is not rotated.

 gtk/gtkstyle.c |   32 ++++++++++++++++++++++++++++++--
 1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index 0783427..12f4f07 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <gobject/gvaluecollector.h>
 #include "gtkmarshalers.h"
+#include "gtkpango.h"
 #include "gtkrc.h"
 #include "gtkspinbutton.h"
 #include "gtkstyle.h"
@@ -4188,6 +4189,7 @@ gtk_default_draw_layout (GtkStyle        *style,
 {
   cairo_t *cr;
   GdkColor *gc;
+  const PangoMatrix *matrix;
 
   cr = gdk_cairo_create (window);
 
@@ -4197,17 +4199,43 @@ gtk_default_draw_layout (GtkStyle        *style,
       cairo_clip (cr);
     }
 
+  matrix = pango_context_get_matrix (pango_layout_get_context (layout));
+  if (matrix)
+    {
+      cairo_matrix_t cairo_matrix;
+      PangoMatrix tmp_matrix;
+      PangoRectangle rect;
+      
+      cairo_matrix_init (&cairo_matrix,
+                         matrix->xx, matrix->yx,
+                         matrix->xy, matrix->yy,
+                         matrix->x0, matrix->y0);
+
+      pango_layout_get_extents (layout, NULL, &rect);
+      pango_matrix_transform_rectangle (matrix, &rect);
+      pango_extents_to_pixels (&rect, NULL);
+                                          
+      tmp_matrix = *matrix;
+      cairo_matrix.x0 += x - rect.x;
+      cairo_matrix.y0 += y - rect.y;
+
+      cairo_set_matrix (cr, &cairo_matrix);
+    }
+  else
+    cairo_translate (cr, x, y);
+
   if (state_type == GTK_STATE_INSENSITIVE)
     {
+      cairo_save (cr);
       gdk_cairo_set_source_color (cr, &style->white);
-      cairo_move_to (cr, x + 1, y + 1);
+      cairo_move_to (cr, 1, 1);
       pango_cairo_layout_path (cr, layout);
       cairo_fill (cr);
+      cairo_restore (cr);
     }
 
   gc = use_text ? &style->text[state_type] : &style->fg[state_type];
 
-  cairo_move_to (cr, x, y);
   gdk_cairo_set_source_color (cr, gc);
 
   pango_cairo_show_layout (cr, layout);



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