[gimp/wip/animation: 347/373] plug-ins: apply the camera preview on releasing mouse after dnd.



commit be86e42f2f2856ddb5ee3e185505b2d3e4915247
Author: Jehan <jehan girinstud io>
Date:   Mon Jun 26 23:30:55 2017 +0200

    plug-ins: apply the camera preview on releasing mouse after dnd.

 plug-ins/animation-play/core/animation-camera.c    |   29 ++++++++++++++++++++
 plug-ins/animation-play/core/animation-camera.h    |    1 +
 plug-ins/animation-play/widgets/animation-dialog.c |   12 +++++++-
 3 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation-camera.c b/plug-ins/animation-play/core/animation-camera.c
index 26a2780..d84cfdf 100644
--- a/plug-ins/animation-play/core/animation-camera.c
+++ b/plug-ins/animation-play/core/animation-camera.c
@@ -275,6 +275,35 @@ animation_camera_preview_keyframe (AnimationCamera *camera,
 }
 
 void
+animation_camera_apply_preview (AnimationCamera *camera)
+{
+  if (camera->priv->preview_offset)
+    {
+      gint preview_offset_x;
+      gint preview_offset_y;
+      gint real_offset_x;
+      gint real_offset_y;
+      gint position;
+
+      animation_camera_get (camera, camera->priv->preview_position,
+                            &preview_offset_x, &preview_offset_y);
+      animation_camera_get_real (camera, camera->priv->preview_position,
+                                 &real_offset_x, &real_offset_y);
+
+      g_free (camera->priv->preview_offset);
+      camera->priv->preview_offset    = NULL;
+      position = camera->priv->preview_position;
+      camera->priv->preview_position  = -1;
+
+      if (preview_offset_x != real_offset_x ||
+          preview_offset_y != real_offset_y)
+        animation_camera_set_keyframe (camera, position,
+                                       preview_offset_x,
+                                       preview_offset_y);
+    }
+}
+
+void
 animation_camera_reset_preview (AnimationCamera *camera)
 {
   gboolean offsets_changed = FALSE;
diff --git a/plug-ins/animation-play/core/animation-camera.h b/plug-ins/animation-play/core/animation-camera.h
index 0301679..344e6a8 100644
--- a/plug-ins/animation-play/core/animation-camera.h
+++ b/plug-ins/animation-play/core/animation-camera.h
@@ -70,6 +70,7 @@ void              animation_camera_preview_keyframe (AnimationCamera *camera,
                                                      gint             position,
                                                      gint             x,
                                                      gint             y);
+void              animation_camera_apply_preview    (AnimationCamera *camera);
 void              animation_camera_reset_preview    (AnimationCamera *camera);
 
 void              animation_camera_get              (AnimationCamera *camera,
diff --git a/plug-ins/animation-play/widgets/animation-dialog.c 
b/plug-ins/animation-play/widgets/animation-dialog.c
index 42d1f2d..c4a9452 100755
--- a/plug-ins/animation-play/widgets/animation-dialog.c
+++ b/plug-ins/animation-play/widgets/animation-dialog.c
@@ -251,6 +251,7 @@ static gboolean    da_button_press           (GtkWidget        *widget,
                                               GdkEventButton   *event,
                                               AnimationDialog  *dialog);
 static gboolean    da_button_released        (GtkWidget        *widget,
+                                              GdkEvent         *event,
                                               AnimationDialog  *dialog);
 static gboolean    da_button_motion          (GtkWidget        *widget,
                                               GdkEventMotion   *event,
@@ -2415,8 +2416,17 @@ da_button_press (GtkWidget       *widget,
 
 static gboolean
 da_button_released (GtkWidget       *widget,
+                    GdkEvent        *event,
                     AnimationDialog *dialog)
 {
+  AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
+  AnimationCelAnimation  *animation;
+  AnimationCamera        *camera;
+
+  animation = ANIMATION_CEL_ANIMATION (priv->animation);
+  camera = ANIMATION_CAMERA (animation_cel_animation_get_main_camera (animation));
+  animation_camera_apply_preview (camera);
+
   gtk_grab_remove (widget);
   gdk_display_pointer_ungrab (gtk_widget_get_display (widget), 0);
   gdk_flush ();
@@ -2462,7 +2472,7 @@ da_button_motion (GtkWidget       *widget,
     }
   else /* the user has released all buttons */
     {
-      da_button_released (widget, dialog);
+      da_button_released (widget, NULL, dialog);
     }
 
   return FALSE;


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