diff options
| author | Greg Ercolano <erco@seriss.com> | 2011-12-06 21:08:07 +0000 |
|---|---|---|
| committer | Greg Ercolano <erco@seriss.com> | 2011-12-06 21:08:07 +0000 |
| commit | 272475dde48e43c4b19799847c5ca3937eeceae3 (patch) | |
| tree | 22c13b4f118389268589c2c6abc5c349a245f835 | |
| parent | d250e21542818846c8a2cbd9b04e67b099eb05ce (diff) | |
Fixing STR #2786; clipping problem with child FLTK widgets.
Replication: Run 'tree' demo, open '500 items' subtree, change 'connector width' to 100..
the "D2" and "ccc" buttons would overdraw the scrollbar. (Not the regular tree items)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9197 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | FL/Fl_Tree.H | 2 | ||||
| -rw-r--r-- | src/Fl_Tree.cxx | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/FL/Fl_Tree.H b/FL/Fl_Tree.H index d6f7bc1b2..7a9111114 100644 --- a/FL/Fl_Tree.H +++ b/FL/Fl_Tree.H @@ -199,6 +199,8 @@ class FL_EXPORT Fl_Tree : public Fl_Group { Fl_Tree_Prefs _prefs; // all the tree's settings int _scrollbar_size; // size of scrollbar trough + void fix_scrollbar_order(); + protected: Fl_Scrollbar *_vscroll; ///< Vertical scrollbar void item_clicked(Fl_Tree_Item* val); diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index fa78940a1..d70b5539f 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -329,6 +329,7 @@ int Fl_Tree::handle(int e) { /// Standard FLTK draw() method, handles draws the tree widget. void Fl_Tree::draw() { + fix_scrollbar_order(); // Let group draw box+label but *NOT* children. // We handle drawing children ourselves by calling each item's draw() // @@ -381,9 +382,11 @@ void Fl_Tree::draw() { _vscroll->hide(); } } - fl_push_clip(cx,cy,cw,ch); + // 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() fl_pop_clip(); + draw_child(*_vscroll); // draw scroll last } /// Print the tree as 'ascii art' to stdout. @@ -1758,6 +1761,18 @@ void Fl_Tree::load(Fl_Preferences &prefs) } } +/// Ensure the scrollbars are the last children +void Fl_Tree::fix_scrollbar_order() { + Fl_Widget** a = (Fl_Widget**)array(); + if (a[children()-1] != _vscroll) { + int i,j; + for (i = j = 0; j < children(); j++) { + if (a[j] != _vscroll) a[i++] = a[j]; + } + a[i++] = _vscroll; + } +} + // // End of "$Id$". // |
