diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2018-07-26 15:12:31 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2018-07-26 15:13:13 +0100 |
commit | 42459f72c1f0e3dcdc1686447f1522c4fe9e3134 (patch) | |
tree | 9f8d8d755e99bc156e1ea65f10c32cb39ce37dfd /desktop | |
parent | 341cfc115b6a022ef9d3d9e8f909bdd4539f0f93 (diff) | |
download | netsurf-42459f72c1f0e3dcdc1686447f1522c4fe9e3134.tar.gz netsurf-42459f72c1f0e3dcdc1686447f1522c4fe9e3134.tar.bz2 |
Treeview: Allow dragging selection to a selected target.
This can be used to consolidate a scattered selection at
drop target when the the drop target happens to be part
of the selection.
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/treeview.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/desktop/treeview.c b/desktop/treeview.c index c44845ea7..48422e8e3 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -3030,6 +3030,7 @@ struct treeview_selection_walk_data { } drag; struct { treeview_node *prev; + treeview_node *fixed; } yank; struct { treeview_node *n; @@ -3132,6 +3133,10 @@ treeview_node_selection_walk_cb(treeview_node *n, treeview_node *p = n->parent; int h = 0; + if (n == sw->data.yank.fixed) { + break; + } + if (treeview_unlink_node(n)) h = n->height; @@ -3361,13 +3366,15 @@ static void treeview_commit_selection_drag(treeview *tree) /** * Yank a selection to the node move list. * - * \param tree Treeview object to yank selection from + * \param tree Treeview object to yank selection from + * \param fixed Treeview node that should not be yanked */ -static void treeview_move_yank_selection(treeview *tree) +static void treeview_move_yank_selection(treeview *tree, treeview_node *fixed) { struct treeview_selection_walk_data sw; sw.purpose = TREEVIEW_WALK_YANK_SELECTION; + sw.data.yank.fixed = fixed; sw.data.yank.prev = NULL; sw.tree = tree; @@ -3541,16 +3548,17 @@ static nserror treeview_move_selection(treeview *tree, struct rect *rect) parent = relation->parent; } - /* The node that we're moving selection to can't itself be selected */ - assert(!(relation->flags & TV_NFLAGS_SELECTED)); - /* Move all selected nodes from treeview to tree->move.root */ - treeview_move_yank_selection(tree); + treeview_move_yank_selection(tree, relation); /* Move all nodes on tree->move.root to target location */ for (node = tree->move.root; node != NULL; node = next) { next = node->next_sib; + if (node == relation) { + continue; + } + if (!(parent->flags & TV_NFLAGS_EXPANDED)) { if (node->flags & TV_NFLAGS_EXPANDED) treeview_node_contract_internal(tree, node); |