[cairo-commit] goocanvas/src goocanvas.c,1.18,1.19
Damon Chaplin
commit at pdx.freedesktop.org
Mon May 14 02:51:36 PDT 2007
Committed by: damon
Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv22569/src
Modified Files:
goocanvas.c
Log Message:
2007-05-14 Damon Chaplin <damon at gnome.org>
* src/goocanvas.c (goo_canvas_set_property)
(goo_canvas_set_bounds): queue a redraw of the widget.
(goo_canvas_expose_event): clip to the canvas bounds if necessary.
* demo/mv-demo.c (change_bounds_clicked):
* demo/demo.c (change_bounds_clicked): test changing the bounds
dynamically.
Index: goocanvas.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvas.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- goocanvas.c 30 Apr 2007 21:09:45 -0000 1.18
+++ goocanvas.c 14 May 2007 09:51:25 -0000 1.19
@@ -685,7 +685,10 @@
}
if (need_reconfigure)
- reconfigure_canvas (canvas, TRUE);
+ {
+ reconfigure_canvas (canvas, FALSE);
+ gtk_widget_queue_draw (GTK_WIDGET (canvas));
+ }
}
@@ -1675,7 +1678,8 @@
canvas->bounds.x2 = right;
canvas->bounds.y2 = bottom;
- reconfigure_canvas (canvas, TRUE);
+ reconfigure_canvas (canvas, FALSE);
+ gtk_widget_queue_draw (GTK_WIDGET (canvas));
}
@@ -2022,7 +2026,7 @@
GdkEventExpose *event)
{
GooCanvas *canvas = GOO_CANVAS (widget);
- GooCanvasBounds bounds;
+ GooCanvasBounds bounds, root_item_bounds;
cairo_t *cr;
if (!canvas->root_item)
@@ -2053,6 +2057,28 @@
/* Translate it so the top-left of the canvas becomes (0,0). */
cairo_translate (cr, -canvas->bounds.x1, -canvas->bounds.y1);
+ /* Clip to the canvas bounds, if necessary. We only need to clip if the
+ items in the canvas extend outside the canvas bounds and the canvas
+ bounds is less than the area being painted. */
+ goo_canvas_item_get_bounds (canvas->root_item, &root_item_bounds);
+ if ((root_item_bounds.x1 < canvas->bounds.x1
+ && canvas->bounds.x1 > bounds.x1)
+ || (root_item_bounds.x2 > canvas->bounds.x2
+ && canvas->bounds.x2 < bounds.x2)
+ || (root_item_bounds.y1 < canvas->bounds.y1
+ && canvas->bounds.y1 > bounds.y1)
+ || (root_item_bounds.y2 > canvas->bounds.y2
+ && canvas->bounds.y2 < bounds.y2))
+ {
+ cairo_new_path (cr);
+ cairo_move_to (cr, canvas->bounds.x1, canvas->bounds.y1);
+ cairo_line_to (cr, canvas->bounds.x2, canvas->bounds.y1);
+ cairo_line_to (cr, canvas->bounds.x2, canvas->bounds.y2);
+ cairo_line_to (cr, canvas->bounds.x1, canvas->bounds.y2);
+ cairo_close_path (cr);
+ cairo_clip (cr);
+ }
+
goo_canvas_item_paint (canvas->root_item, cr, &bounds, canvas->scale);
cairo_destroy (cr);
More information about the cairo-commit
mailing list