[libadwaita/bilelmoussaoui/animation-target-fn: 1/2] AnimationTarget: take the user_data on the last param
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libadwaita/bilelmoussaoui/animation-target-fn: 1/2] AnimationTarget: take the user_data on the last param
- Date: Sat, 27 Nov 2021 20:33:28 +0000 (UTC)
commit 7182e2de6323c8db4edb0ab1732d93d00a405ffe
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Sat Nov 27 20:29:45 2021 +0100
AnimationTarget: take the user_data on the last param
Otherwise bindings confuses the value for the user_data
In general, it's supposed to be the last param
demo/adw-demo-window.c | 9 ++++++++-
src/adw-animation-target.c | 2 +-
src/adw-animation-target.h | 6 +++---
src/adw-animation.c | 4 ++--
src/adw-carousel-indicator-dots.c | 9 ++++++++-
src/adw-carousel-indicator-lines.c | 9 ++++++++-
src/adw-carousel.c | 8 ++++----
src/adw-flap.c | 10 +++++-----
src/adw-tab-box.c | 31 +++++++++++++++++++------------
src/adw-tab.c | 4 ++--
src/adw-toast-overlay.c | 13 ++++++++++---
tests/test-animation.c | 4 ++--
tests/test-timed-animation.c | 4 ++--
13 files changed, 74 insertions(+), 39 deletions(-)
---
diff --git a/demo/adw-demo-window.c b/demo/adw-demo-window.c
index 81324159..9f28c3be 100644
--- a/demo/adw-demo-window.c
+++ b/demo/adw-demo-window.c
@@ -696,6 +696,13 @@ toast_undo_cb (AdwDemoWindow *self)
adw_toast_overlay_add_toast (self->toast_overlay, toast);
}
+static void
+animation_page_cb (double value,
+ GtkWidget *self)
+{
+ gtk_widget_queue_allocate (self);
+}
+
static void
toast_dismiss_cb (AdwDemoWindow *self)
{
@@ -812,7 +819,7 @@ animation_page_init (AdwDemoWindow *self)
GtkLayoutManager *manager;
AdwAnimationTarget *target =
adw_callback_animation_target_new ((AdwAnimationTargetFunc)
- gtk_widget_queue_allocate,
+ animation_page_cb,
self->timed_animation_sample, NULL);
self->timed_animation =
diff --git a/src/adw-animation-target.c b/src/adw-animation-target.c
index 379487d7..337359c5 100644
--- a/src/adw-animation-target.c
+++ b/src/adw-animation-target.c
@@ -85,7 +85,7 @@ adw_callback_animation_target_set_value (AdwAnimationTarget *target,
{
AdwCallbackAnimationTarget *self = ADW_CALLBACK_ANIMATION_TARGET (target);
- self->callback (self->user_data, value);
+ self->callback (value, self->user_data);
}
static void
diff --git a/src/adw-animation-target.h b/src/adw-animation-target.h
index 42483d04..6f9c4383 100644
--- a/src/adw-animation-target.h
+++ b/src/adw-animation-target.h
@@ -24,15 +24,15 @@ GDK_DECLARE_INTERNAL_TYPE (AdwAnimationTarget, adw_animation_target, ADW, ANIMAT
/**
* AdwAnimationTargetFunc:
- * @user_data: (nullable): The user data provided when creating the target
* @value: The animation value
+ * @user_data: (nullable): The user data provided when creating the target
*
* Prototype for animation targets based on user callbacks.
*
* Since: 1.0
*/
-typedef void (*AdwAnimationTargetFunc) (gpointer user_data,
- double value);
+typedef void (*AdwAnimationTargetFunc) (double value,
+ gpointer user_data);
#define ADW_TYPE_CALLBACK_ANIMATION_TARGET (adw_callback_animation_target_get_type())
diff --git a/src/adw-animation.c b/src/adw-animation.c
index fc5d91c2..bb46fc37 100644
--- a/src/adw-animation.c
+++ b/src/adw-animation.c
@@ -38,8 +38,8 @@
*
* ```c
* static void
- * animation_cb (MyObject *self,
- * double value)
+ * animation_cb (double value,
+ * MyObject *self)
* {
* // Do something with @value
* }
diff --git a/src/adw-carousel-indicator-dots.c b/src/adw-carousel-indicator-dots.c
index d3bf2a5f..0c8a7553 100644
--- a/src/adw-carousel-indicator-dots.c
+++ b/src/adw-carousel-indicator-dots.c
@@ -79,6 +79,13 @@ get_color (GtkWidget *widget)
return color;
}
+static void
+indicator_dots_animation_cb (double value,
+ GtkWidget *self)
+{
+ gtk_widget_queue_resize (self);
+}
+
static void
snapshot_dots (GtkWidget *widget,
GtkSnapshot *snapshot,
@@ -339,7 +346,7 @@ adw_carousel_indicator_dots_init (AdwCarouselIndicatorDots *self)
{
AdwAnimationTarget *target
= adw_callback_animation_target_new ((AdwAnimationTargetFunc)
- gtk_widget_queue_resize,
+ indicator_dots_animation_cb,
self, NULL);
self->animation =
diff --git a/src/adw-carousel-indicator-lines.c b/src/adw-carousel-indicator-lines.c
index 97c8df32..90a804ae 100644
--- a/src/adw-carousel-indicator-lines.c
+++ b/src/adw-carousel-indicator-lines.c
@@ -77,6 +77,13 @@ get_color (GtkWidget *widget)
return color;
}
+static void
+indicator_lines_animation_cb (double value,
+ GtkWidget *self)
+{
+ gtk_widget_queue_resize (self);
+}
+
static void
snapshot_lines (GtkWidget *widget,
GtkSnapshot *snapshot,
@@ -324,7 +331,7 @@ adw_carousel_indicator_lines_init (AdwCarouselIndicatorLines *self)
{
AdwAnimationTarget *target
= adw_callback_animation_target_new ((AdwAnimationTargetFunc)
- gtk_widget_queue_resize,
+ indicator_lines_animation_cb,
self, NULL);
self->animation =
diff --git a/src/adw-carousel.c b/src/adw-carousel.c
index fc09ba23..a59a6817 100644
--- a/src/adw-carousel.c
+++ b/src/adw-carousel.c
@@ -279,8 +279,8 @@ set_position (AdwCarousel *self,
}
static void
-resize_animation_value_cb (ChildInfo *child,
- double value)
+resize_animation_value_cb (double value,
+ ChildInfo *child)
{
AdwCarousel *self = ADW_CAROUSEL (adw_animation_get_widget (child->resize_animation));
double delta = value - child->size;
@@ -348,8 +348,8 @@ shift_position (AdwCarousel *self,
}
static void
-scroll_animation_value_cb (AdwCarousel *self,
- double value)
+scroll_animation_value_cb (double value,
+ AdwCarousel *self)
{
double position = adw_lerp (self->animation_source_position,
self->animation_target_child->snap_point,
diff --git a/src/adw-flap.c b/src/adw-flap.c
index 4335dce1..cfdac2b6 100644
--- a/src/adw-flap.c
+++ b/src/adw-flap.c
@@ -263,8 +263,8 @@ update_shortcuts (AdwFlap *self)
}
static void
-set_reveal_progress (AdwFlap *self,
- double progress)
+set_reveal_progress (double progress,
+ AdwFlap *self)
{
self->reveal_progress = progress;
@@ -275,8 +275,8 @@ set_reveal_progress (AdwFlap *self,
}
static void
-fold_animation_value_cb (AdwFlap *self,
- double value)
+fold_animation_value_cb (double value,
+ AdwFlap *self)
{
self->fold_progress = value;
@@ -414,7 +414,7 @@ update_swipe_cb (AdwSwipeTracker *tracker,
double progress,
AdwFlap *self)
{
- set_reveal_progress (self, progress);
+ set_reveal_progress (progress, self);
}
static void
diff --git a/src/adw-tab-box.c b/src/adw-tab-box.c
index 1effdea5..b4dbbb2a 100644
--- a/src/adw-tab-box.c
+++ b/src/adw-tab-box.c
@@ -963,8 +963,8 @@ get_reorder_position (AdwTabBox *self)
}
static void
-reorder_animation_value_cb (TabInfo *dest_tab,
- double value)
+reorder_animation_value_cb (double value,
+ TabInfo *dest_tab)
{
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (dest_tab->tab));
AdwTabBox *self = ADW_TAB_BOX (parent);
@@ -1014,8 +1014,8 @@ animate_reordering (AdwTabBox *self,
}
static void
-reorder_offset_animation_value_cb (TabInfo *info,
- double value)
+reorder_offset_animation_value_cb (double value,
+ TabInfo *info)
{
GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (info->tab));
@@ -1564,8 +1564,8 @@ extra_drag_drop_cb (AdwTab *tab,
}
static void
-appear_animation_value_cb (TabInfo *info,
- double value)
+appear_animation_value_cb (double value,
+ TabInfo *info)
{
info->appear_progress = value;
@@ -1875,12 +1875,12 @@ calculate_placeholder_index (AdwTabBox *self,
}
static void
-insert_animation_value_cb (TabInfo *info,
- double value)
+insert_animation_value_cb (double value,
+ TabInfo *info)
{
AdwTabBox *self = ADW_TAB_BOX (gtk_widget_get_parent (GTK_WIDGET (info->tab)));
- appear_animation_value_cb (info, value);
+ appear_animation_value_cb (value, info);
update_drag_reodering (self);
}
@@ -2203,8 +2203,8 @@ tab_drag_cancel_cb (AdwTabBox *self,
}
static void
-icon_resize_animation_value_cb (DragIcon *icon,
- double value)
+icon_resize_animation_value_cb (double value,
+ DragIcon *icon)
{
double relative_pos;
@@ -2226,6 +2226,13 @@ icon_resize_animation_value_cb (DragIcon *icon,
gtk_widget_queue_resize (GTK_WIDGET (icon->tab));
}
+static void
+target_animation_cb (double value,
+ GtkWidget *self)
+{
+ gtk_widget_queue_resize (self);
+}
+
static void
create_drag_icon (AdwTabBox *self,
GdkDrag *drag)
@@ -3448,7 +3455,7 @@ adw_tab_box_init (AdwTabBox *self)
* well after one last update, so that we don't miss the last frame.
*/
target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
- gtk_widget_queue_resize,
+ target_animation_cb,
self, NULL);
self->scroll_animation =
adw_timed_animation_new (GTK_WIDGET (self), 0, 1,
diff --git a/src/adw-tab.c b/src/adw-tab.c
index 55dad957..9c1c55df 100644
--- a/src/adw-tab.c
+++ b/src/adw-tab.c
@@ -87,8 +87,8 @@ set_style_class (GtkWidget *widget,
}
static void
-close_btn_animation_value_cb (AdwTab *self,
- double value)
+close_btn_animation_value_cb (double value,
+ AdwTab *self)
{
gtk_widget_set_opacity (self->close_btn, value);
gtk_widget_set_can_target (self->close_btn, value > 0);
diff --git a/src/adw-toast-overlay.c b/src/adw-toast-overlay.c
index c22d0781..7585f3e9 100644
--- a/src/adw-toast-overlay.c
+++ b/src/adw-toast-overlay.c
@@ -121,8 +121,8 @@ dismiss_and_free_toast_info (ToastInfo *info)
}
static void
-hide_value_cb (ToastInfo *info,
- double value)
+hide_value_cb (double value,
+ ToastInfo *info)
{
value = adw_easing_ease (ADW_EASE_OUT_CUBIC, value);
gtk_widget_set_opacity (info->widget, value);
@@ -184,6 +184,13 @@ hide_current_toast (AdwToastOverlay *self)
adw_animation_play (info->hide_animation);
}
+static void
+show_toast_animation_cb (double value,
+ GtkWidget *self)
+{
+ gtk_widget_queue_allocate (self);
+}
+
static void
dismissed_cb (ToastInfo *info)
{
@@ -229,7 +236,7 @@ show_toast (AdwToastOverlay *self,
gtk_widget_insert_before (info->widget, GTK_WIDGET (self), NULL);
target = adw_callback_animation_target_new ((AdwAnimationTargetFunc)
- gtk_widget_queue_allocate,
+ show_toast_animation_cb,
self, NULL);
info->show_animation =
adw_timed_animation_new (GTK_WIDGET (self), 0, 1,
diff --git a/tests/test-animation.c b/tests/test-animation.c
index 2701f028..252f2930 100644
--- a/tests/test-animation.c
+++ b/tests/test-animation.c
@@ -12,8 +12,8 @@ static double last_value;
static int done_count;
static void
-value_cb (gpointer user_data,
- double value)
+value_cb (double value,
+ gpointer user_data)
{
last_value = value;
}
diff --git a/tests/test-timed-animation.c b/tests/test-timed-animation.c
index 679b1f3a..78e7db69 100644
--- a/tests/test-timed-animation.c
+++ b/tests/test-timed-animation.c
@@ -11,8 +11,8 @@
int notified;
static void
-value_cb (gpointer user_data,
- double value)
+value_cb (double value,
+ gpointer user_data)
{
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]