summaryrefslogtreecommitdiff
path: root/src/Fl_Tree_Item.cxx
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2014-09-05 02:59:00 +0000
committerGreg Ercolano <erco@seriss.com>2014-09-05 02:59:00 +0000
commitce1ab7e1ce58f33a0dc6e7dc883cfd6710e899e3 (patch)
treeabe32140045e230bedb5d7ec0be4565171566ec7 /src/Fl_Tree_Item.cxx
parent107fc50e48c96d3eca7980cdb227d8d22aad30a8 (diff)
Fixes to how new move() operations handle the concept
of 'above' and 'below' when referring to items instead of index positions. Small offsets needed due to how the arrays are scrolled after a move operation. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10272 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tree_Item.cxx')
-rw-r--r--src/Fl_Tree_Item.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Fl_Tree_Item.cxx b/src/Fl_Tree_Item.cxx
index a5ec92d27..8c68c2518 100644
--- a/src/Fl_Tree_Item.cxx
+++ b/src/Fl_Tree_Item.cxx
@@ -539,8 +539,11 @@ int Fl_Tree_Item::move(Fl_Tree_Item *item, int op, int pos) {
}
if ( !from_parent || !to_parent ) return -1;
if ( from < 0 || to < 0 ) return -2;
- if ( op == 1 ) to++; // 'below'? apply +1 offset for 'to'
if ( from_parent == to_parent ) { // same parent?
+ switch (op) { // 'to' offsets due to scroll
+ case 0: if ( from < to && to > 0 ) --to; break;
+ case 1: if ( from > to && to < to_parent->children() ) ++to; break;
+ }
if ( from_parent->move(to, from) < 0 ) // simple move among siblings
return -4;
} else { // different parent?