]> Pileus Git - ~andy/gtk/commitdiff
Use pango_matrix_transform_rectangle(). (#340141)
authorBehdad Esfahbod <behdad@gnome.org>
Wed, 10 Jan 2007 20:21:26 +0000 (20:21 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Wed, 10 Jan 2007 20:21:26 +0000 (20:21 +0000)
2007-01-10  Behdad Esfahbod  <behdad@gnome.org>

        * gdk/gdkpango.c (gdk_draw_layout_with_colors):
        * gtk/gtklabel.c (gtk_label_size_request):
        Use pango_matrix_transform_rectangle(). (#340141)

        * configure.in: Bump pango requirement to 1.15.3.

svn path=/trunk/; revision=17129

ChangeLog
configure.in
gdk/gdkpango.c
gtk/gtklabel.c

index 9521e7a52de86693c60e0a3462756ad38a54e33b..6d8033d7c6149436ecb0bc36472eca0f821de506 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-10  Behdad Esfahbod  <behdad@gnome.org>
+
+       * gdk/gdkpango.c (gdk_draw_layout_with_colors):
+       * gtk/gtklabel.c (gtk_label_size_request):
+       Use pango_matrix_transform_rectangle(). (#340141)
+
+       * configure.in: Bump pango requirement to 1.15.3.
+
 2007-01-10  Kristian Rietveld  <kris@imendio.com>
 
        * gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_init):
index 29c4831af8de80f7785f2d5a86195aa0013fc359..7ed909ff3acc67080c4364ac7a4bb22b4ba53a19 100644 (file)
@@ -32,7 +32,7 @@ m4_define([gtk_binary_version], [2.10.0])
 
 # required versions of other packages
 m4_define([glib_required_version], [2.12.0])
-m4_define([pango_required_version], [1.15.2])
+m4_define([pango_required_version], [1.15.3])
 m4_define([atk_required_version], [1.9.0])
 m4_define([cairo_required_version], [1.2.0])
 
index 54c0c961c837009259ea8c041d8e259e7a19b687..59438b5f8e80b5e2ea0e5f55fedd7a16d7174c8e 100644 (file)
@@ -873,55 +873,6 @@ gdk_draw_layout_line_with_colors (GdkDrawable      *drawable,
   release_renderer (renderer);
 }
 
-/* Gets the bounds of a layout in device coordinates. Note cut-and-paste
- * between here and gtklabel.c */
-static void
-get_rotated_layout_bounds (PangoLayout  *layout,
-                          GdkRectangle *rect)
-{
-  PangoContext *context = pango_layout_get_context (layout);
-  const PangoMatrix *matrix = pango_context_get_matrix (context);
-  gdouble x_min = 0, x_max = 0, y_min = 0, y_max = 0; /* quiet gcc */
-  PangoRectangle logical_rect;
-  gint i, j;
-
-  pango_layout_get_extents (layout, NULL, &logical_rect);
-  
-  for (i = 0; i < 2; i++)
-    {
-      gdouble x = (i == 0) ? logical_rect.x : logical_rect.x + logical_rect.width;
-      for (j = 0; j < 2; j++)
-       {
-         gdouble y = (j == 0) ? logical_rect.y : logical_rect.y + logical_rect.height;
-         
-         gdouble xt = (x * matrix->xx + y * matrix->xy) / PANGO_SCALE + matrix->x0;
-         gdouble yt = (x * matrix->yx + y * matrix->yy) / PANGO_SCALE + matrix->y0;
-         
-         if (i == 0 && j == 0)
-           {
-             x_min = x_max = xt;
-             y_min = y_max = yt;
-           }
-         else
-           {
-             if (xt < x_min)
-               x_min = xt;
-             if (yt < y_min)
-               y_min = yt;
-             if (xt > x_max)
-               x_max = xt;
-             if (yt > y_max)
-               y_max = yt;
-           }
-       }
-    }
-  
-  rect->x = floor (x_min);
-  rect->width = ceil (x_max) - rect->x;
-  rect->y = floor (y_min);
-  rect->height = floor (y_max) - rect->y;
-}
-
 /**
  * gdk_draw_layout_with_colors:
  * @drawable:  the drawable on which to draw string
@@ -970,9 +921,11 @@ gdk_draw_layout_with_colors (GdkDrawable     *drawable,
   if (matrix)
     {
       PangoMatrix tmp_matrix;
-      GdkRectangle rect;
+      PangoRectangle rect;
 
-      get_rotated_layout_bounds (layout, &rect);
+      pango_layout_get_extents (layout, NULL, &rect);
+      pango_matrix_transform_rectangle (matrix, &rect);
+      pango_extents_to_pixels (&rect, NULL);
       
       tmp_matrix = *matrix;
       tmp_matrix.x0 += x - rect.x;
index 6f25651df9495a999e22207a6b9ab5f738b15294..9cee21d10a8c6b5a521c5715bc6c6fe4df59f5c7 100644 (file)
@@ -2042,55 +2042,6 @@ gtk_label_ensure_layout (GtkLabel *label)
     }
 }
 
-/* Gets the bounds of a layout in device coordinates. Note cut-and-paste
- * between here and gdkpango.c */
-static void
-get_rotated_layout_bounds (PangoLayout  *layout,
-                          GdkRectangle *rect)
-{
-  PangoContext *context = pango_layout_get_context (layout);
-  const PangoMatrix *matrix = pango_context_get_matrix (context);
-  gdouble x_min = 0, x_max = 0, y_min = 0, y_max = 0; /* quiet gcc */
-  PangoRectangle logical_rect;
-  gint i, j;
-
-  pango_layout_get_extents (layout, NULL, &logical_rect);
-  
-  for (i = 0; i < 2; i++)
-    {
-      gdouble x = (i == 0) ? logical_rect.x : logical_rect.x + logical_rect.width;
-      for (j = 0; j < 2; j++)
-       {
-         gdouble y = (j == 0) ? logical_rect.y : logical_rect.y + logical_rect.height;
-         
-         gdouble xt = (x * matrix->xx + y * matrix->xy) / PANGO_SCALE + matrix->x0;
-         gdouble yt = (x * matrix->yx + y * matrix->yy) / PANGO_SCALE + matrix->y0;
-         
-         if (i == 0 && j == 0)
-           {
-             x_min = x_max = xt;
-             y_min = y_max = yt;
-           }
-         else
-           {
-             if (xt < x_min)
-               x_min = xt;
-             if (yt < y_min)
-               y_min = yt;
-             if (xt > x_max)
-               x_max = xt;
-             if (yt > y_max)
-               y_max = yt;
-           }
-       }
-    }
-  
-  rect->x = floor (x_min);
-  rect->width = ceil (x_max) - rect->x;
-  rect->y = floor (y_min);
-  rect->height = floor (y_max) - rect->y;
-}
-
 static void
 gtk_label_size_request (GtkWidget      *widget,
                        GtkRequisition *requisition)
@@ -2132,9 +2083,13 @@ gtk_label_size_request (GtkWidget      *widget,
 
   if (label->have_transform)
     {
-      GdkRectangle rect;
+      PangoRectangle rect;
+      PangoContext *context = pango_layout_get_context (label->layout);
+      const PangoMatrix *matrix = pango_context_get_matrix (context);
 
-      get_rotated_layout_bounds (label->layout, &rect);
+      pango_layout_get_extents (label->layout, NULL, &rect);
+      pango_matrix_transform_rectangle (matrix, &rect);
+      pango_extents_to_pixels (&rect, NULL);
       
       requisition->width = width + rect.width;
       requisition->height = height + rect.height;