[libadwaita/wip/exalm/browsing-view: 1/5] remove transition




commit e24e87c21f52929d7e6d26869fc8e0248cf7619d
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Oct 5 00:25:57 2022 +0400

    remove transition

 src/adw-window-mixin.c | 75 ++++----------------------------------------------
 1 file changed, 5 insertions(+), 70 deletions(-)
---
diff --git a/src/adw-window-mixin.c b/src/adw-window-mixin.c
index d2a27e55..ab297ddf 100644
--- a/src/adw-window-mixin.c
+++ b/src/adw-window-mixin.c
@@ -12,11 +12,8 @@
 #include "adw-adaptive-state-private.h"
 #include "adw-gizmo-private.h"
 #include "adw-macros-private.h"
-#include "adw-timed-animation.h"
 #include "adw-widget-utils-private.h"
 
-#define TRANSITION_DURATION 250
-
 struct _AdwWindowMixin
 {
   GObject parent;
@@ -32,11 +29,7 @@ struct _AdwWindowMixin
   GList *states;
   AdwAdaptiveState *current_state;
 
-  gboolean state_changing;
   GskRenderNode *old_node;
-  int old_width;
-  int old_height;
-  AdwAnimation *animation;
   gboolean first_allocation;
   guint tick_cb_id;
   gboolean block_warnings;
@@ -51,21 +44,6 @@ enum {
 
 static guint signals[SIGNAL_LAST_SIGNAL];
 
-static void
-animation_cb (double          value,
-              AdwWindowMixin *self)
-{
-  gtk_widget_queue_draw (GTK_WIDGET (self->window));
-}
-
-static void
-animation_done_cb (AdwWindowMixin *self)
-{
-  self->old_node = NULL;
-  self->old_width = 0;
-  self->old_height = 0;
-}
-
 static void
 measure_content (AdwGizmo       *gizmo,
                  GtkOrientation  orientation,
@@ -106,7 +84,7 @@ allocate_content (AdwGizmo *gizmo,
   AdwWindowMixin *self = g_object_get_data (G_OBJECT (gizmo), "adw-window-mixin");
   int min_width, min_height;
 
-  if (self->state_changing)
+  if (self->old_node)
     return;
 
   if (!self->content)
@@ -163,13 +141,10 @@ state_changed_tick_cb (GtkWidget      *widget,
                        AdwWindowMixin *self)
 {
   self->tick_cb_id = 0;
-  self->state_changing = FALSE;
+  self->old_node = NULL;
   gtk_widget_set_child_visible (self->child, TRUE);
   gtk_widget_queue_resize (GTK_WIDGET (self->window));
 
-  adw_animation_reset (self->animation);
-  adw_animation_play (self->animation);
-
   return G_SOURCE_REMOVE;
 }
 
@@ -222,10 +197,7 @@ adw_window_mixin_size_allocate (AdwWindowMixin *self,
     adw_window_mixin_snapshot (self, snapshot);
 
     self->old_node = gtk_snapshot_free_to_node (snapshot);
-    self->old_width = gtk_widget_get_width (GTK_WIDGET (self->window));
-    self->old_height = gtk_widget_get_height (GTK_WIDGET (self->window));
 
-    self->state_changing = TRUE;
     gtk_widget_set_child_visible (self->child, FALSE);
   }
 
@@ -253,52 +225,22 @@ adw_window_mixin_size_allocate (AdwWindowMixin *self,
   }
 }
 
-static inline void
-draw_old_node (AdwWindowMixin *self,
-               GtkSnapshot    *snapshot)
-{
-  float scale_x, scale_y;
-
-  if (!self->old_node)
-    return;
-
-  scale_x = (float) gtk_widget_get_width (GTK_WIDGET (self->window)) / self->old_width;
-  scale_y = (float) gtk_widget_get_height (GTK_WIDGET (self->window)) / self->old_height;
-
-  gtk_snapshot_save (snapshot);
-  gtk_snapshot_scale (snapshot, scale_x, scale_y);
-  gtk_snapshot_append_node (snapshot, self->old_node);
-  gtk_snapshot_restore (snapshot);
-}
-
 void
 adw_window_mixin_snapshot (AdwWindowMixin *self,
                            GtkSnapshot    *snapshot)
 {
-  if (self->state_changing) {
-    draw_old_node (self, snapshot);
+  if (self->old_node) {
+    gtk_snapshot_append_node (snapshot, self->old_node);
     return;
   }
 
-  if (!self->old_node ||
-      adw_animation_get_state (self->animation) != ADW_ANIMATION_PLAYING) {
-    GTK_WIDGET_CLASS (self->klass)->snapshot (GTK_WIDGET (self->window), snapshot);
-    return;
-  }
-
-  gtk_snapshot_push_cross_fade (snapshot, adw_animation_get_value (self->animation));
-
-  draw_old_node (self, snapshot);
-  gtk_snapshot_pop (snapshot);
-
   GTK_WIDGET_CLASS (self->klass)->snapshot (GTK_WIDGET (self->window), snapshot);
-  gtk_snapshot_pop (snapshot);
 }
 
 void
 adw_window_mixin_realize (AdwWindowMixin *self)
 {
-  self->first_allocation = TRUE;
+//  self->first_allocation = TRUE;
 
   GTK_WIDGET_CLASS (self->klass)->realize (GTK_WIDGET (self->window));
 }
@@ -313,8 +255,6 @@ adw_window_mixin_dispose (GObject *object)
     self->tick_cb_id = 0;
   }
 
-  g_clear_object (&self->animation);
-
   if (self->states) {
     g_list_free_full (self->states, g_object_unref);
     self->states = NULL;
@@ -350,7 +290,6 @@ adw_window_mixin_new (GtkWindow      *window,
                       GtkWindowClass *klass)
 {
   AdwWindowMixin *self;
-  AdwAnimationTarget *target;
 
   g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
   g_return_val_if_fail (GTK_IS_WINDOW_CLASS (klass), NULL);
@@ -374,10 +313,6 @@ adw_window_mixin_new (GtkWindow      *window,
   g_object_set_data (G_OBJECT (self->child), "adw-window-mixin", self);
   gtk_window_set_child (window, self->child);
 
-  target = adw_callback_animation_target_new ((AdwAnimationTargetFunc) animation_cb, self, NULL);
-  self->animation = adw_timed_animation_new (GTK_WIDGET (window), 0, 1, TRANSITION_DURATION, target);
-  g_signal_connect_swapped (self->animation, "done", G_CALLBACK (animation_done_cb), self);
-
   return self;
 }
 


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