Re: GnomeCanvas question, bug & patch




Seems, that gnome-canvas-utils has a bug. gnome_canvas_item_update_svp & 
relatives do not require redrawing new region, if previous svp (previous 
region) is NULL.
It affects only items added to already visible canvas, or if hidden items
are shown.

Included is small patch.

On Mon, 23 Aug 1999, Ronald de Man wrote:

> Hello,
> 
> I'm playing a bit with the (non-AA) canvas. At the moment I can drag items
> around, and everything is fine until I want to return an item to
> a certain fixed position. What I do to move 'item' to (dest_x, dest_y) is:

Hmmm...

> 
> double xx, yy;

xx = yy = 0.0;

> gnome_canvas_item_i2w(item, &xx, &yy);
> gnome_canvas_item_set(item, "x", dest_x - xx, "y", dest_y - yy, NULL);

gnome_canvas_item_i2w transforms point in item coords to point in world
coords. So you have to give it some value...

I would do:

gnome_canvas_item_i2c_affine (item, i2c);
i2c[4] = dest_x;
i2c[5] = dest_y;
gnome_canvas_item_i2c_affine (item->parent, p2c);
art_affine_invert (c2p, p2c);
art_affine_multiply (i2p, i2c, c2i);

or something similar. Although non-aa canvas items do not have full
affine, tranlating as this should work well.

Lauris Kaplinski

> 
> This works well, except in situations where I had dragged the item
> outside the canvas. In that case, sometimes it works, and sometimes
> it doesn't. When it doesn't work, the xx and yy are equal to 'nan'.
> 
> I can probably hack around this by first moving the item
> with gnome_canvas_item_move back to the canvas, and then performing the
> above, but I don't think this problem should arise at all.
> Or am I doing something wrong?
> 
> Ronald
> 
--- gnome-canvas-util.c	Wed Jun 23 19:53:16 1999
+++ ../libgnomeui-new/gnome-canvas-util.c	Mon Aug 23 18:17:13 1999
@@ -439,10 +439,16 @@
 		repaint_uta = art_uta_from_svp (new_svp);
 		gnome_canvas_request_redraw_uta (canvas, repaint_uta);
 #endif
-	} else if (old_svp != NULL) {
-		repaint_uta = art_uta_from_svp (old_svp);
-		art_svp_free (old_svp);
-		gnome_canvas_request_redraw_uta (canvas, repaint_uta);
+	} else {
+		if (old_svp != NULL) {
+			repaint_uta = art_uta_from_svp (old_svp);
+			art_svp_free (old_svp);
+			gnome_canvas_request_redraw_uta (canvas, repaint_uta);
+		}
+		if (new_svp != NULL) {
+			repaint_uta = art_uta_from_svp (new_svp);
+			gnome_canvas_request_redraw_uta (canvas, repaint_uta);
+		}
 	}
 	*p_svp = new_svp;
 }


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