[libadwaita/wip/exalm/squeezer-fix: 106/106] squeezer: Make layout work with vertical orientation
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/wip/exalm/squeezer-fix: 106/106] squeezer: Make layout work with vertical orientation
- Date: Mon, 19 Apr 2021 09:54:41 +0000 (UTC)
commit fdce6c02dc94ac19a3c8a45983576e3f3e203707
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Apr 12 13:06:49 2021 +0500
squeezer: Make layout work with vertical orientation
Also properly use xalign/yalign instead of halign/valign.
Fixes https://gitlab.gnome.org/GNOME/libadwaita/-/issues/121
src/adw-squeezer.c | 48 ++++++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/src/adw-squeezer.c b/src/adw-squeezer.c
index e0eaceb..095038e 100644
--- a/src/adw-squeezer.c
+++ b/src/adw-squeezer.c
@@ -891,12 +891,21 @@ adw_squeezer_size_allocate (GtkWidget *widget,
if (self->last_visible_child) {
int min, nat;
- gtk_widget_measure (self->last_visible_child->widget, GTK_ORIENTATION_HORIZONTAL,
- -1, &min, &nat, NULL, NULL);
- child_allocation.width = MAX (min, width);
- gtk_widget_measure (self->last_visible_child->widget, GTK_ORIENTATION_VERTICAL,
- child_allocation.width, &min, &nat, NULL, NULL);
- child_allocation.height = MAX (min, height);
+ if (self->orientation == GTK_ORIENTATION_HORIZONTAL) {
+ gtk_widget_measure (self->last_visible_child->widget, GTK_ORIENTATION_HORIZONTAL,
+ -1, &min, &nat, NULL, NULL);
+ child_allocation.width = MAX (min, width);
+ gtk_widget_measure (self->last_visible_child->widget, GTK_ORIENTATION_VERTICAL,
+ child_allocation.width, &min, &nat, NULL, NULL);
+ child_allocation.height = MAX (min, height);
+ } else {
+ gtk_widget_measure (self->last_visible_child->widget, GTK_ORIENTATION_VERTICAL,
+ -1, &min, &nat, NULL, NULL);
+ child_allocation.height = MAX (min, height);
+ gtk_widget_measure (self->last_visible_child->widget, GTK_ORIENTATION_HORIZONTAL,
+ child_allocation.height, &min, &nat, NULL, NULL);
+ child_allocation.width = MAX (min, width);
+ }
gtk_widget_size_allocate (self->last_visible_child->widget, &child_allocation, -1);
}
@@ -905,22 +914,21 @@ adw_squeezer_size_allocate (GtkWidget *widget,
child_allocation.height = height;
if (self->visible_child) {
- int min, nat;
- GtkAlign valign;
+ int min;
+
+ gtk_widget_measure (self->visible_child->widget, GTK_ORIENTATION_HORIZONTAL,
+ height, &min, NULL, NULL, NULL);
+ child_allocation.width = MAX (child_allocation.width, min);
gtk_widget_measure (self->visible_child->widget, GTK_ORIENTATION_VERTICAL,
- width, &min, &nat, NULL, NULL);
-
- if (self->interpolate_size) {
- valign = gtk_widget_get_valign (self->visible_child->widget);
- child_allocation.height = MAX (nat, height);
- if (valign == GTK_ALIGN_END &&
- child_allocation.height > height)
- child_allocation.y -= nat - height;
- else if (valign == GTK_ALIGN_CENTER &&
- child_allocation.height > height)
- child_allocation.y -= (nat - height) / 2;
- }
+ width, &min, NULL, NULL, NULL);
+ child_allocation.height = MAX (child_allocation.height, min);
+
+ if (child_allocation.width > width)
+ child_allocation.x = (width - child_allocation.width) * self->xalign;
+
+ if (child_allocation.height > height)
+ child_allocation.y = (height - child_allocation.height) * self->yalign;
gtk_widget_size_allocate (self->visible_child->widget, &child_allocation, -1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]