From df5f31a628df0240aba6c9f7ae0586e77ec127ac Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 17 Sep 2012 20:41:51 +0000 Subject: Add Canvas::remove_edge and allow for_each_edge to be used to remove edges. Add Edge handle_radius accessors. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4777 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 16 ++++++++++++++-- src/edge.c | 20 ++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 337cd16..d3055d1 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -1487,6 +1487,12 @@ Canvas::remove_edge(Node* item1, Node* item2) } } +void +Canvas::remove_edge(Edge* edge) +{ + impl()->remove_edge(edge->gobj()); +} + Edge* Canvas::get_edge(Node* tail, Node* head) const { @@ -1501,8 +1507,14 @@ Canvas::get_edge(Node* tail, Node* head) const void Canvas::for_each_edge(EdgePtrFunc f, void* data) { - FOREACH_EDGE(impl()->_edges, i) { + for (GanvCanvasImpl::Edges::iterator i = impl()->_edges.begin(); + i != impl()->_edges.end();) { + GanvCanvasImpl::Edges::iterator next = i; + ++next; + f((*i), data); + + i = next; } } @@ -1802,7 +1814,7 @@ ganv_canvas_zoom_full(GanvCanvas* canvas) double bottom = DBL_MAX; FOREACH_ITEM(canvas->impl->_items, i) { - double x, y, w, h; + double x = 0.0, y = 0.0, w = 0.0, h = 0.0; g_object_get(G_OBJECT(*i), "x", &x, "y", &y, "w", &w, "h", &h, NULL); if (x < left) left = x; diff --git a/src/edge.c b/src/edge.c index 871498a..2440990 100644 --- a/src/edge.c +++ b/src/edge.c @@ -207,11 +207,13 @@ request_redraw(GanvCanvasBase* canvas, x2 + w, y2 + w); } - ganv_canvas_base_request_redraw(canvas, - coords->handle_x - coords->handle_radius, - coords->handle_y - coords->handle_radius, - coords->handle_x + coords->handle_radius, - coords->handle_y + coords->handle_radius); + if (coords->handle_radius > 0.0) { + ganv_canvas_base_request_redraw(canvas, + coords->handle_x - coords->handle_radius, + coords->handle_y - coords->handle_radius, + coords->handle_x + coords->handle_radius, + coords->handle_y + coords->handle_radius); + } if (coords->arrowhead) { ganv_canvas_base_request_redraw( @@ -420,9 +422,11 @@ ganv_edge_draw(GanvItem* item, cairo_stroke(cr); - cairo_move_to(cr, join_x, join_y); - cairo_arc(cr, join_x, join_y, impl->coords.handle_radius, 0, 2 * G_PI); - cairo_fill(cr); + if (impl->coords.handle_radius > 0.0) { + cairo_move_to(cr, join_x, join_y); + cairo_arc(cr, join_x, join_y, impl->coords.handle_radius, 0, 2 * G_PI); + cairo_fill(cr); + } } static double -- cgit v1.2.1