On 04/20/13 14:04, dirac wrote:
> Hi guys,
> 
> I'm building a stack of horizontal widgets, like that (I hope the ASCII
> art works):
> 
> +---Fl_tile-------------------+
> | +-------------------------+ |
> | | widget 0                | |
> | +-------------------------+ |
> | +-------------------------+ |
> | | widget 1                | |
> | +-------------------------+ |
> | +-------------------------+ |
> | | widget 2                | |
> | +-------------------------+ |
> |+----------------------------+
> 
> I would like to make each widget vertically resizable, so an Fl_tile
> seems a good choice for a container.
> Unfortunately I've noticed that Fl_tile shrinks the other widgets: for
> example if I enlarge Widget 0 completely to the very bottom, "widget 1"
> and "widget 2" disappear, i.e. their height becomes zero.
> 
> My question: is there a way to extend Fl_tile so that it shifts the
> other widgets below Widget 0, instead of shrink them? Possibly Fl_tile
> should also expand itself vertically to make room for the other widgets.

        I made one of these once; in my case I didn't use a tile,
        just used a regular Fl_Group in which the widgets were positioned,
        and put a thin widget between each that acted as a 'resizer' which:

                1) enlarged/shrunk the widget above it
                2) enlarged/shrunk the parent group
                3) moved all the children below it up/down

        The resizer class responded to FL_MOVE so that the cursor would
        turn into a "north/south" cursor, and responded to FL_DRAG to handle
        dragging. So basically:

> +---Fl_tile-------------------+
> | +-------------------------+ |
> | |                         | |
> | | widget 0                | |
> | |                         | |
> | +-------------------------+ |
> | |         resizer         | |
> | +-------------------------+ |
> | |                         | |
> | | widget 1                | |
> | |                         | |
> | +-------------------------+ |
> | |         resizer         | |
> | +-------------------------+ |
> | |                         | |
> | | widget 2                | |
> | |                         | |
> | +-------------------------+ |
> +-----------------------------+

        You can either have resizer make assumptions about parent() being
        an Fl_Group and assume all widgets within that parent are inspected
        to see if the widgets are above or below the current 'resizer' being
        moved, so that only the widget immediately above is resized, and widgets
        below are moved, and all the other child widgets are left alone.
        Then just call the parent's init_sizes() to let it know the children
        have changed size.

        I suppose you could then put this entire group inside an Fl_Scroll, so
        that if the children resize off the screen, a scroller will appear..
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to