Re: Minimum height for minimum width - reprise

On Wed, Jun 19, 2013 at 6:19 PM, Pietro Battiston <me pietrobattiston it> wrote:
Il giorno mer, 19/06/2013 alle 13.40 +0900, Tristan Van Berkom ha
On Wed, Jun 19, 2013 at 1:31 AM, Pietro Battiston <me pietrobattiston it> wrote:
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.

Notice the window in my case is not tall and slim, it is tall and large!
Because the width is the natural one, but the minimal height corresponds
to the minimal width.

   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).

Maybe I misunderstand you, but what seems to happen is precisely that
the height of a window is "determined by the minimum width of a window":

git clone git://
cd quack
git checkout wrapbox_error
cd plugins/tags


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

OK, fine - labels were just an example, I don't claim I know better than
anybody else how they should behave.

   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.



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.

Actually, what I'm asking is exactly the opposite: is there any way to
create a simple widget which
1) requests (=minimal) a rectangular area of 10 000 pixels, accepting
any possible ratio going from 20 x 500 to 500 x 20
2) suggests (=natural) a 100 x 100 square

This is, to my eyes, the clearest example of height-for-width space
management... and as far as I understand, it is currently impossible.

Am I missing something?

This is possible, but I don't know any widgets which do that, that's all.

widget_get_preferred_height_for_width (GtkWidget *widget,
                                                            gint width,
                                                            gint *minimum,
                                                            gint *natural)
   /* You are going to be allocated 'width' which is something greater
    * than the minimum width you reported in
get_preferred_width_for_height( height = -1);

   /* Now you will *request* this much height */
   *minimum = height;

   /* Note that 'natural' must be at least as big as 'minimum' */
   *natural = desired_height_for_given_width (height);

   /* Now you will *request* this much height */
   *minimum = *natural = height;

Note that you might be allocated more size than that which you requested,
but not less.

You might want your aspect ratio height to be the minimum & natural
instead of 'square', depending.

Does this answer your question ?

Thanks again,


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

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