Re: Geometry Management



On Sun, 2011-09-25 at 18:23 -0400, Paul Davis wrote:
> On Sun, Sep 25, 2011 at 6:20 PM, Matthew Bucknall
> <matthew bucknall googlemail com> wrote:
> 
> > What I'm not clear on is the meaning of the 'natural' arguments in
> > calls to gtk_widget_get_preferred_height () and
> > gtk_widget_get_preferred_width ().
> >
> > Are the natural sizes just some sort hint to containers which may
> > result in more aesthetically pleasing layouts than just going by the
> > minimum sizes alone?

It's a bit confusing what is the right answer for "natural_width"
when implementing a widget, the accurate explanation about natural
size is:
  the size at which a widget will cease to compete with it's siblings
  for space in a said container.

But you could just say they are 'hints', they basically mean "at what
size am I satisfied that I have enough width", it does not mean that
no greater width given can be used (a wrapping label can have a
natural width that is not the entire text length).

Long winded story I guess I felt like writing...

When allocating children of a container we always have enough space
to satisfy the minimum size, after that (assuming the container is
height-for-width aware) space is distributed to smaller widgets first
until every sibling reaches it's natural size and then finally
extra space is given to widgets who requested to 'expand'.

Allocating children taking into consideration minimum and natural
width allows for better management of space, simply put; more 
(possibly dynamic) content can appear on screen at once.

Imagine a setup where you have a details box of sorts on the
left and a content area on the right. Lets say that the content
area is set to expand horizontally and the details box's width
is limited by a translatable "title" label at the top which is
set to ellipsize.

In this case, the title label's full width will (by default)
define the natural width of the label and consequently when
resizing the application; the parent box will always try to fit
the detail area with the entire title label (if possible) and 
leave the remainder to the content window.

Cheers,
        -Tristan




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