Hi,
still on FLTK testing...
First point, I try to use a bug FL_Tree (10000).
On my computer, it's almost unusable and the real time will be at least 27000 
(the number of testcase/testgroup in my nunit code)

when I check the Fl_Tree code (and Fl_Tree_Item), the max value of the Valuator 
is computed each time something happen to the Fl_Tree...
Strange since only add/remove/collapse/expand (may be missing one or two).
The H value is passed by reference and the tree item H is added recursively 
even if the tree item is not visible (breaking the recursion when a tre item is 
not visible anymore help a lot).
I have done a same patch (who solve the performance issue) but reverted due to 
some bug on the scroll display (Still beginner on FLTK sorry).

Second point, in my sample below, on tree full expanded, when positioning at 
the end of the tree item list (scroll at the max down position) and clicking to 
collapse all, the scroll bar is not recomputed, and stay at the end, so the 
tree seems empty. We had to move it manually up to resize the valuator and see 
the items.

PS: I did not succeed not using a Fl_Windon for the button container, else, 
there is some unclean drawing that stay if a move the tile left and right... 
(it happens using a simple Fl_Group for example).

Here my code...


#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Tree.H>
#include <FL/Fl_Tile.H>

#include <vector>
#include <string>
#include <sstream>

using namespace std;

Fl_Tree* tree = 0;

void generateTree(size_t s, vector<string>& tree) {
    for ( size_t i = 0;  tree.size() < s; ++i )
        for ( size_t j = 0; j < s * 5 / 100; ++j ) {
            ostringstream oss; oss << i << "/" << j;
            tree.push_back( oss.str() );
        }
}

void expandAllCb(Fl_Widget *, void *p) {
  Fl_Tree_Item* root = tree->root();
  for ( int i = 0; i < root->children(); ++i )
      p?root->child(i)->open():root->child(i)->close();
  tree->redraw();
}

int main() {
    vector<string> testGroups; generateTree(10000,testGroups);

    Fl_Double_Window w(800,600, "CPP Unit Test Log Parser");
    w.resizable(w);
        Fl_Tile tile( 0, 0, w.w(), w.h() );
        Fl_Group g(0,0, tile.w()/2, tile.h());
        tree = new Fl_Tree(0, 0, g.w(), g.h()-20, "Unit Tests");
            Fl_Window g2(0,tree->y()+tree->h(), g.w(), g.h()-tree->h());
                Fl_Button buttonCollapse(0, 0, 150, 20, "Collapse All");
                buttonCollapse.callback(expandAllCb, (void*)false);
                Fl_Button buttonExpandAll(170, 0, 150, 20, "Expand All");
                buttonExpandAll.callback(expandAllCb, (void*)true);
            g2.end();
        g.resizable(tree);
        g.end();
        tile.end();
    w.end();

    tree->showroot(false);

    for( vector<string>::const_iterator g = testGroups.begin();
        g != testGroups.end(); ++g )
        tree->add( g->c_str() );

    w.show();
    return Fl::run();
}

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

Reply via email to