summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ganv/Canvas.hpp2
-rw-r--r--ganv/Edge.hpp1
-rw-r--r--src/Canvas.cpp16
-rw-r--r--src/edge.c20
4 files changed, 29 insertions, 10 deletions
diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp
index 08a1140..00c267c 100644
--- a/ganv/Canvas.hpp
+++ b/ganv/Canvas.hpp
@@ -99,6 +99,8 @@ public:
/** Delete the edge from @c tail to @c head. */
void remove_edge(Node* tail, Node* head);
+ void remove_edge(Edge* edge);
+
typedef void (*EdgePtrFunc)(GanvEdge* edge, void* data);
void for_each_edge(EdgePtrFunc f, void* data);
diff --git a/ganv/Edge.hpp b/ganv/Edge.hpp
index 83c3a0b..aa8e7d1 100644
--- a/ganv/Edge.hpp
+++ b/ganv/Edge.hpp
@@ -77,6 +77,7 @@ public:
RW_PROPERTY(gboolean, selected)
RW_PROPERTY(gboolean, highlighted)
RW_PROPERTY(guint, color)
+ RW_PROPERTY(gdouble, handle_radius)
METHODRETWRAP0(ganv_edge, Node*, get_tail);
METHODRETWRAP0(ganv_edge, Node*, get_head);
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