Vertical position of text in under-allocated labels



Hi,

We have a problem in gnome-main-menu which is (understandably) a corner
case in GtkLabel ( https://bugzilla.novell.com/show_bug.cgi?id=310710 )

First, please see no-focus.png (attached).  That is main-menu's
"Computer" button and a button from the task list applet.  You'll see
that the labels don't line up, and the "Computer" text appears clipped
(the descender of the "p" is gone).

This happens for the following reasons:

* The "Computer" button has normal values for focus padding and focus
line width.  In focus.png (attached) you can see the focused button; the
button must be focusable for a11y reasons.

* The task list sets the style of its buttons to have zero-width and
zero-padding for the focus (and its buttons don't seem to be focusable
at all).

* The "Computer" label ends up getting an allocation which shorter than
its requisition in the Y direction.

When GtkLabel comes to gtklabel.c:get_layout_location(), specifically
here:

  y = floor (widget->allocation.y + (gint)misc->ypad 
             + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign),
	            0));

It ends up always positioning the label text at or below its
allocation.y.  This is usually the right thing, but gives bad results
when the label is under-allocated *and* centered:  the end result
definitely doesn't *look* centered --- there's visually enough room for
the text inside the button.

I did a little digging and found this:
http://bugzilla.gnome.org/show_bug.cgi?id=71742

That's when GtkLabel was made to show as much of the text as possible
when it is under-allocated.  Søren's patch indeed seems to do the right
thing for the label's horizontal position, but I think for the vertical
position it could very well just center the requisition within the
allocation (or use whatever the alignment specifies).

This may only work well for single-line labels, and it would fix the
problem for the Computer button.  For multi-line labels, I think the
rationale of showing the top of the text is better.

Does this make sense?  I'll cook a patch to test it, but first I wanted
to confirm with people who have given more thought to this.

  Federico

Attachment: no-focus.png
Description: PNG image

Attachment: focus.png
Description: PNG image



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