________________ _________ ________________
| | | | | |
| Box A | | Box B | | Box C |
|________________| |_________| |________________|
The goal is to have boxes A and C horizontally stretch
to fit the window during resizing,
and Box B remains a fixed width and centered.
I've thought about this a bit and can't think of a way to do it
other than to overload resize()
and do it with code, but would like to use FLTK's resizing
abilities if it's possible.
[..]
I could see making a fully flexible packing widget like an HTML table..
I should probably review this TableBox widget
in our Links pages, which sounds like it's exactly that:
|
TableBoxThe TableBox manages a group of widgets that are arranged in rows and columns, making it easy to align many widgets next to each other, horizontally and vertically. The size of a table can be changed using the Size() method. Widgets can be added to a table using the Attach() method. The gaps between all rows or columns can be changed by calling the Gap() method. Supports both row and column expanding, filling, spanning and aligning in both X and Y directions. The whole project was inspired by HTML table and GTK+ table widget. |
---|
If you want padding between the boxes I suggest to add another group
around box C and make box C the resizable in this box. If I understood
you correctly.
See attached r2a.cxx with my solution (again, if that's what you wanted
to achieve). The groups are now colored (red and green). I'm aware that
the padding is not equal everywhere but I'm leaving this as an exercise
to the reader. ;-)
On 2020-11-20 16:10, Greg Ercolano wrote:
I could see making a fully flexible packing widget like an HTML table..
I should probably review this TableBox widget in our Links pages, which sounds like it's exactly that..
TableBox
The TableBox manages a group of widgets that are arranged in rows and columns, making it easy to align many widgets next to each other [..]The whole project was inspired by HTML table and GTK+ table widget.
I did research that a bit; unfortunately that widget is fltk2.
I was unable to get the old fltk2 project to build on
my machine, so I couldn't explore it.
But I did make a very rough
port that works with fltk 1.x, tossing the result on github
in case anyone wants to try to fix it/take it further with a
fork.
The TableBox demo in my port runs and very interesting
resizing behavior happens, but I don't
think I got it fully working as intended. I can't remember
fully how fltk2's layout() system
worked, so it could be a problem with how I ported that.
I think layout() was called on first drawing to
reposition/size the widgets, and then
Ialso called during any kind of resize(). I emulated that
in the port, since TableBox
overloads layout() to do its work, but not sure I got all
that right; didn't have time
to really dig in.
See attached r2a.cxx with my solution (again, if that's what you wanted
to achieve). The groups are now colored (red and green). I'm aware that
the padding is not equal everywhere but I'm leaving this as an exercise
to the reader. ;-)
TableBox
The TableBox manages a group of widgets that are arranged in rows and columns, making it easy to align many widgets next to each other [..]The whole project was inspired by HTML table and GTK+ table widget.
[..] I did make a very rough port that works with fltk 1.x, tossing the result on github
in case anyone wants to try to fix it/take it further with a fork.
The TableBox demo in my port runs and very interesting resizing behavior happens, but I don't
think I got it fully working as intended.
Followup: played around with that code a bit more and got it
working more like intended I think.
Seems interesting and perhaps worth persuing as a widget to
add to FLTK; it's pretty "small+light".
The original author posted it as GPL v2 though, which might be
a problem for FLTK inclusion unless
we can get the author's OK to allow its inclusion in fltk,
otherwise a complete rewrite could be done
I suppose..
The attached files can be dropped into the test directory and compiledwith fltk-config, and are in the style of the existing resize examples.
Hmm, I'm not sure what "as expected" is in this case. However, WRT
padding I think you missed to make the C box the resizable() widget. I
added at line ~64 in resize-example5b.cxx:
m_groupR->end();
+ m_groupR->resizable(m_boxC);
So given your recent r.cxx (Nov 21 2020), I ended up with this to
rough out the cube.cxx application issue #157, including
symmetrical horizontal margins:
Ascii art in the code describes the arrangements.
Thanks everyone!