Hi
I have read a lot of threads talking about how to correctly position widgets 
inside an Fl_Scroll and no matter how much I try I just can't solve my problem:

I have an Fl_Scroll with a vertical Fl_Pack inside full of buttons groups and 
other widgets.
The Fl_Scroll is cleared every once in a while and the contents get re-added 
dynamically. It works great except that if the scroll was scrolled down to a 
certain position before clearing it I would like it to be in the same position 
after the contents was re-added.

The solution seemed quite straight forward:
1. Save the scroll position
2. Clear the Fl_Scroll
3. Recreate the contents of the scroll
4. call Fl_Scroll->position with saved values


In code:
///////////////////////////////////////////////////
int prevScrollY=bottomPaneScroll->yposition();
int prevScrollX=bottomPaneScroll->xposition();

bottomPaneScroll->clear()
Fl_Pack *pliPacker = new Fl_Pack(bottomPaneScroll->x(), menuBar->h(), 
bottomPaneScroll->w()-30, 1)
..
widgets are added... groups are ended etc...
..
bottomPaneScroll->init_sizes();
Fl::check();
bottomPaneScroll->position(prevScrollX,prevScrollY);
bottomPaneScroll->redraw();
/////////////////////////////////////////////////


However, this simply does not work, the scroll bar always resets to the top 
(with a strange size that is not correct until it is scrolled all the way down 
and all the way up again).

I have attempted several things, like creating the Fl_Pack with it's 'y' 
constructor parameter set to the saved Y position, but that positions the pack 
shifted down... logic and the forums says that I should position the pack by 
substracting the saved Y position, so I create the pack like this:
Fl_Pack *pliPacker = new Fl_Pack(bottomPaneScroll->x(), 
menuBar->h()-prevScrollY, bottomPaneScroll->w()-30, 1)

This seems right, except that I think clipping is occurring and the pack is not 
drawn until I scroll all the way up again.

The first method (calling the saved position after recreating the scroll) 
seemed like one way to go...
The second method (building the Fl_Pack offset by the saved position) seemed 
like another way to go...

Any ideas on how to fix this?

Thankyou in advance
Daniel Gollás





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

Reply via email to