From c75a368bab66180c2ebd2ca9483b419fa64840d9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 5 Sep 2019 15:29:19 -0400 Subject: [PATCH] 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;