# Re: Extended Layout Summary

• To: Mathias Hasselmann <mathias hasselmann gmx de>
• Cc: Gtk+ Developers <gtk-devel-list gnome org>
• Subject: Re: Extended Layout Summary
• Date: Tue, 20 Nov 2007 20:09:01 -0500

Thanks Mathias for the write-up.  You didn't get much into the baseline
stuff which was the really interesting part about text, but other than
that, the rest looks good from that point of view.  Comments below:

On Tue, 2007-11-20 at 07:23 -0500, Mathias Hasselmann wrote:
>
> When a container widget got more space allocated than requested, it
> considers the difference between natural and requested size of its
> children to distribute that additional space, in relation to the child's
> difference between natural and minimum-size. Let's use an example for
> demonstration:
>
>     Assume we have a container with two children. Both children request
>     a_min = b_min = 50 pixels as minimum size. The first child announces
>     a_nat = 100 pixels, the second announces b_nat = 200 pixels as
>     natural size.
>
>     This gives a requested size of c_min = 100 pixels, and a natural
>     size of 300 pixels (c_nat) for the container. Now the container gets
>     allocated at a size of 200 pixels (c_cur). This are 100 pixels to
>     distribute (c_gap).
>
>     So the first child gets:
>
>       a_cur = a_min + c_gap * (a_nat - a_min) / (c_nat - c_nat)
>             = 50    + 100   * 50              / 200
>             = 75 pixels.
>
>     The second child gets:
>
>       b_cur = b_min + b_gap * (b_nat - b_min) / (c_nat - c_nat)
>             = 50    + 100   * 150             / 200
>             = 125 pixels.

Something that Ryan brought up, and I was hoping that Havoc answer is
that the above algorithm is not optimal, you can easily do better.
Quoting Havoc's words: "bring smaller items up to natural size first".
Read his entire "TEXT LAYOUT THAT WORKS PROPERLY?" post here:

http://log.ometer.com/2006-10.html

That, and switching to the API Havoc suggested would mean that Gtk+ will
be in par with HippoCanvas which is cool.

Cheers,

--