diff options
author | David Robillard <d@drobilla.net> | 2015-10-05 01:24:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-10-05 01:24:15 +0000 |
commit | 803140774eda264fbf7c872cd480558b4caa1275 (patch) | |
tree | 7feed762ebc3674d6c45034ca944ccdd155e8352 | |
parent | db0a582cff8b17c41d3bac0068e69cbbf7752666 (diff) | |
download | ganv-803140774eda264fbf7c872cd480558b4caa1275.tar.gz ganv-803140774eda264fbf7c872cd480558b4caa1275.tar.bz2 ganv-803140774eda264fbf7c872cd480558b4caa1275.zip |
Highlight connected edges on port hover
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5745 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ganv/edge.h | 6 | ||||
-rw-r--r-- | src/Canvas.cpp | 23 | ||||
-rw-r--r-- | src/edge.c | 12 |
4 files changed, 38 insertions, 6 deletions
@@ -5,6 +5,7 @@ ganv (1.4.3) unstable; * Preserve selection for quickly making several connections. * Dampen sprung layout energy over time to prevent oscillation. * Distinguish edge color from port color slighly. + * Highlight connected edges on port hover. * Add support for PDF and PS export. * Improve text rendering at high zoom. * Improve appearance of graphs with circle nodes. @@ -17,7 +18,7 @@ ganv (1.4.3) unstable; * Fix crash when destroying canvas. * Upgrade to waf 1.8.14 - -- David Robillard <d@drobilla.net> Fri, 02 Oct 2015 21:08:24 -0400 + -- David Robillard <d@drobilla.net> Sun, 04 Oct 2015 21:23:59 -0400 ganv (1.4.2) stable; diff --git a/ganv/edge.h b/ganv/edge.h index 46816f6..72b4105 100644 --- a/ganv/edge.h +++ b/ganv/edge.h @@ -77,6 +77,12 @@ ganv_edge_select(GanvEdge* edge); void ganv_edge_unselect(GanvEdge* edge); +void +ganv_edge_highlight(GanvEdge* edge); + +void +ganv_edge_unhighlight(GanvEdge* edge); + /** * ganv_edge_disconnect: * diff --git a/src/Canvas.cpp b/src/Canvas.cpp index a30657b..3c59351 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -333,6 +333,7 @@ struct GanvCanvasImpl { void ports_joined(GanvPort* port1, GanvPort* port2); void port_clicked(GdkEvent* event, GanvPort* port); + void highlight_port(GanvPort* port, bool highlight); void move_contents_to_internal(double x, double y, double min_x, double min_y); @@ -1418,7 +1419,7 @@ void GanvCanvasImpl::end_connect_drag() { if (_connect_port) { - g_object_set(G_OBJECT(_connect_port), "highlighted", FALSE, NULL); + highlight_port(_connect_port, false); } gtk_object_destroy(GTK_OBJECT(_drag_edge)); gtk_object_destroy(GTK_OBJECT(_drag_node)); @@ -1557,7 +1558,7 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port) gboolean selected; g_object_get(G_OBJECT(port), "selected", &selected, NULL); if (!control_dragging && !selected) { - g_object_set(G_OBJECT(port), "highlighted", TRUE, NULL); + highlight_port(port, true); return true; } break; @@ -1574,7 +1575,7 @@ GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port) NULL, event->crossing.time); return true; } else if (!control_dragging) { - g_object_set(G_OBJECT(port), "highlighted", FALSE, NULL); + highlight_port(port, false); return true; } break; @@ -1594,8 +1595,8 @@ GanvCanvasImpl::ports_joined(GanvPort* port1, GanvPort* port2) return; } - g_object_set(G_OBJECT(port1), "highlighted", FALSE, NULL); - g_object_set(G_OBJECT(port2), "highlighted", FALSE, NULL); + highlight_port(port1, false); + highlight_port(port2, false); GanvNode* src_node; GanvNode* dst_node; @@ -1631,6 +1632,18 @@ GanvCanvasImpl::port_clicked(GdkEvent* event, GanvPort* port) } } +void +GanvCanvasImpl::highlight_port(GanvPort* port, bool highlight) +{ + g_object_set(G_OBJECT(port), "highlighted", highlight, NULL); + ganv_canvas_for_each_edge_on(_gcanvas, + GANV_NODE(port), + (highlight + ? (GanvEdgeFunc)ganv_edge_highlight + : (GanvEdgeFunc)ganv_edge_unhighlight), + NULL); +} + /* Update animated "rubber band" selection effect. */ gboolean GanvCanvasImpl::on_animate_timeout(gpointer data) @@ -689,6 +689,18 @@ ganv_edge_unselect(GanvEdge* edge) } void +ganv_edge_highlight(GanvEdge* edge) +{ + ganv_edge_set_highlighted(edge, TRUE); +} + +void +ganv_edge_unhighlight(GanvEdge* edge) +{ + ganv_edge_set_highlighted(edge, FALSE); +} + +void ganv_edge_set_highlighted(GanvEdge* edge, gboolean highlighted) { edge->impl->highlighted = highlighted; |