From 803140774eda264fbf7c872cd480558b4caa1275 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 5 Oct 2015 01:24:15 +0000 Subject: Highlight connected edges on port hover git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5745 a436a847-0d15-0410-975c-d299462d15a1 --- NEWS | 3 ++- ganv/edge.h | 6 ++++++ src/Canvas.cpp | 23 ++++++++++++++++++----- src/edge.c | 12 ++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 246b75c..ef05d94 100644 --- a/NEWS +++ b/NEWS @@ -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 Fri, 02 Oct 2015 21:08:24 -0400 + -- David Robillard 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) diff --git a/src/edge.c b/src/edge.c index 89da897..d3c96cc 100644 --- a/src/edge.c +++ b/src/edge.c @@ -688,6 +688,18 @@ ganv_edge_unselect(GanvEdge* edge) ganv_edge_set_selected(edge, FALSE); } +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) { -- cgit v1.2.1