Author: greg.ercolano
Date: 2011-12-06 13:08:07 -0800 (Tue, 06 Dec 2011)
New Revision: 9197
Log:
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)


Modified:
   branches/branch-1.3/FL/Fl_Tree.H
   branches/branch-1.3/src/Fl_Tree.cxx

Modified: branches/branch-1.3/FL/Fl_Tree.H
===================================================================
--- branches/branch-1.3/FL/Fl_Tree.H    2011-12-06 16:55:51 UTC (rev 9196)
+++ branches/branch-1.3/FL/Fl_Tree.H    2011-12-06 21:08:07 UTC (rev 9197)
@@ -199,6 +199,8 @@
   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);

Modified: branches/branch-1.3/src/Fl_Tree.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Tree.cxx 2011-12-06 16:55:51 UTC (rev 9196)
+++ branches/branch-1.3/src/Fl_Tree.cxx 2011-12-06 21:08:07 UTC (rev 9197)
@@ -329,6 +329,7 @@
 
 /// 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 @@
       _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 @@
   }
 }
 
+/// 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$".
 //

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to