|
|
FWIW, +1 for me (always seemed strange to only allow one widget to be resizable), but if you do that then you can consolidate Fl_Pack, Fl_Flex, and Fl_Tile - a non-resizable widget just gets stacked/packed while a resizable one fills the remainder. If two resizable widgets border each other then you can drag the border to resize.
> On Oct 26, 2022, at 6:21 AM, 'melcher....@googlemail.com' via fltk.coredev <fltkcoredev@googlegroups.com> wrote:
>
> 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.
________________________
Michael Sweet
--
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/146B10AB-4969-45D9-916F-BE0EA2A5AAF9%40gmail.com.
[ Direct Link to Message ] | |
|
| |