After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 524166 - Underallocated GtkLabel should honor its allocation/alignment
Underallocated GtkLabel should honor its allocation/alignment
Status: RESOLVED DUPLICATE of bug 315462
Product: gtk+
Classification: Platform
Component: Widget: Other
2.12.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2008-03-24 17:35 UTC by Federico Mena Quintero
Modified: 2008-03-24 18:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
no-focus.png (4.75 KB, image/png)
2008-03-24 17:37 UTC, Federico Mena Quintero
  Details
focus.png (4.80 KB, image/png)
2008-03-24 17:37 UTC, Federico Mena Quintero
  Details
gtk+-bgo524166-bnc310710-underallocated-gtklabel-position.diff (1.49 KB, patch)
2008-03-24 17:40 UTC, Federico Mena Quintero
none Details | Review

Description Federico Mena Quintero 2008-03-24 17:35:27 UTC
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 bug #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.
Comment 1 Federico Mena Quintero 2008-03-24 17:37:05 UTC
Created attachment 107933 [details]
no-focus.png
Comment 2 Federico Mena Quintero 2008-03-24 17:37:35 UTC
Created attachment 107934 [details]
focus.png
Comment 3 Federico Mena Quintero 2008-03-24 17:40:08 UTC
Created attachment 107935 [details] [review]
gtk+-bgo524166-bnc310710-underallocated-gtklabel-position.diff

This is the patch which we have in openSUSE 10.3 and fixes the problem.
Comment 4 Björn Lindqvist 2008-03-24 18:26:11 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.


*** This bug has been marked as a duplicate of 315462 ***