Hi! Certainly fltk needs this. However I don't like redundancy in the data. It would be really nice if a single "layout" object can be shared by many groups, as actual widget pointers are stored in the group.
The group necessarily has a complete ordered list of widgets (though the order also controls stacking order and left/right arrow navigation). In addition the widgets themselves have a current position & size and they can have a couple flags on them. It also has the "resizable" pointer to a single child widget. Currently fltk2 tries to set the layout type by using subclasses of Group. An example is the fltk/BarGroup in fltk2 which uses the resizable pointer to indicate the center widget. The order of the widgets determines how they go against the edges. The "resizable" pointer indicates the "center" widget, all before that go on the top/left edges, all after go on the bottom/right edges. A "horizontal" flag on the widgets determines if they go on the top/bottom or left/right edges. There are also AlignGroup, the plain Group, PackedGroup, StatusBarGroup, TiledGroup, and ScrollGroup. Perhaps also the Tab and Wizard group. I'm pretty certain that setting a layout-type pointer on Group would be better than subclasses. In particular you cannot set the layout type of fltk::Window. One important thing in fltk and not in Qt is that layout must be deferred until drawing. Layout is very expensive, perhaps more so than drawing (on modern systems measuring fonts takes longer than drawing them). If a widget thinks it's size needs to change then it sets a flag saying layout is needed. This will recursively set it on all parents. Later on the layout() method is called, and at that point the widget actually forces itself to the size it wants. The huge missing part of fltk2 is a way for a widget to indicate it's minimum or preferred size. My intention was to allow layout() to set the size to the desired one. But I now don't think that will work. Better would be a virtual desired-size call that layout() that returns the size a widget wants, without changing anything. So here is what I would like to see: 1. fltk::Group has a pointer to a Layout object. 2. Layout object can be shared between multiple fltk::Group. This means it does not have any pointers to Widgets. "special" widgets must be identified by their position in the Group's list, by the "resizable" Group pointer, or by flags on the widgets or in the widget style, or otherwise by examining the widgets such as using rtti or looking at the label. 3. A new virtual function returns a widget's desired dimensions. Groups will ask the Layout object to implement this, and they will work by recursively calling this on the child widgets. 4. The layout() virtual function takes no arguments. It is called just before draw() on widgets with the layout flag set, and then the flag is cleared. This is not allowed to change this widgets size or position, but it can change child sizes and positions (layout() will be called on them later). It is also possible that layout() can be scrapped, instead draw() should do the work if the layout flag is set (this is how old fltk worked). On 03/29/2011 08:08 PM, Brian wrote: > Just thought I'd post that I put up a preliminary package of freeflow layout > stuff for fltk2. I posted it a couple of weeks ago to fltk.org as a package > but > thought I'd also announce it here. _______________________________________________ fltk-dev mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-dev
