[gtk+/overlay: 31/34] Implement RTL flipping for GtkOverlay
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/overlay: 31/34] Implement RTL flipping for GtkOverlay
- Date: Sat, 11 Jun 2011 01:01:15 +0000 (UTC)
commit 8acc61f7b6d5c1cd28b289f773a67feb0fc6f53d
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 10 20:26:54 2011 -0400
Implement RTL flipping for GtkOverlay
gtk/gtkoverlay.c | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index 9211332..e7a34ba 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -228,6 +228,21 @@ gtk_overlay_child_allocate (GtkWidget *child,
gtk_widget_size_allocate (child, child_allocation);
}
+static GtkAlign
+effective_align (GtkAlign align,
+ GtkTextDirection direction)
+{
+ switch (align)
+ {
+ case GTK_ALIGN_START:
+ return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_END : GTK_ALIGN_START;
+ case GTK_ALIGN_END:
+ return direction == GTK_TEXT_DIR_RTL ? GTK_ALIGN_START : GTK_ALIGN_END;
+ default:
+ return align;
+ }
+}
+
static void
gtk_overlay_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -268,6 +283,8 @@ gtk_overlay_size_allocate (GtkWidget *widget,
{
GtkRequisition req;
GtkAllocation alloc, child_alloc;
+ GtkAlign halign;
+ GtkTextDirection direction;
child = children->data;
@@ -277,10 +294,18 @@ gtk_overlay_size_allocate (GtkWidget *widget,
gtk_widget_get_preferred_size (child->widget, NULL, &req);
- alloc.x = child->x_offset + main_alloc.x;
+ alloc.x = main_alloc.x;
alloc.width = MIN (main_alloc.width, req.width);
- switch (gtk_widget_get_halign (child->widget))
+ direction = gtk_widget_get_direction (child->widget);
+
+ if (direction == GTK_TEXT_DIR_RTL)
+ alloc.x -= child->x_offset;
+ else
+ alloc.x += child->x_offset;
+
+ halign = gtk_widget_get_halign (child->widget);
+ switch (effective_align (halign, direction))
{
case GTK_ALIGN_START:
case GTK_ALIGN_FILL:
@@ -294,9 +319,11 @@ gtk_overlay_size_allocate (GtkWidget *widget,
break;
}
- alloc.y = child->y_offset + main_alloc.y;
+ alloc.y = main_alloc.y;
alloc.height = MIN (main_alloc.height, req.height);
+ alloc.y += child->y_offset;
+
switch (gtk_widget_get_valign (child->widget))
{
case GTK_ALIGN_START:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]