From 80ef97d123f9d5fa086844398f55c97d5613b8a3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 May 2012 04:27:08 +0000 Subject: Fix node selection so setting "selected" property does the right thing. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4369 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 10 +++++----- src/node.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 9ab4304..fb42192 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -1350,16 +1350,16 @@ GanvCanvasImpl::clear_selection() { unselect_ports(); - FOREACH_ITEM(_selected_items, i) { + Items items(_selected_items); + _selected_items.clear(); + FOREACH_ITEM(items, i) { ganv_item_set(GANV_ITEM(*i), "selected", FALSE, NULL); } - FOREACH_SELECTED_EDGE(_selected_edges, c) { + SelectedEdges edges(_selected_edges); + FOREACH_SELECTED_EDGE(edges, c) { ganv_item_set(GANV_ITEM(*c), "selected", FALSE, NULL); } - - _selected_items.clear(); - _selected_edges.clear(); } void diff --git a/src/node.c b/src/node.c index 0a885c3..85415d8 100644 --- a/src/node.c +++ b/src/node.c @@ -139,9 +139,21 @@ ganv_node_set_property(GObject* object, SET_CASE(BORDER_COLOR, uint, impl->border_color); SET_CASE(CAN_TAIL, boolean, impl->can_tail); SET_CASE(CAN_HEAD, boolean, impl->can_head); - SET_CASE(SELECTED, boolean, impl->selected); SET_CASE(HIGHLIGHTED, boolean, impl->highlighted); SET_CASE(DRAGGABLE, boolean, impl->draggable); + case PROP_SELECTED: + if (impl->selected != g_value_get_boolean(value)) { + impl->selected = g_value_get_boolean(value); + if (item->canvas) { + if (impl->selected) { + ganv_canvas_select_node(GANV_CANVAS(item->canvas), node); + } else { + ganv_canvas_unselect_node(GANV_CANVAS(item->canvas), node); + } + ganv_item_request_update(item); + } + } + break; case PROP_CANVAS: if (!item->parent) { GanvCanvasBase* canvas = GANV_CANVAS_BASE(g_value_get_object(value)); -- cgit v1.2.1