[gimp/wip/animation: 346/373] plug-ins: allow dragging the display area for camera.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 346/373] plug-ins: allow dragging the display area for camera.
- Date: Sat, 7 Oct 2017 02:23:48 +0000 (UTC)
commit aec63a60176d6d95bcad1478ccaf63595cefc3f7
Author: Jehan <jehan girinstud io>
Date: Mon Jun 26 22:36:36 2017 +0200
plug-ins: allow dragging the display area for camera.
It's much too slow, but that's a first step.
plug-ins/animation-play/widgets/animation-dialog.c | 96 +++++++++++++++++++-
.../widgets/animation-keyframe-view.c | 9 ++
2 files changed, 102 insertions(+), 3 deletions(-)
---
diff --git a/plug-ins/animation-play/widgets/animation-dialog.c
b/plug-ins/animation-play/widgets/animation-dialog.c
index f8e9b57..42d1f2d 100755
--- a/plug-ins/animation-play/widgets/animation-dialog.c
+++ b/plug-ins/animation-play/widgets/animation-dialog.c
@@ -48,7 +48,7 @@
/* for shaping */
typedef struct
{
- gint x, y;
+ gdouble x, y;
} CursorOffset;
enum
@@ -250,6 +250,11 @@ static gboolean repaint_da (GtkWidget *darea,
static gboolean da_button_press (GtkWidget *widget,
GdkEventButton *event,
AnimationDialog *dialog);
+static gboolean da_button_released (GtkWidget *widget,
+ AnimationDialog *dialog);
+static gboolean da_button_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ AnimationDialog *dialog);
static gboolean da_scrolled (GtkWidget *widget,
GdkEventScroll *event,
AnimationDialog *dialog);
@@ -770,15 +775,26 @@ animation_dialog_constructed (GObject *object)
gtk_container_add (GTK_CONTAINER (abox), priv->drawing_area);
gtk_widget_show (priv->drawing_area);
+ gtk_widget_add_events (priv->drawing_area,
+ GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK | GDK_SCROLL_MASK);
g_signal_connect (priv->drawing_area, "size-allocate",
G_CALLBACK (da_size_callback),
dialog);
g_signal_connect (priv->drawing_area, "button-press-event",
G_CALLBACK (da_button_press),
dialog);
+ g_signal_connect (priv->drawing_area, "button-release-event",
+ G_CALLBACK (da_button_released),
+ dialog);
+ g_signal_connect (priv->drawing_area, "motion-notify-event",
+ G_CALLBACK (da_button_motion),
+ dialog);
g_signal_connect (priv->drawing_area, "scroll-event",
G_CALLBACK (da_scrolled),
dialog);
+ g_object_set_data (G_OBJECT (priv->drawing_area),
+ "cursor-offset", g_new0 (CursorOffset, 1));
/*****************/
/* Play toolbar. */
@@ -2374,6 +2390,80 @@ da_button_press (GtkWidget *widget,
event->time);
return TRUE;
}
+ else if (event->type == GDK_BUTTON_PRESS)
+ {
+ CursorOffset *p = g_object_get_data (G_OBJECT (widget),
+ "cursor-offset");
+
+ if (! p)
+ return FALSE;
+
+ p->x = event->x;
+ p->y = event->y;
+
+ gtk_grab_add (widget);
+ gdk_pointer_grab (gtk_widget_get_window (widget), TRUE,
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_BUTTON_MOTION_MASK |
+ GDK_POINTER_MOTION_HINT_MASK,
+ NULL, NULL, 0);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+da_button_released (GtkWidget *widget,
+ AnimationDialog *dialog)
+{
+ gtk_grab_remove (widget);
+ gdk_display_pointer_ungrab (gtk_widget_get_display (widget), 0);
+ gdk_flush ();
+
+ return FALSE;
+}
+
+static gboolean
+da_button_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ AnimationDialog *dialog)
+{
+ AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
+
+ /* if a button is still held by the time we process this event... */
+ if (event->state & GDK_BUTTON1_MASK)
+ {
+ CursorOffset *p = g_object_get_data (G_OBJECT (widget),
+ "cursor-offset");
+
+ if (! p)
+ return FALSE;
+
+ if (ANIMATION_IS_CEL_ANIMATION (priv->animation))
+ {
+ AnimationCelAnimation *animation;
+ AnimationCamera *camera;
+ gint position;
+ gint x_offset;
+ gint y_offset;
+
+ animation = ANIMATION_CEL_ANIMATION (priv->animation);
+ camera = ANIMATION_CAMERA (animation_cel_animation_get_main_camera (animation));
+ position = animation_playback_get_position (priv->playback);
+ animation_camera_get (camera, position, &x_offset, &y_offset);
+ animation_camera_preview_keyframe (camera, position,
+ x_offset + (event->x - p->x) / priv->zoom,
+ y_offset + (event->y - p->y) / priv->zoom);
+ p->x = event->x;
+ p->y = event->y;
+ return TRUE;
+ }
+ }
+ else /* the user has released all buttons */
+ {
+ da_button_released (widget, dialog);
+ }
return FALSE;
}
@@ -2511,8 +2601,8 @@ shape_pressed (GtkWidget *widget,
if (!p)
return FALSE;
- p->x = (gint) event->x;
- p->y = (gint) event->y;
+ p->x = event->x;
+ p->y = event->y;
gtk_grab_add (widget);
gdk_pointer_grab (gtk_widget_get_window (widget), TRUE,
diff --git a/plug-ins/animation-play/widgets/animation-keyframe-view.c
b/plug-ins/animation-play/widgets/animation-keyframe-view.c
index 6ce4d65..a34973f 100644
--- a/plug-ins/animation-play/widgets/animation-keyframe-view.c
+++ b/plug-ins/animation-play/widgets/animation-keyframe-view.c
@@ -46,6 +46,8 @@ struct _AnimationKeyFrameViewPrivate
/* GObject handlers */
static void animation_keyframe_view_constructed (GObject *object);
+static void animation_keyframe_view_dispose (GObject *object);
+
static gboolean animation_keyframe_update_source (gpointer user_data);
static void on_offset_entry_changed (GimpSizeEntry *entry,
@@ -65,6 +67,7 @@ animation_keyframe_view_class_init (AnimationKeyFrameViewClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructed = animation_keyframe_view_constructed;
+ object_class->dispose = animation_keyframe_view_dispose;
g_type_class_add_private (klass, sizeof (AnimationKeyFrameViewPrivate));
}
@@ -192,6 +195,12 @@ animation_keyframe_view_hide (AnimationKeyFrameView *view)
/************ Private Functions ****************/
+static void animation_keyframe_view_dispose (GObject *object)
+{
+ animation_keyframe_view_hide (ANIMATION_KEYFRAME_VIEW (object));
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
static void
animation_keyframe_view_constructed (GObject *object)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]