[gtk+] Scale: Set the correct value alignment
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Scale: Set the correct value alignment
- Date: Tue, 10 May 2016 19:25:19 +0000 (UTC)
commit 327777a291a736ed3e0ebb14b2be6cdbb664c907
Author: Timm Bäder <mail baedert org>
Date: Tue May 10 18:33:37 2016 +0200
Scale: Set the correct value alignment
We're measuring both the width of the minimal and the maximal value for
the value gadget, but only give the value the minimal width for its
current value, resultnig in an always left-aligned value.
Fix this by assigning the width of the value gadget to the value layout
and letting pango align the text inside the layout.
https://bugzilla.gnome.org/show_bug.cgi?id=766120
gtk/gtkscale.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 2223d37..fc0121d 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -1903,8 +1903,23 @@ gtk_scale_get_layout (GtkScale *scale)
if (!priv->layout)
{
+ int min_layout_width;
+
if (priv->draw_value)
- priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
+ priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (scale), NULL);
+
+ gtk_css_gadget_get_preferred_size (priv->value_gadget,
+ GTK_ORIENTATION_HORIZONTAL, -1,
+ &min_layout_width, NULL,
+ NULL, NULL);
+ pango_layout_set_width (priv->layout, min_layout_width * PANGO_SCALE);
+
+ if (priv->value_pos == GTK_POS_LEFT)
+ pango_layout_set_alignment (priv->layout, PANGO_ALIGN_RIGHT);
+ else if (priv->value_pos == GTK_POS_RIGHT)
+ pango_layout_set_alignment (priv->layout, PANGO_ALIGN_LEFT);
+ else
+ pango_layout_set_alignment (priv->layout, PANGO_ALIGN_CENTER);
}
if (priv->draw_value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]