From 9a4ef219defa24e0db83dc5f22d01cf29e0a75bd Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Thu, 19 Jan 2012 12:44:26 +0000 Subject: Fl_Tree optimizations for selecting large trees (100k items). Added _next_sibling and _prev_sibling to Fl_Tree_Item class to make next_sibling() and prev_sibling() more efficient during item selection. Used new FLTK_ABI_VERSION macro (as designed by Greg and Albrecht on fltk.dev) to protect the ABI breaking features. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9231 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Tree_Item.H | 5 +++++ FL/Fl_Tree_Item_Array.H | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'FL') diff --git a/FL/Fl_Tree_Item.H b/FL/Fl_Tree_Item.H index a3b4e2cda..d090df1b6 100644 --- a/FL/Fl_Tree_Item.H +++ b/FL/Fl_Tree_Item.H @@ -69,6 +69,10 @@ class FL_EXPORT Fl_Tree_Item { Fl_Tree_Item_Array _children; // array of child items Fl_Tree_Item *_parent; // parent item (=0 if root) void *_userdata; // user data that can be associated with an item +#if FLTK_ABI_VERSION >= 10302 + Fl_Tree_Item *_prev_sibling; // previous sibling (same level) + Fl_Tree_Item *_next_sibling; // next sibling (same level) +#endif /*FLTK_ABI_VERSION*/ protected: void show_widgets(); void hide_widgets(); @@ -178,6 +182,7 @@ public: Fl_Tree_Item *next(); Fl_Tree_Item *next_sibling(); Fl_Tree_Item *prev_sibling(); + void update_prev_next(int index); Fl_Tree_Item *next_displayed(Fl_Tree_Prefs &prefs); Fl_Tree_Item *prev_displayed(Fl_Tree_Prefs &prefs); diff --git a/FL/Fl_Tree_Item_Array.H b/FL/Fl_Tree_Item_Array.H index 8bdf21afc..18527a8ef 100644 --- a/FL/Fl_Tree_Item_Array.H +++ b/FL/Fl_Tree_Item_Array.H @@ -5,6 +5,7 @@ #ifndef _FL_TREE_ITEM_ARRAY_H #define _FL_TREE_ITEM_ARRAY_H +#include #include "Fl_Export.H" class FL_EXPORT Fl_Tree_Item; // forward decl must *precede* first doxygen comment block @@ -66,11 +67,17 @@ public: return(_total); } /// Swap the two items at index positions \p ax and \p bx. +#if FLTK_ABI_VERSION >= 10302 + // NEW -- code moved to .cxx + void swap(int ax, int bx); +#else /*FLTK_ABI_VERSION*/ + // OLD void swap(int ax, int bx) { Fl_Tree_Item *asave = _items[ax]; _items[ax] = _items[bx]; _items[bx] = asave; } +#endif /*FLTK_ABI_VERSION*/ void clear(); void add(Fl_Tree_Item *val); void insert(int pos, Fl_Tree_Item *new_item); -- cgit v1.2.3