[gtk+/native-layout] Disabling natural sizes of labels.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/native-layout] Disabling natural sizes of labels.
- Date: Sat, 17 Apr 2010 05:53:41 +0000 (UTC)
commit 46fe9c3f00a1cd7f175d726bbe521233d2e86018
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat Apr 17 01:49:35 2010 -0400
Disabling natural sizes of labels.
Since GtkLabel is returning invalid natural sizes for now,
in order to test regressions well with the new width-for-height
api, I've temporarily disabled the natural values.
gtk/gtklabel.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index c730e31..865d8f4 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -3253,7 +3253,7 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
label->layout = backup;
}
- if (label->single_line_mode || label->wrap)
+ if (label->single_line_mode)
required_rect.height = get_single_line_height (GTK_WIDGET (label), label->layout);
if (label->have_transform)
@@ -3283,6 +3283,10 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
minimum = required_rect.height + label->misc.ypad * 2;
}
+
+ natural = minimum;
+
+#if 0
/* Natural size */
natural_layout = pango_layout_copy (label->layout);
pango_layout_set_width (natural_layout, -1);
@@ -3310,6 +3314,7 @@ gtk_label_get_desired_size (GtkExtendedLayout *layout,
natural = required_rect.height + label->misc.ypad * 2;
g_object_unref (natural_layout);
+#endif
if (minimum_size)
*minimum_size = minimum;
@@ -3347,6 +3352,7 @@ get_size_for_allocation (GtkLabel *label,
GtkWidgetAuxInfo *aux_info =
_gtk_widget_get_aux_info (GTK_WIDGET (label), FALSE);
gint aux_size;
+ gint text_height;
if (label->wrap)
gtk_label_clear_layout (label);
@@ -3354,24 +3360,28 @@ get_size_for_allocation (GtkLabel *label,
gtk_label_ensure_layout (label);
layout = pango_layout_copy (label->layout);
- if (orientation == GTK_ORIENTATION_HORIZONTAL)
- aux_size = aux_info->width;
+ if (aux_info)
+ {
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ aux_size = aux_info->width;
+ else
+ aux_size = aux_info->height;
+ }
else
- aux_size = aux_info->height;
+ aux_size = 0;
if (aux_size > 0)
pango_layout_set_width (layout, aux_size * PANGO_SCALE);
else
pango_layout_set_width (layout, allocation * PANGO_SCALE);
+ pango_layout_get_pixel_size (layout, NULL, &text_height);
+
if (minimum_size)
- pango_layout_get_pixel_size (layout, NULL, minimum_size);
+ *minimum_size = text_height;
if (natural_size)
- {
- //pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
- pango_layout_get_pixel_size (layout, NULL, natural_size);
- }
+ *natural_size = text_height;
g_object_unref (layout);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]