Re: Please fill out the GtkLabel questionnaire



On Sun, 2011-04-10 at 00:25 +0200, Benjamin Otte wrote:
> Hey,
> 
> So this came up while discussing
> https://bugzilla.gnome.org/show_bug.cgi?id=647284 and we weren't sure
> what the proper answers for all those questions were. So we were
> wondering.
> We are thinking about GtkLabel size reuqests, in particular about the
> width. For ease of discussion, we assume that the font is monospaced,
> so we can forget about pixels and only think about characters. The
> text set on the label is "12345 1234" (10 characters in 2 words). And
> the question is: Given the properties on the left what width should
> the label request? Please fill out the table.

Benjamin,
   Essentially the width request of a label should be quite simple,
things became overcomplicated by the guessed minimum width of a wrapping
label and by my addition of max-width-chars... while it's a little bit
besides the point let me describe what should have have been done
instead.

Basically what happened is that I discovered if you give wrapping labels
a straight-forward size request you end up with a very tall and skinny 
interface by default... at the time I was working fast and I resorted to
giving wrapping labels "reasonably large" minimum widths to compensate 
for this (keep in mind an interface/GtkWindow is initially allocated the
minimum-height-for-minimum-width by default).

What I should have done, as Owen pointed out back in december was to
leave the label requests very straight-forward and require the program
author to set an explicit minimum size of the toplevel GtkWindow,
essentially the difference would only be that instead of having to
potentially configure a lot of label sizes inside the interface, you
just configure the desired size of the toplevel and you get a reasonable
allocation (Havoc also suggested we do some one-shot binary search to
find a good aspect ratio for the initial size of the toplevel window).

So, assuming that things were a bit simpler and we did not have to
guarantee that wrapping labels get a larger-than-life size by default,
my answer would be.

For ellipsizing labels:
   Minimum size: the size of the "..." or the size of the label,
                 whichever is smaller (an empty label can be smaller).
   Natural size: the full text length.

For labels wrapping with WRAP_CHAR or WRAP_WORD_CHAR:
   Minimum size: The width of the widest character in the label text
   Natural size: The fully unwrapped text length

For labels wrapping with WRAP_WORD:
   Minimum size: The width of the longest *word* in the full label text
   Natural size: The fully unwrapped text length

Natural size, it's important to remember is the size where a widget
ceases to compete with sibling widgets for space in a given container,
so it's still interesting to let the user set a natural-width-chars
(or max-width-chars), assigning a natural width in charachters does
not mean the widget will never get larger/wider... but it will only
get larger than the natural size after all siblings receive their
respective natural sizes and the label starts to receive expand space.

A caveat here is that currently there is no straight-forward way for
obtaining things like "the size of the largest word in the text" or
"the size of the widest character".

Labels currently don't wrap and ellipsize both, it would be nice if
they did however (and it's certainly possible, I would imagine the
whole text would wrap as much as possible and the text that doesnt
fit would be ellipsized only on the last line).

As far as "max-width-chars" and "width-chars" effects go, I dont have
any strong opinion so far as it's useful, the subtleties are:

  - Do we blatently always request "width-chars" as minimum if set ?
  - Do we request MIN (text_width, width-chars) ? 
    (I think this is more useful and I think it's how it currently
     works)

Same for max:
  - Do we blindly request "max-width-chars" as the natural width ?
  - Do we request MIN (text_width, max-width-chars) as natural ?
    (Again I think it's currently the latter and I personally think
    that is more useful).

Hope this was helpful,
    -Tristan


> 
> label properties                                     number of
> characters label should request
> wrap        ellipsize   width_chars max_width_chars  minimum   natural
> false       false       -1          -1               ?         ?
> true        false       -1          -1               ?         ?
> false       true        -1          -1               ?         ?
> true        true        -1          -1               ?         ?
> false       false        4          -1               ?         ?
> true        false        4          -1               ?         ?
> false       true         4          -1               ?         ?
> true        true         4          -1               ?         ?
> false       false        8          -1               ?         ?
> true        false        8          -1               ?         ?
> false       true         8          -1               ?         ?
> true        true         8          -1               ?         ?
> false       false       12          -1               ?         ?
> true        false       12          -1               ?         ?
> false       true        12          -1               ?         ?
> true        true        12          -1               ?         ?
> false       false       -1           4               ?         ?
> true        false       -1           4               ?         ?
> false       true        -1           4               ?         ?
> true        true        -1           4               ?         ?
> false       false        4           4               ?         ?
> true        false        4           4               ?         ?
> false       true         4           4               ?         ?
> true        true         4           4               ?         ?
> false       false        8           4               ?         ?
> true        false        8           4               ?         ?
> false       true         8           4               ?         ?
> true        true         8           4               ?         ?
> false       false       12           4               ?         ?
> true        false       12           4               ?         ?
> false       true        12           4               ?         ?
> true        true        12           4               ?         ?
> false       false       -1           8               ?         ?
> true        false       -1           8               ?         ?
> false       true        -1           8               ?         ?
> true        true        -1           8               ?         ?
> false       false        4           8               ?         ?
> true        false        4           8               ?         ?
> false       true         4           8               ?         ?
> true        true         4           8               ?         ?
> false       false        8           8               ?         ?
> true        false        8           8               ?         ?
> false       true         8           8               ?         ?
> true        true         8           8               ?         ?
> false       false       12           8               ?         ?
> true        false       12           8               ?         ?
> false       true        12           8               ?         ?
> true        true        12           8               ?         ?
> false       false       -1          12               ?         ?
> true        false       -1          12               ?         ?
> false       true        -1          12               ?         ?
> true        true        -1          12               ?         ?
> false       false        4          12               ?         ?
> true        false        4          12               ?         ?
> false       true         4          12               ?         ?
> true        true         4          12               ?         ?
> false       false        8          12               ?         ?
> true        false        8          12               ?         ?
> false       true         8          12               ?         ?
> true        true         8          12               ?         ?
> false       false       12          12               ?         ?
> true        false       12          12               ?         ?
> false       true        12          12               ?         ?
> true        true        12          12               ?         ?
> 
> 
> Alternatively, you can describe an algorithm to compute the label and
> I will fill out the table for you. But I'm pretty sure you'll get the
> algorithm wrong and do something entirely stupid for some weird corner
> case.
> 
> Enjoy,
> Benjamin
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list




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