[gimp/wip/animation: 93/197] plug-ins: in x-sheet and storyboard, do not jump to current panel...



commit ceb582c6ed483438b8826f3b5635a35f5caeff93
Author: Jehan <jehan girinstud io>
Date:   Sun Nov 13 23:09:11 2016 +0100

    plug-ins: in x-sheet and storyboard, do not jump to current panel...
    
    ... and position while playing. This is too fast and just disturbing.
    We must jump to the frame position (X-Sheet) or the panel (storyboard)
    only when the playback stops or when one jumps without playing.

 .../animation-play/widgets/animation-storyboard.c  |   66 ++++++++++++++-----
 plug-ins/animation-play/widgets/animation-xsheet.c |   68 ++++++++++++++------
 2 files changed, 98 insertions(+), 36 deletions(-)
---
diff --git a/plug-ins/animation-play/widgets/animation-storyboard.c 
b/plug-ins/animation-play/widgets/animation-storyboard.c
index 286906d..625e38f 100644
--- a/plug-ins/animation-play/widgets/animation-storyboard.c
+++ b/plug-ins/animation-play/widgets/animation-storyboard.c
@@ -68,6 +68,8 @@ static void animation_storyboard_finalize              (GObject             *obj
 /* Callbacks on animation */
 static void animation_storyboard_load                  (Animation           *animation,
                                                         AnimationStoryboard *view);
+static void animation_storyboard_stopped               (AnimationPlayback   *playback,
+                                                        AnimationStoryboard *view);
 static void animation_storyboard_rendered              (AnimationPlayback   *playback,
                                                         gint                 frame_number,
                                                         GeglBuffer          *buffer,
@@ -87,6 +89,10 @@ static void animation_storyboard_disposal_toggled      (GtkToggleButton     *but
 static void animation_storyboard_button_clicked        (GtkWidget           *widget,
                                                         AnimationStoryboard *storyboard);
 
+/* Utils */
+static void animation_storyboard_jump                  (AnimationStoryboard *view,
+                                                        gint                 panel);
+
 G_DEFINE_TYPE (AnimationStoryboard, animation_storyboard, GTK_TYPE_SCROLLED_WINDOW)
 
 #define parent_class animation_storyboard_parent_class
@@ -427,35 +433,37 @@ animation_storyboard_load (Animation           *animation,
   g_signal_connect (view->priv->playback, "render",
                     (GCallback) animation_storyboard_rendered,
                     view);
+  g_signal_connect (view->priv->playback, "stop",
+                    (GCallback) animation_storyboard_stopped,
+                    view);
   gimp_image_delete (image_id);
 }
 
 static void
+animation_storyboard_stopped (AnimationPlayback   *playback,
+                              AnimationStoryboard *view)
+{
+  gint position;
+  gint panel;
+
+  position = animation_playback_get_position (playback);
+  panel = animation_animatic_get_panel (view->priv->animation,
+                                        position);
+  animation_storyboard_jump (view, panel);
+}
+
+static void
 animation_storyboard_rendered (AnimationPlayback   *playback,
                                gint                 frame_number,
                                GeglBuffer          *buffer,
                                gboolean             must_draw_null,
                                AnimationStoryboard *view)
 {
-  GtkWidget *button;
-  gint       panel;
+  gint panel;
 
   panel = animation_animatic_get_panel (view->priv->animation,
                                         frame_number);
-  if (view->priv->current_panel >= 0)
-    {
-      button = g_list_nth_data (view->priv->panel_buttons,
-                                view->priv->current_panel);
-      gtk_button_set_relief (GTK_BUTTON (button),
-                             GTK_RELIEF_NONE);
-    }
-
-  view->priv->current_panel = panel;
-  button = g_list_nth_data (view->priv->panel_buttons,
-                            view->priv->current_panel);
-  gtk_button_set_relief (GTK_BUTTON (button),
-                         GTK_RELIEF_NORMAL);
-  show_scrolled_child (GTK_SCROLLED_WINDOW (view), button);
+  animation_storyboard_jump (view, panel);
 }
 
 static void
@@ -564,3 +572,29 @@ animation_storyboard_button_clicked (GtkWidget           *widget,
                                               GPOINTER_TO_INT (panel_num));
   animation_playback_jump (storyboard->priv->playback, position);
 }
+
+static void
+animation_storyboard_jump (AnimationStoryboard *view,
+                           gint                 panel)
+{
+  /* Don't jump while playing. This is too disturbing. */
+  if (! animation_playback_is_playing (view->priv->playback))
+    {
+      GtkWidget *button;
+
+      if (view->priv->current_panel >= 0)
+        {
+          button = g_list_nth_data (view->priv->panel_buttons,
+                                    view->priv->current_panel);
+          gtk_button_set_relief (GTK_BUTTON (button),
+                                 GTK_RELIEF_NONE);
+        }
+
+      view->priv->current_panel = panel;
+      button = g_list_nth_data (view->priv->panel_buttons,
+                                view->priv->current_panel);
+      gtk_button_set_relief (GTK_BUTTON (button),
+                             GTK_RELIEF_NORMAL);
+      show_scrolled_child (GTK_SCROLLED_WINDOW (view), button);
+    }
+}
diff --git a/plug-ins/animation-play/widgets/animation-xsheet.c 
b/plug-ins/animation-play/widgets/animation-xsheet.c
index 95e65cf..f79b44f 100755
--- a/plug-ins/animation-play/widgets/animation-xsheet.c
+++ b/plug-ins/animation-play/widgets/animation-xsheet.c
@@ -78,16 +78,18 @@ static void    animation_xsheet_get_property (GObject      *object,
 static void    animation_xsheet_finalize     (GObject      *object);
 
 /* Construction methods */
-static void     animation_xsheet_reset_layout  (AnimationXSheet *xsheet);
-static gboolean animation_xsheet_update_layout (AnimationXSheet *xsheet);
+static void     animation_xsheet_reset_layout  (AnimationXSheet   *xsheet);
+static gboolean animation_xsheet_update_layout (AnimationXSheet   *xsheet);
 
 /* Callbacks on animation. */
-static void     on_animation_loaded            (Animation       *animation,
-                                                AnimationXSheet *xsheet);
+static void     on_animation_loaded            (Animation         *animation,
+                                                AnimationXSheet   *xsheet);
 static void     on_animation_duration_changed  (Animation         *animation,
                                                 gint               duration,
                                                 AnimationXSheet   *xsheet);
 /* Callbacks on playback. */
+static void     on_animation_stopped           (AnimationPlayback *playback,
+                                                AnimationXSheet   *xsheet);
 static void     on_animation_rendered          (AnimationPlayback *animation,
                                                 gint               frame_number,
                                                 GeglBuffer        *buffer,
@@ -127,6 +129,8 @@ static void     on_track_right_clicked               (GtkToolButton   *toolbutto
 static void     animation_xsheet_rename_cel          (AnimationXSheet *xsheet,
                                                       GtkWidget       *cel,
                                                       gboolean         recursively);
+static void     animation_xsheet_jump                (AnimationXSheet *xsheet,
+                                                      gint             position);
 
 G_DEFINE_TYPE (AnimationXSheet, animation_xsheet, GTK_TYPE_SCROLLED_WINDOW)
 
@@ -189,6 +193,9 @@ animation_xsheet_new (AnimationCelAnimation *animation,
   g_signal_connect (ANIMATION_XSHEET (xsheet)->priv->playback,
                     "render", G_CALLBACK (on_animation_rendered),
                     xsheet);
+  g_signal_connect (ANIMATION_XSHEET (xsheet)->priv->playback,
+                    "stop", G_CALLBACK (on_animation_stopped),
+                    xsheet);
 
   return xsheet;
 }
@@ -280,6 +287,9 @@ animation_xsheet_finalize (GObject *object)
   g_signal_handlers_disconnect_by_func (ANIMATION_XSHEET (xsheet)->priv->playback,
                                         G_CALLBACK (on_animation_rendered),
                                         xsheet);
+  g_signal_handlers_disconnect_by_func (ANIMATION_XSHEET (xsheet)->priv->playback,
+                                        G_CALLBACK (on_animation_stopped),
+                                        xsheet);
   if (xsheet->priv->animation)
     g_object_unref (xsheet->priv->animation);
   if (xsheet->priv->layer_view)
@@ -842,28 +852,21 @@ on_animation_duration_changed (Animation       *animation,
 }
 
 static void
+on_animation_stopped (AnimationPlayback   *playback,
+                      AnimationXSheet     *xsheet)
+{
+  animation_xsheet_jump (xsheet,
+                         animation_playback_get_position (playback));
+}
+
+static void
 on_animation_rendered (AnimationPlayback *playback,
                        gint               frame_number,
                        GeglBuffer        *buffer,
                        gboolean           must_draw_null,
                        AnimationXSheet   *xsheet)
 {
-  GtkWidget *button;
-
-  button = g_list_nth_data (xsheet->priv->position_buttons,
-                            frame_number);
-  if (xsheet->priv->active_pos_button)
-    {
-      GtkToggleButton *active_button;
-
-      active_button = GTK_TOGGLE_BUTTON (xsheet->priv->active_pos_button);
-      gtk_toggle_button_set_active (active_button, FALSE);
-    }
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                TRUE);
-  xsheet->priv->active_pos_button = button;
-
-  show_scrolled_child (GTK_SCROLLED_WINDOW (xsheet), button);
+  animation_xsheet_jump (xsheet, frame_number);
 }
 
 static gboolean
@@ -1247,3 +1250,28 @@ animation_xsheet_rename_cel (AnimationXSheet *xsheet,
         }
     }
 }
+
+static void
+animation_xsheet_jump (AnimationXSheet *xsheet,
+                       gint             position)
+{
+  if (! animation_playback_is_playing (xsheet->priv->playback))
+    {
+      GtkWidget *button;
+
+      button = g_list_nth_data (xsheet->priv->position_buttons,
+                                position);
+      if (xsheet->priv->active_pos_button)
+        {
+          GtkToggleButton *active_button;
+
+          active_button = GTK_TOGGLE_BUTTON (xsheet->priv->active_pos_button);
+          gtk_toggle_button_set_active (active_button, FALSE);
+        }
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+                                    TRUE);
+      xsheet->priv->active_pos_button = button;
+
+      show_scrolled_child (GTK_SCROLLED_WINDOW (xsheet), button);
+    }
+}


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