Re: Vertical position of text in under-allocated labels



.. And here is a patch which fixes the problem in main-menu.

  Federico
2007-12-17  Federico Mena Quintero  <federico novell com>

	* gtk/gtklabel.c (get_layout_location): For single-line labels,
	align the requisition to the allocation unconditionally, even if
	we are under-allocated.  For multi-line labels, try to show the
	top of the text as before.  Fixes
	https://bugzilla.novell.com/show_bug.cgi?id=310710

diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index cd6c5ac..6e38a7d 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -2362,9 +2362,17 @@ get_layout_location (GtkLabel  *label,
   else
     x = MIN (x, widget->allocation.x + widget->allocation.width - misc->xpad);
 
-  y = floor (widget->allocation.y + (gint)misc->ypad 
-             + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign),
-	     0));
+  /* For single-line labels, *do* align the requisition with respect to the allocation, even
+   * if we are under-allocated.  For multi-line labels, always show the top of the text when
+   * they are under-allocated.
+   */
+  if (pango_layout_get_line_count (label->layout) == 1)
+    y = floor (widget->allocation.y + (gint)misc->ypad 
+	       + (widget->allocation.height - widget->requisition.height) * misc->yalign);
+  else
+    y = floor (widget->allocation.y + (gint)misc->ypad 
+	       + MAX (((widget->allocation.height - widget->requisition.height) * misc->yalign),
+		      0));
 
   if (xp)
     *xp = x;


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