|
|
tl;dr Proposal to add Fl_Widget::resizable(int width_factor, int height_factor) and merge Fl_Flex into Fl_Pack.
I was looking into how Fl_Flex differs from Fl_Pack, and apart from the margins, Fl_Flex adds the option the make individual children resizable while the rest stays fixed. So instead of introducing a new widget, wouldn't it be better to add this functionality to Fl_Pack?
Which brings me to the second point. Fl_Group::resizable(Fl_Widget*) is a horrible interface. First of all, we reference a child widget, wich may disappear, giving us a dangling pointer. Second of all, we can only have one resizable child, which generated the need for Fl_Flex.
Now, Fl_Flex maintains a list of children that are resizable, and the list is not updated if children are removed because Fl_Group::remove() and clear() are not virtual (delete_child() is, but that is not enough). Again, we get dangling pointers.
My proposal is to remove Fl_Group::resizable_ and instead add either a flag or an integer to Fl_Widget to indicate if the widget is resizable (flag) or even better, by what factor a widget is resizable (int). Adding the functionality of Fl_Flex to Fl_Pack would be ten lines of code. Fl_Group::resizable(Fl_Widget*) could be implemented with the exact same API and functionality, but without the risk of dangling pointers.
Since the resizable() method name is already taken, we need a new method name. We could use Fl_Widget::flexible(bool), but how about Fl_Widget::resizable(int width, int height) where width and height are factors in the given direction. It's a bit of a stretch, as Fl_Group::resizable(child) would be the same as child->resizable(100, 100), but it can't all be perfect. This would add two integers, eight bytes, to every Fl_Widget, and remove one pointer from Fl_Group and more pointers from Fl_Pack/Fl_Flex.
--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/acfad3a8-6dfd-4777-9362-624e71c62361n%40googlegroups.com.
[ Direct Link to Message ] | |
|
| |