Re: align vs expand vs grid



On Thu, May 12, 2011 at 9:53 PM, Benjamin Otte <otte gnome org> wrote:
> Hey,
>
> I've had an interesting discussion that has so far involved Matthias
> and Alex about align and expand flags and about GtkGrid's involvement
> in it[1]. This discussion is mostly academic in that it should never
> appear in the real world. People should set their expand and align
> flags properly when designing a user interface. However, this problem
> happens when using the default settings, so people will inevitably
> encounter it. Most likely they will encounter it
> - while preparing their UIs in Glade
> - when writing tutorials
> - when writing testcases
> so it seems useful to define a proper behavior. So lets go on to the problems.

Its not actually true. The default value for align is FILL. So, you
will not encounter this unless you explicitly set alignment yourself.

> (1) Should align apply when the widget expands?
> An easy warm-up question, it can be answered with yes/no. Currently
> the code in GtkWidget constrains the size allocation of a widget to
> its natural size unless it is set to ALIGN_FILL.[2] This means that
> even widgets that are set to expand will never grow bigger than their
> natural size when a different align is set. My intuition is that
> expand set to true should override the align setting and expand the
> widget to fill all available space. If you do not want that and want
> to instead align your widget, you can hardcode the expand to FALSE.
> What brought me to consider this question is that expand is inherited
> by parent containers, so an align set on _any_ ancestor of an
> expanding widget will effectively nullify its expansion and I wondered
> if that's intentional.

Given that the default value for align is FILL, I'm really tempted to reply:
So ? If you do not want that and want your widget to expand, simply
don't set align to a non-expanding value.

Changing the semantics of align as you propose would muddy the waters
by entangling align and expand.


> Unfortunately, all of them have interesting side effects that can
> require some work to undo them, in particular if you insist on one
> widget

I think we probably want to steer people away from the idea that the
grid is a container you only ever need a single instance of, since it
does everything. There is nothing wrong with nesting containers,
people are very good at it from past experience with boxes...


> Second, if children should never get
> assigned extra space, why do we have the ALIGN_FILL parameter?

expand is about whether you _want_ the child to receive extra space.
align=fill is about how the child should react if it _gets_ extra
space, wanted or not...


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]