diff options
| author | Greg Ercolano <erco@seriss.com> | 2012-04-18 15:20:20 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2012-04-18 15:20:20 +0000 |
| commit | c7044ca0097432fad31f7e525f7d17a63ab5bd29 (patch) | |
| tree | 6cc5f90100c879a2fe436424f61977cac28f58c8 /src/Fl_Tree.cxx | |
| parent | d741da43175f7544ca090a240620a0bcafb9bc60 (diff) | |
Optimizations for when Fl_Tree is a container of FLTK widgets.
o Don't draw FLTK widgets outside tree's viewport.
o Added tree-as-container.cxx example program, demos tree
w/50k tree items each with 6 widgets (300k total)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9356 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Tree.cxx')
| -rw-r--r-- | src/Fl_Tree.cxx | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index 6dae729aa..b058df055 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -125,6 +125,7 @@ Fl_Tree::~Fl_Tree() { /// Standard FLTK event handler for this widget. int Fl_Tree::handle(int e) { + if (e == FL_NO_EVENT) return(0); // XXX: optimize to prevent slow resizes on large trees! int ret = 0; // Developer note: Fl_Browser_::handle() used for reference here.. // #include <FL/names.h> // for event debugging @@ -400,7 +401,26 @@ void Fl_Tree::draw() { } // Draw children fl_push_clip(cx,cy,cw-(_vscroll->visible()?_vscroll->w():0),ch); - Fl_Group::draw_children(); // draws any FLTK children set via Fl_Tree::widget() + // Similar to Fl_Group::draw(), but optimized to ignore drawing + // items outside the viewport. + // TODO: Suggest Fl_Group::draw() do this if clip_children() is enabled. + { + Fl_Widget*const* a = Fl_Group::array(); + if (damage() & ~FL_DAMAGE_CHILD) { // redraw the entire thing: + for (int i=Fl_Group::children(); i--;) { + Fl_Widget& o = **a++; + if ( (o.y()+o.h()) < y() || (o.y() > (y()+h())) ) continue; + Fl_Group::draw_child(o); + Fl_Group::draw_outside_label(o); + } + } else { // only redraw the children that need it: + for (int i=Fl_Group::children(); i--;) { + Fl_Widget& o = **a++; + if ( (o.y()+o.h()) < y() || (o.y() > (y()+h())) ) continue; + Fl_Group::update_child(o); + } + } + } fl_pop_clip(); draw_child(*_vscroll); // draw scroll last } |
