Re: [fltk/fltk] Fluid: enhancement for widget_class for extra option: reposition-and-rescale (PR #481)
Albrecht Schlosser
Aug 14, 2022
@etorth Thank you very much for your test code and the description.
What I did (abstract):
I tested your code (.fl) with the original fluid and found the "bug" in your .fl file
I fixed your .fl file for usage with the original fluid
Conclusion
Hint: I propose to use the new Fl_Flex class as an alternative for what you likely wanted to achieve.
Details:
The "fault" in your .fl file is that you create the widget with another (smaller!) size than the designed size. Thus the second button appears outside the group which makes it "unclickable", as you already know (this is what your patch would change). Later resizing doesn't help, obviously.
The solution with the original fluid is to create the group in the exact size it was designed for and then resize it to the desired size. This looks a little confusing but it is a possible solution with the original fluid. No need to patch. Here is my working solution:
Except adding test statements I gave all the relevant widgets names (or renamed them): b1, b2, and tc (the test_widget_class instance). In the generated code you'll notice the following main changes (explained here by comments):
{ Test_widget_class* o = tc = newTest_widget_class(10, 25, 530, 35, "Test_widget_class");
// use "original" size of class (530 x 35) in constructor
tc->box(FL_UP_FRAME);
// ... some code elided ...Fl_Group::current()->resizable(tc);
// resize the widget to desired size (below):
o->size(325, 55);
} // Test_widget_class* tc
Conclusion: there is no need to patch fluid to do what you want to achieve. Admittedly, it would be "nice to have" to define a new class and to be able to create an instance in an arbitrary size and position. However, I'm not sure if fluid should be used to do it in the way you propose. I tend not to include your PR because it's not strictly necessary. However, I'm open for arguments.
That said, the new Fl_Flex widget can be used to achieve what you showed in your example. I copied your .fl file and modified it to use the new Fl_Flex class and derived my own flex class similar to what you did. The result is shown in an application that creates three flex instances (flex1, flex2, flex3) in different sizes. But note that Fl_Flex is brand-new and has no built-in fluid support yet. My fluid file is just a quick hack, it could maybe be done better and I hope that we will also get fluid support of Fl_Flex soon. Note that I made a design decision to make the buttons in two different widths (b1: 100, b2: 80) and the floating box in the middle gets the remaining size. Here is my fluid file that uses three instances of the class flex derived from Fl_Flex. Enjoy!
Finally, there's another "flexible" widget Fl_Grid I'm working on now which will give us even more flexibility in grouping widgets in rows and columns (i.e. in a grid) without strict pixel positions.
Final note: I did not test your patch/PR because I found a working solution. As said above, there's still room for discussion.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/pull/481/c1214401757@github.com>
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.