[gimp] Bug 788399 - Corrupted display of sample points



commit a7620b08aa80bf9528940b07487947b2237065f9
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 1 19:39:56 2017 +0200

    Bug 788399 - Corrupted display of sample points
    
    In gimp_canvas_sample_point_get_extents(), use the drawn number's
    actual size instead of some random constant that was good enough for
    my own font size.

 app/display/gimpcanvassamplepoint.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/app/display/gimpcanvassamplepoint.c b/app/display/gimpcanvassamplepoint.c
index 3490063..f900ccb 100644
--- a/app/display/gimpcanvassamplepoint.c
+++ b/app/display/gimpcanvassamplepoint.c
@@ -254,9 +254,13 @@ gimp_canvas_sample_point_draw (GimpCanvasItem *item,
 static cairo_region_t *
 gimp_canvas_sample_point_get_extents (GimpCanvasItem *item)
 {
-  cairo_rectangle_int_t rectangle;
-  gdouble               x, y;
-  gint                  x1, x2, y1, y2;
+  GimpCanvasSamplePointPrivate *private = GET_PRIVATE (item);
+  GtkWidget                    *canvas  = gimp_canvas_item_get_canvas (item);
+  cairo_rectangle_int_t         rectangle;
+  PangoLayout                  *layout;
+  PangoRectangle                ink;
+  gdouble                       x, y;
+  gint                          x1, x2, y1, y2;
 
   gimp_canvas_sample_point_transform (item, &x, &y);
 
@@ -265,15 +269,19 @@ gimp_canvas_sample_point_get_extents (GimpCanvasItem *item)
   y1 = floor (y - GIMP_SAMPLE_POINT_DRAW_SIZE);
   y2 = ceil  (y + GIMP_SAMPLE_POINT_DRAW_SIZE);
 
+  layout = gimp_canvas_get_layout (GIMP_CANVAS (canvas),
+                                   "%d", private->index);
+
+  pango_layout_get_extents (layout, &ink, NULL);
+
+  x2 = MAX (x2, 2.5 + ink.width);
+  y2 = MAX (y2, 2.5 + ink.height);
+
   rectangle.x      = x1 - 1.5;
   rectangle.y      = y1 - 1.5;
   rectangle.width  = x2 - x1 + 3.0;
   rectangle.height = y2 - y1 + 3.0;
 
-  /* HACK: add 5 so the number gets cleared too */
-  rectangle.width  += 5;
-  rectangle.height += 5;
-
   return cairo_region_create_rectangle (&rectangle);
 }
 


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