Re: Minimum height for minimum width - reprise

On Wed, Jun 19, 2013 at 1:31 AM, Pietro Battiston <me pietrobattiston it> wrote:
Dear developers,

I've written a plugin. It is a simple WrapBox, similar to the one which
was for some time in gtk2 (or at least I think so - I did not actually
see it working, only read some mails about it). I tell you this only to
make you grasp an idea of how magically such a plugin can benefit from
the gtk3 space allocation mechanism: it can play well with a width which
is just the width of the smallest child, but also with a width which is
the sum of them all - in the first case, taking many rows, in the
second, taking only one.

Well, no, I'm lying, it does not, for the simple reason that I stumbled
in the problem perfectly described by Owen here:

If I'm honest about the minimum width, then the (corresponding) minimum
height required is assumed to be something huge, and the result (for
instance directly inside a window) is ugly.

This is the nature or height for width, minimum height for minimum width
will usually be tall and slim.

However there are a few tactics to use which ensure that tall and slim windows
don't occur.

   a.) The toplevel window should not by default present itself at
minimum width,
        I think currently GTK+ toplevels use some trickery with natural width.

        I.e., the height of a window is not determined by the minimum
width of a window,
        it's determined by the height for the width which will be
*allocated* to the window
        (that's an important difference).

        There was also talk about creating an algorithm to aim for
something closest
        to the screen's aspect ratio when trying to guess a default window size
        (if the programmer did not provide a default size with

        I think Bejamin Otte might know a bit more about the current
functionality of

   b.) Make sure that labels do not request a ridiculously small
minimum width when they
        are set to wrap.

        This can be done by setting the 'width-chars' property
(originally I had an automatic
        minimum width which was larger than "..." but I think that got
removed early in
        the 3.0 cycle, causing the tall/skinny dialogs we've seen in
some apps, which I
        think was fixed by some other patch to make the GtkWindow
request something
        more reasonable since then).

   c.) Height for width makes more sense when there are areas in your
application which
        might be smaller or larger or contain some content which might
not always be visible.

        I.e. many applications contain paned windows with scrolled
windows, this is where
        height for width becomes interesting, because generally the
user's window will be larger
        than the minimum possible size.

        In this case shrinking the window width would cause some
content to wrap and show
        less of the content in the scrolled window area below, making
the window wider will
        unwrap and then reveal more of the content in the scrolled window.

        The goal is to show as much content that is reasonably
possible, while minimizing
        the useless blank space between widgets as much as possible.

I could in principle
understand (though it seems to me a hack) that a Gtk.Label doesn't
declare its minimal width as the width of its largest word. But in the
current design the author of a widget can't in fact, declare _any_
minimum width smaller than the natural width - otherwise (what gtk will
consider) the minimum height will be _larger_ than the space which the
widget does use, and this will look horrible.

To be honest, I did read the thread which followed the mail linked
above... but I I'm not sure I fully understood it completely. So I'm
writing to ask:
1) did I say something wrong in my short analysis?
2) can you confirm that things are as they were when that thread

Or in few words: am I missing anything? Taking it to the extreme, is
there actually any way to create a simple widget which always asks for
100 000 pixels of screen space, but is totally indifferent with respect
to the aspect ratio?

Of course, many widgets do this, i.e. a GtkImage loaded from a pixbuf only
requests the size of the image, and does not trade any height for width.

I hope this answers most of your questions.


Thank you in advance for any enlightnement,


gtk-devel-list mailing list
gtk-devel-list gnome org

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