Re: Baseline alignment ideas



On tis, 2013-02-26 at 10:58 -0500, Matthias Clasen wrote:
On Tue, Feb 26, 2013 at 9:30 AM, Alexander Larsson <alexl redhat com> wrote:

Ideas wanted...

I think you basically have to split the height that is returned for
minimal or natural size into an overlength/underlength pair. Then you
can sum them up separately in containers that support baseline
alignment. In containers that don't, you'll always just use the total
height (which is the sum of the two).

Would that work, or am I overlooking something ?

Yeah, thats the way you implement size *request*. The problem comes when
you get to the allocation phase. Let me give a simple example. We're
laying out a hbox with two child vboxes, each with a label and some
other widget. Like this:

+- HBox --------------+
|+-------+            |
||       |            |
||  A    |            |
||       |            |
|+-------+ +--------+ |
||  B    | |    B   | |
|+-------+ +--------+ |
|          |        | |
|          |    D   | |
|          |        | |
|          |        | |
|          +--------+ |
+---------------------+
The labels B are identical, but packed in different order in the vboxes.
To make things easy, lets say all widgets are 100 px wide.
Then:
   min height   nat height  baseline
A: 10           20
B: 20           20          10
C: 20           30

Its quite obvious that the min height of the hbox is 10+20+20 == 50, the
natural height is 20 + 20 + 30 == 70px, and the corresponding baselines
are at 20 and 30. And the width is 200 px.

So, we report this is size_request. Now the size machinery happens and
we get called with the final size of the hbox. It is to be 200x60
pixels.

Now, what size should we allocate to the children?
At least we should fulfill the minimum request which is 50 px tall. But
then we have an extra 10 pixels to distribute. But, how do we distribute
it? Whenever we add size to some particular child that will affect the
baseline of that child in some complex way. For instance, in this case
as the two children point in different direction we should probably give
each child 5 pixels more each which gives a total height of 60. But if
the order of the two children were the same we should give each child 10
pixels, which would then give us 60 pixels.

Now repeat the same for arbitrarily complex dependencies on the child
baseline position based on its height...











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