[gimp/wip/animation: 124/145] plug-ins: very basic onion-skinning.



commit 5c4cc52dc87cbb55eda1de1b2cf0a7a6741971b9
Author: Jehan <jehan girinstud io>
Date:   Fri Jun 23 16:05:25 2017 +0200

    plug-ins: very basic onion-skinning.
    
    Add onion-skinning when viewing in GIMP. I don't use onion-skinning in
    the preview (plug-in display area) because that is mostly used for
    painting. When actually previewing the video, you will want the "normal"
    animation.
    This is right now hard-coded in the sync feature (when double-clicking
    the frame) but in the hand, this will have to be customizable. Also the
    limitation is that if you wanted to use opacity feature in the finale
    rendering, as well as various kind of effects.
    Also set the last layer of the current position as the active layer.
    There are definitely better logics than this (in particular if some cels
    are selected), but that's a first step towards better.

 plug-ins/animation-play/animation-utils.c          |   10 ++++--
 plug-ins/animation-play/animation-utils.h          |    5 ++-
 .../animation-play/core/animation-celanimation.c   |   31 ++++++++++++++++++-
 3 files changed, 39 insertions(+), 7 deletions(-)
---
diff --git a/plug-ins/animation-play/animation-utils.c b/plug-ins/animation-play/animation-utils.c
index 76fe3fb..f4bfdd0 100755
--- a/plug-ins/animation-play/animation-utils.c
+++ b/plug-ins/animation-play/animation-utils.c
@@ -301,19 +301,23 @@ hide_item (gint     item,
 }
 
 void
-show_item (gint   item,
-           gint32 color_tag)
+show_layer (gint    item,
+            gint32  color_tag,
+            gdouble opacity)
 {
   gint32 parent;
 
   gimp_item_set_visible (item, TRUE);
   if (color_tag >= 0)
     gimp_item_set_color_tag (item, color_tag);
+  gimp_layer_set_opacity (item, opacity * 100.0);
 
   /* Show the parent as well, but do not update its color tag. */
   parent = gimp_item_get_parent (item);
   if (parent > 0)
-    show_item (parent, -1);
+    {
+      show_layer (parent, -1, 1.0);
+    }
 }
 
 gint
diff --git a/plug-ins/animation-play/animation-utils.h b/plug-ins/animation-play/animation-utils.h
index 30d3bf2..1be135f 100755
--- a/plug-ins/animation-play/animation-utils.h
+++ b/plug-ins/animation-play/animation-utils.h
@@ -59,8 +59,9 @@ void         show_scrolled_child (GtkScrolledWindow *window,
 void         hide_item           (gint               item,
                                   gboolean           recursive,
                                   gboolean           reset_color_tag);
-void         show_item           (gint               item,
-                                  gint32             color_tag);
+void         show_layer          (gint               item,
+                                  gint32             color_tag,
+                                  gdouble            opacity);
 
 gint         compare_int_from    (gconstpointer      f1,
                                   gconstpointer      f2,
diff --git a/plug-ins/animation-play/core/animation-celanimation.c 
b/plug-ins/animation-play/core/animation-celanimation.c
index eabcd4c..0d04cea 100644
--- a/plug-ins/animation-play/core/animation-celanimation.c
+++ b/plug-ins/animation-play/core/animation-celanimation.c
@@ -954,6 +954,7 @@ animation_cel_animation_update_paint_view (Animation *animation,
   GList                 *iter;
   gint                   num_layers;
   gint32                 image_id;
+  gint                   last_layer;
   gint                   i;
 
   cel_animation = ANIMATION_CEL_ANIMATION (animation);
@@ -966,7 +967,7 @@ animation_cel_animation_update_paint_view (Animation *animation,
       hide_item (layers[i], TRUE, TRUE);
     }
 
-  /* Show layers */
+  /* Show layers from current position. */
   for (iter = cel_animation->priv->tracks; iter; iter = iter->next)
     {
       Track *track = iter->data;
@@ -982,9 +983,35 @@ animation_cel_animation_update_paint_view (Animation *animation,
 
           tattoo = GPOINTER_TO_INT (iter2->data);
           layer = gimp_image_get_layer_by_tattoo (image_id, tattoo);
-          show_item (layer, GIMP_COLOR_TAG_RED);
+          show_layer (layer, GIMP_COLOR_TAG_RED, 1.0);
+          last_layer = layer;
         }
     }
+
+  if (position > 0)
+    {
+      /* Show layers from previous position (onion skinning). */
+      for (iter = cel_animation->priv->tracks; iter; iter = iter->next)
+        {
+          Track *track = iter->data;
+          GList *frame_layers;
+          GList *iter2;
+
+          frame_layers = g_list_nth_data (track->frames, position - 1);
+
+          for (iter2 = frame_layers; iter2; iter2 = iter2->next)
+            {
+              gint tattoo;
+              gint layer;
+
+              tattoo = GPOINTER_TO_INT (iter2->data);
+              layer = gimp_image_get_layer_by_tattoo (image_id, tattoo);
+              if (! gimp_item_get_visible (layer))
+                show_layer (layer, GIMP_COLOR_TAG_ORANGE, 0.5);
+            }
+        }
+    }
+  gimp_image_set_active_layer (image_id, last_layer);
 }
 
 static void


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