>
> This is how I visualize it:
>
> init_sizes() and Fl_Group's default resize behavior
> work together; init_sizes() "snapshots" the widget layout,
> 'caching' all the children's new positions in an internal array
> so that later, when the group is resized, Fl_Group's scaling
> algorithm can use those cached values to scale the widget's
> positions up and down, without accumulating precision loss.
..
>
> > Now, for MyGroup* my_group, my_group->child(0)->size(..)
> > should be followed by my_group->init_sizes(),
>
> ..only if you want the new position to be updated
> in the snapshot so that Fl_Group's automatic resize
> algorithm can take it into account.
..
That's a nice mental model, thanks. Unfortunately, actual
behavior doesn't seem to match it. At least not to me :)
For instance, look at this little demo. I'd have thought
that after moving the boxes apart in the program (without
taking a new snapshot) resizing the window would be based
on the prior coordinates. But that doesn't seem to be the
case. Am I missing something?
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl.H>
class DBox : public Fl_Box {
public:
DBox(int x, int y, int w, int h, char const* label = 0)
: Fl_Box(x, y, w, h, label)
{
box(FL_DOWN_BOX);
}
};
int main()
{
Fl_Double_Window win(200, 200);
DBox* bx1 = new DBox(50, 50, 50, 50);
DBox* bx2 = new DBox(100, 50, 50, 50);
DBox* bx3 = new DBox(50, 100, 50, 50);
DBox* bx4 = new DBox(100, 100, 50, 50);
win.end();
win.resizable(&win);
win.show();
bx1->position(bx1->x() - 10, bx1->y() - 10);
bx2->position(bx2->x() + 10, bx2->y() - 10);
bx3->position(bx3->x() - 10, bx3->y() + 10);
bx4->position(bx4->x() + 10, bx4->y() + 10);
// It doesn't seem to matter whether or not
// init_sizes is called here.
// win.init_sizes();
return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk