[gimp] app: fix rendering glitches on changing the axis ranges in GimpCurveView



commit edca08e1c25878eedf90dc2b55ad47a36dcc41c1
Author: Michael Natterer <mitch gimp org>
Date:   Thu Jun 13 00:22:20 2013 +0200

    app: fix rendering glitches on changing the axis ranges in GimpCurveView
    
    and honor the x-axis range when displaying the set "xpos".

 app/widgets/gimpcurveview.c |   33 +++++++++++++++++++++++++++++++--
 1 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c
index 3daab3d..c72aed2 100644
--- a/app/widgets/gimpcurveview.c
+++ b/app/widgets/gimpcurveview.c
@@ -645,8 +645,21 @@ gimp_curve_view_expose (GtkWidget      *widget,
                      border + height - 1);
       cairo_stroke (cr);
 
-      /* and xpos indicator */
-      g_snprintf (buf, sizeof (buf), "x:%d", (gint) (view->xpos * 255.999));
+      /*  stupid heuristic: special-case for 0..255  */
+      if (view->range_x_max == 255.0)
+        {
+          g_snprintf (buf, sizeof (buf), "x:%3d",
+                      (gint) (view->xpos *
+                              (view->range_x_max - view->range_x_min) +
+                              view->range_x_min));
+        }
+      else
+        {
+          g_snprintf (buf, sizeof (buf), "x:%0.3f",
+                      view->xpos *
+                      (view->range_x_max - view->range_x_min) +
+                      view->range_x_min);
+        }
 
       if (! view->layout)
         view->layout = gtk_widget_create_pango_layout (widget, NULL);
@@ -1332,6 +1345,14 @@ gimp_curve_view_set_range_x (GimpCurveView *view,
 
   view->range_x_min = min;
   view->range_x_max = max;
+
+  if (view->cursor_layout)
+    {
+      g_object_unref (view->cursor_layout);
+      view->cursor_layout = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (view));
 }
 
 void
@@ -1343,6 +1364,14 @@ gimp_curve_view_set_range_y (GimpCurveView *view,
 
   view->range_y_min = min;
   view->range_y_max = max;
+
+  if (view->cursor_layout)
+    {
+      g_object_unref (view->cursor_layout);
+      view->cursor_layout = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (view));
 }
 
 void


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