From ce1ab7e1ce58f33a0dc6e7dc883cfd6710e899e3 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Fri, 5 Sep 2014 02:59:00 +0000 Subject: 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 --- src/Fl_Tree_Item.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/Fl_Tree_Item.cxx') 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? -- cgit v1.2.3