Stan wrote:
> I guess it's the concept of changing things "yourself" that I'm
> trying to get my mind around.  Can I conclude that init_sizes()
> needs to be called (only) after calling resize (or one of its cousins)
> on a group member, from outside the execution context of the group's
> resize method?

        Right.

> For instance, suppose I've derived MyGroup from Fl_Group,
> and implemented its resize() method.

        Hmm, if you're redefining the resize behavior
        of the group, then it's your option to either:

                a) completely redefine the resize behavior,
                   and never call Fl_Group::resize(),
                   in which case calling init_sizes() becomes moot.

                - or -

                b) 'slightly modify' the resize behavior,
                   while still depending on Fl_Group::resize()'s
                   algorithm to manage the child positions.

        In the case of (a), calling init_sizes() becomes
        totally moot; init_sizes() takes a "snapshot" of the
        children's current widget positions. This snapshot
        is used by Fl_Group::resize()'s algorithm to calculate
        the new widget positions when the group is scaled up
        and down.

        If you never call Fl_Group::resize(), then the snapshot
        that init_sizes() grabs will never be used.

        In the case of (b), you probably would want to call
        init_sizes() after moving things around, so that if
        you later call Fl_Group::resize(), its scaling algorithm
        will take into account the new position tweaks you made.

        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.

        Consider the extreme case where the Fl_Group is scaled
        all the way down to a single pixel, such that all the
        children have their x/y/w/h values scaled to a single value.

        When the group is scaled back up, if not for the snapshot
        of the original widget positions, there'd be no way
        to recover the original widget layout.

> 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.

        You may or might not want that, depends on what
        you're doing.

> but my_group->resize(..) should not be,

        Yes, I don't think you'd want to follow a call to
        the group's resize() with init_sizes(), otherwise you'd
        be defeating the purpose of the single layout snapshot,
        and promoting the accumulation of precision loss.

        The above described 'extreme case' becomes relevant here;
        when the group is scaled down to a single pixel, if you
        then call init_sizes(), you've now lost the widget's original
        layout completely. When the group is scaled back up, there's
        no way to recover the original layout; the widgets would all
        remain crunched together.

        HTH.

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

Reply via email to