Re: Minimum height for minimum width - reprise

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

Well, this did suggest to me that my question was maybe not well
formulated - in fact, I have a problem with the layouting algorithm, not
with the working of a widget on its own. So consider this simple

1) in my widget_get_preferred_width(), I set
   *minimum = 50
   *natural = 200

2) in my widget_get_preferred_height_for_width(), I set
   *minimum = *natural = 10000/width

3) I pack_start this widget into a Gtk.VBox()

4) I add the VBox in a Gtk.Window, and show_all() it

Result: a window that's 200x200 (and the user can't shrink vertically).

Now repeat the steps above, adding, between 3 and 4:

3a) I pack_start into the VBox an additional 60x17 GtkLabel (or
GtkImage, that's irrelevant).

Result: a window that's 200x183!

So to resume: what annoys me - in both cases - is that the window is
much too tall, and the user cannot even shrink it vertically.
But what I really find inconsistent is that by adding a widget below,
the resulting window may become smaller!

Anyway, I don't have a better algorithm in mind - if you tell me that
there is nothing I'm missing and there is no obvious solution to such
problem, I'll just make things work reasonably in reasonable contexts.



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