Supporting complex layouts

294 views
Skip to first unread message

Kevin Ivarsen

unread,
Feb 23, 2015, 6:39:30 PM2/23/15
to eto-...@googlegroups.com
Hello,

I've been experimenting with Eto.Forms for a few days, and based on what I've seen so far it's quite an impressive technical achievement! I'm looking forward to getting some more experience with it.

One observation is that TableLayout seems to be missing a few things commonly found in table-based layout managers. For example:

1. Allowing a cell to span multiple rows or columns (as might be done with the RowSpan and ColumnSpan properties in a WinForms TableLayoutPanel)

2. Aligning a small control within a larger cell. TableLayout.AutoSize() effectively lets you do top-left and center alignment, but I haven't found a built-in way to do (for example) left-middle alignment.

Note 1: The wiki page on TableLayout references a TableLayout.Centered() helper, which doesn't seem to exist. However, TableLayout.AutoSized(..., centered: true) lets you accomplish something equivalent. Is this the intended behavior? If so, I can update the wiki.

Note 2: I've implemented trivial wrappers (based on TableLayout.AutoSized) for the 9 alignment options (TopLeft, MiddleLeft, BottomLeft, TopCenter, etc.) If these would be useful to include in Eto.Forms, I'd be happy to contribute them.

3. Setting proportional sizing weights to scaled rows/columns. Right now, extra weight is divided equally among rows/columns where "scale" is true. Are there limitations in some platforms that led to this being a boolean rather than a numeric weight?

I might be able to make some contributions to the layout code in Eto.Forms if there aren't already good methods for doing these things (or intentional reasons why they may not be implemented).

On another note: if I wanted to experiment with implementing other types of layout managers, would PixelLayout serve as a good foundation? This way you could implement the logic once (using PixelLayout to move and resize controls) and have it work across platforms rather than potentially having to wrap something different for each platform (such as the way that TableLayout uses TableLayoutPanel for the WinForms implementation, Gtk.Table for the GTK implementation, etc).


Thanks!
Kevin




curtis

unread,
Feb 25, 2015, 9:19:17 PM2/25/15
to eto-...@googlegroups.com
Hi Kevin,

You are correct there's still lots of work that can be done to make layouts more flexible with Eto.  Just recently I've implemented a StackLayout which should hopefully come in handy, especially for simple vertical or horizontal sets of controls.  However, it is still based on the existing TableLayout.  Hopefully these answers help:

1. This is on the radar, but I haven't got around to it yet.  The most difficult platform will probably be Mac since the table layout is entirely hand-coded. With the new Rows/Cells collections in 2.x, I want to also remove the arrays kept in each of the handlers to make them more lightweight. This is going to be needed soon for one of my projects, so I may be taking this on fairly soon.

2. You can use the TableLayout for this, but yeah having more helpers would be great.  The new VerticalAlignment/HorizontalAlignment enumerations might be a good way to do this without having to create a ton of helper classes.  E.g. TableLayout.AutoSize(myControl, HorizontalAlignment.Stretch, VerticalAlignment.Center).. we could then also depreciate the current AutoSize helper.

Yeah the wiki is wrong there, I didn't actually add the Centered helper.

3. I don't believe there are any limitations that will prevent this from being implemented.  I have often thought that this will be a great feature to implement, just hadn't got to it yet.

4. Yes, PixelLayout would be a great foundation for completely custom layouts.  It will probably be necessary to at expose the Control.GetPreferredSize() method, which is already implemented similarly on all platforms but could use some cleanup.  This way you can organize the controls based on their preferred sizes.  The first layout I thought would be great to have that would be implemented this way is something like a FlowLayout that wraps the controls.

All of your ideas are exactly what I envision Eto to have in the future, so I certainly welcome any contributions in that direction.  These would definitely make the layouts in Eto more robust and powerful.

Cheers!
Curtis.
Reply all
Reply to author
Forward
0 new messages