I'm using FLTK for a project (the version distributed with Debian/sid 1.3.2-6+b1) and I'm having some trouble initializing Fl_Scroll
's content scroll values.
I create a Fl_Double_Window
and on the right side a vertical panel using Fl_Scroll
, it is positioned at left x 600 and top y 24.
Then I set Fl_Scroll
's type to Fl_Scroll::VERTICAL
and place a Fl_Button
inside, everything works fine.
The problem? Fl_Scroll
initialize already scrolled with xposition() = 600
and yposition() = 24
(X and Y of the Fl_Scroll's constructor?? Is supposed to work so?), instead I want it to initialize with content scrolled at left and top 0, 0
, so I tried scroll_to()
in different places, before and after window's show()
, on FL_SHOW
of the subclassed Fl_Scroll
(I didn't really need to subclass Fl_Scroll
, just trying to get scroll_to()
working), also on overridden draw()
after
the parent draw()
, even creating Fl_Scroll
at 0, 0 then position()
at 600, 24, but nothing.
The only way I got scroll_to()
working is if I call it from an async event after the application initialize (FL_KEYUP
).
Here's the overridden Fl_Double_Window window constructor:
group = new Fl_Group(0, 0, WIN_W, WIN_H);
{
menu = new Fl_Menu_Bar(0, 0, WIN_W, MENU_H);
menu->add("File/Quit", FL_CTRL+'q', cbMenuQuit_i);
glview = new CGLView(0, MENU_H, WIN_W-PROPS_W+1, WIN_H-MENU_H);
group->resizable(glview);
scroll = new CScroll(WIN_W-PROPS_W, MENU_H, PROPS_W-1, WIN_H-MENU_H);
scroll->type(Fl_Scroll::VERTICAL);
{
Fl_Pack *pack = new Fl_Pack(0, 0, PROPS_W-1, WIN_H-1);
{
btnAddLayer = new Fl_Button(0, 0, PROPS_W, 32, "@#+ Add Layer");
btnAddLayer->callback(btnAddLayerCb_i, (void *)this);
}
pack->end();
}
scroll->end();
}
group->end();
end();
size_range(WIN_MIN_W, WIN_MIN_H); /* Make the window resizable */
show();