60 lines
1.8 KiB
Diff
60 lines
1.8 KiB
Diff
|
|
From b2c52f258757e37a74a95c109431f6af8cda8f91 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Sophie Herold <sophie@hemio.de>
|
||
|
|
Date: Wed, 7 Dec 2022 17:42:06 +0100
|
||
|
|
Subject: [PATCH] carousel: give new child a snap_point immediately
|
||
|
|
|
||
|
|
Fixes #457, #597
|
||
|
|
---
|
||
|
|
src/adw-carousel.c | 21 ++++++++++++++++++++-
|
||
|
|
1 file changed, 20 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
|
||
|
|
index 47ea9475..5a9816f9 100644
|
||
|
|
--- a/src/adw-carousel.c
|
||
|
|
+++ b/src/adw-carousel.c
|
||
|
|
@@ -1207,6 +1207,8 @@ adw_carousel_insert (AdwCarousel *self,
|
||
|
|
{
|
||
|
|
ChildInfo *info;
|
||
|
|
GList *next_link = NULL;
|
||
|
|
+ double snap_point = 0;
|
||
|
|
+ GList *children;
|
||
|
|
|
||
|
|
g_return_if_fail (ADW_IS_CAROUSEL (self));
|
||
|
|
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||
|
|
@@ -1214,7 +1216,8 @@ adw_carousel_insert (AdwCarousel *self,
|
||
|
|
|
||
|
|
info = g_new0 (ChildInfo, 1);
|
||
|
|
info->widget = widget;
|
||
|
|
- info->size = 0;
|
||
|
|
+ // set a minimal size to give child it's own snap_point from the beginning
|
||
|
|
+ info->size = 0.00001;
|
||
|
|
info->adding = TRUE;
|
||
|
|
|
||
|
|
if (position >= 0)
|
||
|
|
@@ -1230,6 +1233,22 @@ adw_carousel_insert (AdwCarousel *self,
|
||
|
|
gtk_widget_set_parent (widget, GTK_WIDGET (self));
|
||
|
|
}
|
||
|
|
|
||
|
|
+ // work around this usually happening in measure which can be too late
|
||
|
|
+ for (children = self->children; children; children = children->next) {
|
||
|
|
+ ChildInfo *child_info = children->data;
|
||
|
|
+
|
||
|
|
+ child_info->snap_point = snap_point + child_info->size - 1;
|
||
|
|
+
|
||
|
|
+ snap_point += child_info->size;
|
||
|
|
+
|
||
|
|
+ if (child_info == self->animation_target_child)
|
||
|
|
+ adw_spring_animation_set_value_to (ADW_SPRING_ANIMATION (self->animation),
|
||
|
|
+ child_info->snap_point);
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
+ // start animation from correct size
|
||
|
|
+ info->size = 0;
|
||
|
|
+
|
||
|
|
gtk_widget_queue_allocate (GTK_WIDGET (self));
|
||
|
|
|
||
|
|
animate_child_resize (self, info, 1, self->reveal_duration);
|
||
|
|
--
|
||
|
|
GitLab
|
||
|
|
|