[gimp/wip/animation: 176/182] plug-ins: update the animatic when moving panels.



commit 00d109a1bc9387e2c01d73a9f47b80064b05f00e
Author: Jehan <jehan girinstud io>
Date:   Sat Jul 22 17:42:20 2017 +0200

    plug-ins: update the animatic when moving panels.
    
    Otherwise the render can't happen.

 plug-ins/animation-play/core/animation-animatic.c  |   63 ++++++++++++++++++++
 plug-ins/animation-play/core/animation-animatic.h  |    3 +
 .../animation-play/widgets/animation-storyboard.c  |    2 +
 3 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation-animatic.c 
b/plug-ins/animation-play/core/animation-animatic.c
index 8865a51..5835014 100644
--- a/plug-ins/animation-play/core/animation-animatic.c
+++ b/plug-ins/animation-play/core/animation-animatic.c
@@ -376,6 +376,69 @@ animation_animatic_get_position (AnimationAnimatic *animation,
   return pos;
 }
 
+void
+animation_animatic_move_panel (AnimationAnimatic *animation,
+                               gint               panel,
+                               gint               new_panel)
+{
+  AnimationAnimaticPrivate *priv = GET_PRIVATE (animation);
+
+  g_return_if_fail (panel >= 0  && new_panel >= 0 &&
+                    panel < priv->n_panels && new_panel < priv->n_panels);
+
+  if (panel != new_panel)
+    {
+      gint       tattoo;
+      gint       duration;
+      gboolean   combine;
+      gchar     *comment;
+      gint       changed_frame;
+      gint       changed_duration;
+
+      tattoo   = priv->tattoos[panel];
+      duration = priv->durations[panel];
+      combine  = priv->combine[panel];
+      comment  = priv->comments[panel];
+      if (panel < new_panel)
+        {
+          memmove (&priv->tattoos[panel], &priv->tattoos[panel + 1],
+                   (new_panel - panel) * sizeof (priv->tattoos[panel]));
+          memmove (&priv->durations[panel], &priv->durations[panel + 1],
+                   (new_panel - panel) * sizeof (priv->tattoos[panel]));
+          memmove (&priv->combine[panel], &priv->combine[panel + 1],
+                   (new_panel - panel) * sizeof (priv->tattoos[panel]));
+          memmove (&priv->comments[panel], &priv->comments[panel + 1],
+                   (new_panel - panel) * sizeof (priv->tattoos[panel]));
+        }
+      else
+        {
+          memmove (&priv->tattoos[new_panel + 1], &priv->tattoos[new_panel],
+                   (panel - new_panel) * sizeof (priv->comments[panel]));
+          memmove (&priv->durations[new_panel + 1], &priv->durations[new_panel],
+                   (panel - new_panel) * sizeof (priv->comments[panel]));
+          memmove (&priv->combine[new_panel + 1], &priv->combine[new_panel],
+                   (panel - new_panel) * sizeof (priv->comments[panel]));
+          memmove (&priv->comments[new_panel + 1], &priv->comments[new_panel],
+                   (panel - new_panel) * sizeof (priv->comments[panel]));
+        }
+      priv->tattoos[new_panel]   = tattoo;
+      priv->durations[new_panel] = duration;
+      priv->combine[new_panel]   = combine;
+      priv->comments[new_panel]  = comment;
+
+      /* Update renders. */
+      changed_frame = animation_animatic_get_position (animation,
+                                                       MIN (panel, new_panel));
+      changed_duration = animation_animatic_get_position (animation,
+                                                          MAX (panel, new_panel)) +
+                         animation_animatic_get_panel_duration (animation,
+                                                                MAX (panel, new_panel)) -
+                         changed_frame;
+      g_signal_emit_by_name (animation, "frames-changed",
+                             changed_frame, changed_duration);
+    }
+}
+
 /**** Virtual methods ****/
 
 static gint
diff --git a/plug-ins/animation-play/core/animation-animatic.h 
b/plug-ins/animation-play/core/animation-animatic.h
index 7860c0a..f0c84e5 100644
--- a/plug-ins/animation-play/core/animation-animatic.h
+++ b/plug-ins/animation-play/core/animation-animatic.h
@@ -68,4 +68,7 @@ gint             animation_animatic_get_panel          (AnimationAnimatic *anima
 gint             animation_animatic_get_position       (AnimationAnimatic *animation,
                                                         gint               panel);
 
+void             animation_animatic_move_panel         (AnimationAnimatic *animatic,
+                                                        gint               panel,
+                                                        gint               new_panel);
 #endif  /*  __ANIMATION_ANIMATIC_H__  */
diff --git a/plug-ins/animation-play/widgets/animation-storyboard.c 
b/plug-ins/animation-play/widgets/animation-storyboard.c
index e7b9c87..0e038fa 100644
--- a/plug-ins/animation-play/widgets/animation-storyboard.c
+++ b/plug-ins/animation-play/widgets/animation-storyboard.c
@@ -896,5 +896,7 @@ animation_storyboard_move (AnimationStoryboard *storyboard,
           g_object_set_data (G_OBJECT (iter->data), "panel-num",
                              GINT_TO_POINTER (i));
         }
+      animation_animatic_move_panel (storyboard->priv->animation,
+                                     from_panel, to_panel);
     }
 }


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