[goocanvas/new-api] 2010-06-28 Damon Chaplin <damon gnome org>



commit 99d89f204c5ed2ff10257f7a74443b3a73848afc
Author: Damon Chaplin <damon gnome org>
Date:   Mon Jun 28 22:44:32 2010 +0100

    2010-06-28  Damon Chaplin  <damon gnome org>
    
    	    * src/goocanvaspolyline.c (goo_canvas_polyline_reconfigure_arrows)
    	    (goo_canvas_polyline_is_item_at, goo_canvas_polyline_paint): if the
    	    line width is unscaled, don't scale the arrows either. To do this we
    	    have to recalculate the arrow coordinates before every operation.
    
    	    * demo/demo.c (setup_lines): set "line-width-is-unscaled" for one
    	    of the small lines with arrows, to test the above.

 ChangeLog               |   10 ++++++++++
 demo/demo.c             |    1 +
 src/goocanvaspolyline.c |   19 ++++++++++++++++++-
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3abfc79..e860f1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-06-28  Damon Chaplin  <damon gnome org>
 
+	* src/goocanvaspolyline.c (goo_canvas_polyline_reconfigure_arrows)
+	(goo_canvas_polyline_is_item_at, goo_canvas_polyline_paint): if the
+	line width is unscaled, don't scale the arrows either. To do this we
+	have to recalculate the arrow coordinates before every operation.
+
+	* demo/demo.c (setup_lines): set "line-width-is-unscaled" for one
+	of the small lines with arrows, to test the above.
+
+2010-06-28  Damon Chaplin  <damon gnome org>
+
 	* demo/demo-events.c: added tooltips to explain which items should
 	be getting events.
 
diff --git a/demo/demo.c b/demo/demo.c
index e15c0cd..e636b78 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -1095,6 +1095,7 @@ setup_lines (GooCanvasItem *root)
 				       "stroke-color", "blue",
 				       "line-width", 1.0,
 				       "line-width-tolerance", 4.0,
+				       "line-width-is-unscaled", TRUE,
 				       "start-arrow", TRUE,
 				       "end-arrow", TRUE,
 				       "arrow-tip-length", 5.0,
diff --git a/src/goocanvaspolyline.c b/src/goocanvaspolyline.c
index 8fa4028..bb3b93e 100644
--- a/src/goocanvaspolyline.c
+++ b/src/goocanvaspolyline.c
@@ -351,13 +351,24 @@ static void
 goo_canvas_polyline_reconfigure_arrows (GooCanvasPolyline *polyline)
 {
   GooCanvasItemSimple *simple = (GooCanvasItemSimple*) polyline;
-  double line_width;
+  GooCanvasStyle *style = simple->style;
+  double line_width, scale;
 
   if (polyline->num_points < 2
       || (!polyline->start_arrow && !polyline->end_arrow))
     return;
 
   line_width = goo_canvas_item_simple_get_line_width (simple);
+  if (style && style->line_width_is_unscaled && simple->canvas)
+    {
+      scale = MAX (simple->canvas->scale_x, simple->canvas->scale_y);
+
+      /* We only want to shrink the lines as the canvas is scaled up.
+	 We don't want to affect the line width when the scales are < 1. */
+      if (scale > 1.0)
+	line_width /= scale;
+    }
+
   ensure_arrow_data (polyline);
 
   if (polyline->start_arrow)
@@ -754,6 +765,7 @@ goo_canvas_polyline_is_item_at (GooCanvasItemSimple *simple,
 {
   GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
   GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
+  GooCanvasStyle *style = simple->style;
   gboolean do_stroke;
 
   if (polyline->num_points == 0)
@@ -767,6 +779,8 @@ goo_canvas_polyline_is_item_at (GooCanvasItemSimple *simple,
   if (!(polyline->close_path && polyline->num_points > 2))
     pointer_events &= ~GOO_CANVAS_EVENTS_FILL_MASK;
 
+  if (style && style->line_width_is_unscaled)
+    goo_canvas_polyline_reconfigure_arrows (polyline);
   goo_canvas_polyline_create_path (polyline, cr);
   if (goo_canvas_item_simple_check_in_path (simple, x, y, cr, pointer_events, TRUE))
     return TRUE;
@@ -875,10 +889,13 @@ goo_canvas_polyline_paint (GooCanvasItemSimple   *simple,
 			   const GooCanvasBounds *bounds)
 {
   GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
+  GooCanvasStyle *style = simple->style;
 
   if (polyline->num_points == 0)
     return;
 
+  if (style && style->line_width_is_unscaled)
+    goo_canvas_polyline_reconfigure_arrows (polyline);
   goo_canvas_polyline_create_path (polyline, cr);
   goo_canvas_item_simple_paint_path (simple, cr);
 



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