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 /src | |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/Canvas.cpp | 23 | ||||
-rw-r--r-- | src/edge.c | 12 |
2 files changed, 30 insertions, 5 deletions
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; |