diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-02-20 16:41:53 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-02-20 16:46:49 -0500 |
commit | 4331ff2939c44109763306fb3f45355f4d08ab24 (patch) | |
tree | abaa26be7512add0c29a6311fe068d376aea7e42 /gtk | |
parent | 7fc1fcde1e5fe7839c9d8d578d2e6d270a74f23b (diff) | |
download | gtk+-4331ff2939c44109763306fb3f45355f4d08ab24.tar.gz |
box: Fix rtl allocation with center widget
The code for adjusting the center widget allocation in case
of uneven sides never worked right in RTL. This was finally
noticed for tabs with close button, which commonly use a
centered label.
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkbox.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index f85459c353..0005413f69 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -1058,7 +1058,8 @@ gtk_box_size_allocate_with_center (GtkWidget *widget, { child_allocation.y = allocation->y; child_allocation.height = MAX (1, allocation->height); - if (packing == GTK_PACK_START) + if ((packing == GTK_PACK_START && direction == GTK_TEXT_DIR_LTR) || + (packing == GTK_PACK_END && direction == GTK_TEXT_DIR_RTL)) x = allocation->x; else x = allocation->x + allocation->width; @@ -1105,7 +1106,8 @@ gtk_box_size_allocate_with_center (GtkWidget *widget, child_allocation.x = x + (child_size - child_allocation.width) / 2; } - if (packing == GTK_PACK_START) + if ((packing == GTK_PACK_START && direction == GTK_TEXT_DIR_LTR) || + (packing == GTK_PACK_END && direction == GTK_TEXT_DIR_RTL)) { x += child_size + priv->spacing; } @@ -1114,10 +1116,6 @@ gtk_box_size_allocate_with_center (GtkWidget *widget, x -= child_size + priv->spacing; child_allocation.x -= child_size; } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - } else /* (private->orientation == GTK_ORIENTATION_VERTICAL) */ { @@ -1159,10 +1157,16 @@ gtk_box_size_allocate_with_center (GtkWidget *widget, else center_pos = allocation->y + (box_size - center_size) / 2; - if (center_pos < side[GTK_PACK_START]) - center_pos = side[GTK_PACK_START]; - else if (center_pos + center_size > side[GTK_PACK_END]) - center_pos = side[GTK_PACK_END] - center_size; + if (priv->orientation == GTK_ORIENTATION_HORIZONTAL && + direction == GTK_TEXT_DIR_RTL) + packing = GTK_PACK_END; + else + packing = GTK_PACK_START; + + if (center_pos < side[packing]) + center_pos = side[packing]; + else if (center_pos + center_size > side[1 - packing]) + center_pos = side[1 - packing] - center_size; if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { |