[gtk/nested-popover-menu: 2/5] popover: Support vertical aligment



commit c75a368bab66180c2ebd2ca9483b419fa64840d9
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 5 15:29:19 2019 -0400

    popover: Support vertical aligment
    
    We already support horizontal alignment, and
    we should do the same for vertical alignment.

 gtk/gtkpopover.c | 44 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 031e606c4c..3f487a1172 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -246,14 +246,50 @@ move_to_rect (GtkPopover *popover)
   switch (priv->position)
     {
     case GTK_POS_LEFT:
-      parent_anchor = GDK_GRAVITY_WEST;
-      surface_anchor = GDK_GRAVITY_EAST;
+      switch (gtk_widget_get_valign (GTK_WIDGET (popover)))
+        {
+        case GTK_ALIGN_START:
+          parent_anchor = GDK_GRAVITY_NORTH_WEST;
+          surface_anchor = GDK_GRAVITY_NORTH_EAST;
+          break;
+
+        case GTK_ALIGN_END:
+          parent_anchor = GDK_GRAVITY_SOUTH_WEST;
+          surface_anchor = GDK_GRAVITY_SOUTH_EAST;
+          break;
+
+        case GTK_ALIGN_FILL:
+        case GTK_ALIGN_CENTER:
+        case GTK_ALIGN_BASELINE:
+        default:
+          parent_anchor = GDK_GRAVITY_WEST;
+          surface_anchor = GDK_GRAVITY_EAST;
+          break;
+        }
       anchor_hints = GDK_ANCHOR_FLIP_X | GDK_ANCHOR_SLIDE_Y;
       break;
 
     case GTK_POS_RIGHT:
-      parent_anchor = GDK_GRAVITY_EAST;
-      surface_anchor = GDK_GRAVITY_WEST;
+      switch (gtk_widget_get_valign (GTK_WIDGET (popover)))
+        {
+        case GTK_ALIGN_START:
+          parent_anchor = GDK_GRAVITY_NORTH_EAST;
+          surface_anchor = GDK_GRAVITY_NORTH_WEST;
+          break;
+
+        case GTK_ALIGN_END:
+          parent_anchor = GDK_GRAVITY_SOUTH_EAST;
+          surface_anchor = GDK_GRAVITY_SOUTH_WEST;
+          break;
+
+        case GTK_ALIGN_FILL:
+        case GTK_ALIGN_CENTER:
+        case GTK_ALIGN_BASELINE:
+        default:
+          parent_anchor = GDK_GRAVITY_EAST;
+          surface_anchor = GDK_GRAVITY_WEST;
+          break;
+        }
       anchor_hints = GDK_ANCHOR_FLIP_X | GDK_ANCHOR_SLIDE_Y;
       break;
 


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