[gimp/wip/animation: 244/373] plug-ins: some basic X-Sheet layout.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 244/373] plug-ins: some basic X-Sheet layout.
- Date: Sat, 7 Oct 2017 02:15:14 +0000 (UTC)
commit 53cb10e5a551a26ae033652a786cb0d4dd7c022c
Author: Jehan <jehan girinstud io>
Date: Mon Aug 8 04:04:35 2016 +0200
plug-ins: some basic X-Sheet layout.
plug-ins/animation-play/Makefile.am | 2 +
.../animation-play/core/animation-celanimation.c | 23 ++
.../animation-play/core/animation-celanimation.h | 12 +-
plug-ins/animation-play/widgets/animation-dialog.c | 25 ++
plug-ins/animation-play/widgets/animation-xsheet.c | 324 ++++++++++++++++++++
plug-ins/animation-play/widgets/animation-xsheet.h | 52 ++++
6 files changed, 434 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/animation-play/Makefile.am b/plug-ins/animation-play/Makefile.am
index 9c88c64..4774dd7 100644
--- a/plug-ins/animation-play/Makefile.am
+++ b/plug-ins/animation-play/Makefile.am
@@ -55,6 +55,8 @@ animation_play_SOURCES = \
widgets/animation-storyboard.c \
widgets/animation-layer-view.h \
widgets/animation-layer-view.c \
+ widgets/animation-xsheet.h \
+ widgets/animation-xsheet.c \
animation-utils.h \
animation-utils.c \
animation-play.c
diff --git a/plug-ins/animation-play/core/animation-celanimation.c
b/plug-ins/animation-play/core/animation-celanimation.c
index 8457a2a..8e2fabd 100644
--- a/plug-ins/animation-play/core/animation-celanimation.c
+++ b/plug-ins/animation-play/core/animation-celanimation.c
@@ -265,6 +265,29 @@ animation_cel_animation_set_duration (AnimationCelAnimation *animation,
animation->priv->duration = duration;
}
+gint
+animation_cel_animation_get_levels (AnimationCelAnimation *animation)
+{
+ return g_list_length (animation->priv->tracks);
+}
+
+const gchar *
+animation_cel_animation_get_track_title (AnimationCelAnimation *animation,
+ gint level)
+{
+ gchar *title = NULL;
+ GList *track;
+
+ track = g_list_nth (animation->priv->tracks, level);
+
+ if (track)
+ {
+ title = ((Track *) track->data)->title;
+ }
+
+ return title;
+}
+
/**** Virtual methods ****/
static gint
diff --git a/plug-ins/animation-play/core/animation-celanimation.h
b/plug-ins/animation-play/core/animation-celanimation.h
index 3e30fc4..b754a90 100644
--- a/plug-ins/animation-play/core/animation-celanimation.h
+++ b/plug-ins/animation-play/core/animation-celanimation.h
@@ -46,17 +46,21 @@ struct _AnimationCelAnimationClass
AnimationClass parent_class;
};
-GType animation_cel_animation_get_type (void);
+GType animation_cel_animation_get_type (void);
-void animation_cel_animation_set_comment (AnimationCelAnimation *animation,
+void animation_cel_animation_set_comment (AnimationCelAnimation *animation,
gint position,
const gchar *comment);
-const gchar * animation_cel_animation_get_comment (AnimationCelAnimation *animation,
+const gchar * animation_cel_animation_get_comment (AnimationCelAnimation *animation,
gint position);
-void animation_cel_animation_set_duration (AnimationCelAnimation *animation,
+void animation_cel_animation_set_duration (AnimationCelAnimation *animation,
gint duration);
+gint animation_cel_animation_get_levels (AnimationCelAnimation *animation);
+
+const gchar * animation_cel_animation_get_track_title (AnimationCelAnimation *animation,
+ gint level);
#endif /* __ANIMATION_CEL_ANIMATION_H__ */
diff --git a/plug-ins/animation-play/widgets/animation-dialog.c
b/plug-ins/animation-play/widgets/animation-dialog.c
index f386189..e18c64b 100755
--- a/plug-ins/animation-play/widgets/animation-dialog.c
+++ b/plug-ins/animation-play/widgets/animation-dialog.c
@@ -30,10 +30,12 @@
#include "core/animation.h"
#include "core/animationanimatic.h"
+#include "core/animation-celanimation.h"
#include "animation-dialog.h"
#include "animation-layer-view.h"
#include "animation-storyboard.h"
+#include "animation-xsheet.h"
#include "libgimp/stdplugins-intl.h"
@@ -94,6 +96,7 @@ struct _AnimationDialogPrivate
/* The vpaned (bottom is timeline, above is preview). */
GtkWidget *vpaned;
+ GtkWidget *xsheet;
/* Actions */
GtkUIManager *ui_manager;
@@ -1218,6 +1221,7 @@ animation_dialog_set_animation (AnimationDialog *dialog,
G_CALLBACK (progress_button),
dialog);
+ /* The right panel. */
frame = gtk_paned_get_child2 (GTK_PANED (priv->hpaned));
if (frame)
{
@@ -1264,6 +1268,27 @@ animation_dialog_set_animation (AnimationDialog *dialog,
gtk_combo_box_set_active (GTK_COMBO_BOX (priv->animation_type_combo), 1);
}
+ /* The bottom panel. */
+ frame = gtk_paned_get_child2 (GTK_PANED (priv->vpaned));
+ if (frame)
+ {
+ gtk_widget_destroy (frame);
+ priv->xsheet = NULL;
+ }
+
+ if (ANIMATION_IS_CEL_ANIMATION (animation))
+ {
+ frame = gtk_frame_new (_("X-Sheet"));
+ gtk_paned_pack2 (GTK_PANED (priv->vpaned), frame,
+ TRUE, TRUE);
+ gtk_widget_show (frame);
+
+ priv->xsheet = animation_xsheet_new (ANIMATION_CEL_ANIMATION (animation),
+ priv->layer_list);
+ gtk_container_add (GTK_CONTAINER (frame), priv->xsheet);
+ gtk_widget_show (priv->xsheet);
+ }
+
/* Animation type. */
g_signal_handlers_unblock_by_func (priv->animation_type_combo,
G_CALLBACK (animation_type_changed),
diff --git a/plug-ins/animation-play/widgets/animation-xsheet.c
b/plug-ins/animation-play/widgets/animation-xsheet.c
new file mode 100755
index 0000000..1712beb
--- /dev/null
+++ b/plug-ins/animation-play/widgets/animation-xsheet.c
@@ -0,0 +1,324 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * animation-xsheet.c
+ * Copyright (C) 2015-2016 Jehan <jehan gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include <libgimp/gimp.h>
+
+#include "core/animation-celanimation.h"
+#include "animation-layer-view.h"
+
+#include "animation-xsheet.h"
+
+#include "libgimp/stdplugins-intl.h"
+
+enum
+{
+ PROP_0,
+ PROP_ANIMATION,
+ PROP_LAYER_VIEW
+};
+
+struct _AnimationXSheetPrivate
+{
+ AnimationCelAnimation *animation;
+ GtkWidget *layer_view;
+
+ GtkWidget *track_layout;
+};
+
+static void animation_xsheet_constructed (GObject *object);
+static void animation_xsheet_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void animation_xsheet_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void animation_xsheet_finalize (GObject *object);
+
+/* Construction methods */
+static void animation_xsheet_reset_layout (AnimationXSheet *xsheet);
+
+/* Callbacks on animation. */
+static void on_animation_loaded (Animation *animation,
+ gint first_frame,
+ gint num_frames,
+ gint playback_start,
+ gint playback_stop,
+ gint preview_width,
+ gint preview_height,
+ AnimationXSheet *xsheet);
+
+G_DEFINE_TYPE (AnimationXSheet, animation_xsheet, GTK_TYPE_SCROLLED_WINDOW)
+
+#define parent_class animation_xsheet_parent_class
+
+static void
+animation_xsheet_class_init (AnimationXSheetClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = animation_xsheet_constructed;
+ object_class->get_property = animation_xsheet_get_property;
+ object_class->set_property = animation_xsheet_set_property;
+ object_class->finalize = animation_xsheet_finalize;
+
+ /**
+ * AnimationXSheet:animation:
+ *
+ * The associated #Animation.
+ */
+ g_object_class_install_property (object_class, PROP_ANIMATION,
+ g_param_spec_object ("animation",
+ NULL, NULL,
+ ANIMATION_TYPE_CEL_ANIMATION,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_LAYER_VIEW,
+ g_param_spec_object ("layer-view",
+ NULL, NULL,
+ ANIMATION_TYPE_LAYER_VIEW,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (klass, sizeof (AnimationXSheetPrivate));
+}
+
+static void
+animation_xsheet_init (AnimationXSheet *xsheet)
+{
+ xsheet->priv = G_TYPE_INSTANCE_GET_PRIVATE (xsheet,
+ ANIMATION_TYPE_XSHEET,
+ AnimationXSheetPrivate);
+}
+
+/************ Public Functions ****************/
+
+GtkWidget *
+animation_xsheet_new (AnimationCelAnimation *animation,
+ GtkWidget *layer_view)
+{
+ GtkWidget *xsheet;
+
+ xsheet = g_object_new (ANIMATION_TYPE_XSHEET,
+ "animation", animation,
+ "layer-view", layer_view,
+ NULL);
+
+ return xsheet;
+}
+
+/************ Private Functions ****************/
+
+static void
+animation_xsheet_constructed (GObject *object)
+{
+ AnimationXSheet *xsheet = ANIMATION_XSHEET (object);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (xsheet),
+ GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
+
+ /* We don't know the size yet. */
+ xsheet->priv->track_layout = gtk_table_new (1, 1, TRUE);
+
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (xsheet),
+ xsheet->priv->track_layout);
+ gtk_table_set_row_spacings (GTK_TABLE (xsheet->priv->track_layout), 0);
+ gtk_table_set_col_spacings (GTK_TABLE (xsheet->priv->track_layout), 0);
+
+ gtk_widget_show (xsheet->priv->track_layout);
+
+ /* Reload everything when we reload the animation. */
+ g_signal_connect_after (xsheet->priv->animation, "loaded",
+ G_CALLBACK (on_animation_loaded), xsheet);
+}
+
+static void
+animation_xsheet_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ AnimationXSheet *xsheet = ANIMATION_XSHEET (object);
+
+ switch (property_id)
+ {
+ case PROP_ANIMATION:
+ xsheet->priv->animation = g_value_dup_object (value);
+ break;
+ case PROP_LAYER_VIEW:
+ xsheet->priv->layer_view = g_value_dup_object (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+animation_xsheet_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ AnimationXSheet *xsheet = ANIMATION_XSHEET (object);
+
+ switch (property_id)
+ {
+ case PROP_ANIMATION:
+ g_value_set_object (value, xsheet->priv->animation);
+ break;
+ case PROP_LAYER_VIEW:
+ g_value_set_object (value, xsheet->priv->layer_view);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+animation_xsheet_finalize (GObject *object)
+{
+ AnimationXSheet *xsheet = ANIMATION_XSHEET (object);
+
+ if (xsheet->priv->animation)
+ g_object_unref (xsheet->priv->animation);
+ if (xsheet->priv->layer_view)
+ g_object_unref (xsheet->priv->layer_view);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+animation_xsheet_reset_layout (AnimationXSheet *xsheet)
+{
+ GtkWidget *frame;
+ GtkWidget *label;
+ GtkWidget *comment_field;
+ gint n_tracks;
+ gint n_frames;
+ gint i;
+ gint j;
+
+ /*
+ * | Frame | Background | Track 1 | Track 2 | ... | Comments (x5) |
+ * | 1 | | | | | |
+ * | 2 | | | | | |
+ * | ... | | | | | |
+ * | n | | | | | |
+ */
+
+ n_tracks = animation_cel_animation_get_levels (xsheet->priv->animation);
+ n_frames = animation_get_length (ANIMATION (xsheet->priv->animation));
+
+ /* Add 4 columns for track names and 1 row for frame numbers. */
+ gtk_table_resize (GTK_TABLE (xsheet->priv->track_layout),
+ (guint) (n_frames + 1),
+ (guint) (n_tracks + 6));
+ for (i = 0; i < n_frames; i++)
+ {
+ gchar *num_str;
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
+ gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
+ frame, 0, 1, i + 1, i + 2,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ num_str = g_strdup_printf ("%d", i + 1);
+ label = gtk_label_new (num_str);
+ gtk_container_add (GTK_CONTAINER (frame), label);
+
+ gtk_widget_show (label);
+ gtk_widget_show (frame);
+
+ for (j = 0; j < n_tracks; j++)
+ {
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+ gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
+ frame, j + 1, j + 2, i + 1, i + 2,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ gtk_widget_show (frame);
+ }
+ /* Comments */
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+ gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
+ frame, n_tracks + 1, n_tracks + 6, i + 1, i + 2,
+ GTK_FILL, GTK_FILL, 0, 0);
+ comment_field = gtk_text_view_new ();
+ gtk_container_add (GTK_CONTAINER (frame), comment_field);
+ gtk_widget_show (comment_field);
+ gtk_widget_show (frame);
+ }
+
+ /* Titles. */
+ for (j = 0; j < n_tracks; j++)
+ {
+ const gchar *title;
+
+ title = animation_cel_animation_get_track_title (xsheet->priv->animation, j);
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
+ gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
+ frame, j + 1, j + 2, 0, 1,
+ GTK_FILL, GTK_FILL, 0, 0);
+ label = gtk_label_new (title);
+ gtk_container_add (GTK_CONTAINER (frame), label);
+ gtk_widget_show (label);
+ gtk_widget_show (frame);
+ }
+ frame = gtk_frame_new (NULL);
+ label = gtk_label_new (_("Comments"));
+ gtk_container_add (GTK_CONTAINER (frame), label);
+ gtk_widget_show (label);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
+ gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
+ frame, n_tracks + 1, n_tracks + 6, 0, 1,
+ GTK_FILL, GTK_FILL, 0, 0);
+
+ gtk_widget_show (frame);
+
+ gtk_table_set_row_spacings (GTK_TABLE (xsheet->priv->track_layout), 0);
+ gtk_table_set_col_spacings (GTK_TABLE (xsheet->priv->track_layout), 0);
+}
+
+static void
+on_animation_loaded (Animation *animation,
+ gint first_frame,
+ gint num_frames,
+ gint playback_start,
+ gint playback_stop,
+ gint preview_width,
+ gint preview_height,
+ AnimationXSheet *xsheet)
+{
+ animation_xsheet_reset_layout (xsheet);
+}
diff --git a/plug-ins/animation-play/widgets/animation-xsheet.h
b/plug-ins/animation-play/widgets/animation-xsheet.h
new file mode 100755
index 0000000..9346419
--- /dev/null
+++ b/plug-ins/animation-play/widgets/animation-xsheet.h
@@ -0,0 +1,52 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * animation-xsheet.h
+ * Copyright (C) 2015-2016 Jehan <jehan gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __ANIMATION_XSHEET_H__
+#define __ANIMATION_XSHEET_H__
+
+#define ANIMATION_TYPE_XSHEET (animation_xsheet_get_type ())
+#define ANIMATION_XSHEET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ANIMATION_TYPE_XSHEET,
AnimationXSheet))
+#define ANIMATION_XSHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ANIMATION_TYPE_XSHEET,
AnimationXSheetClass))
+#define ANIMATION_IS_XSHEET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ANIMATION_TYPE_XSHEET))
+#define ANIMATION_IS_XSHEET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ANIMATION_TYPE_XSHEET))
+#define ANIMATION_XSHEET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ANIMATION_TYPE_XSHEET,
AnimationXSheetClass))
+
+typedef struct _AnimationXSheet AnimationXSheet;
+typedef struct _AnimationXSheetClass AnimationXSheetClass;
+typedef struct _AnimationXSheetPrivate AnimationXSheetPrivate;
+
+struct _AnimationXSheet
+{
+ GtkScrolledWindow parent_instance;
+
+ AnimationXSheetPrivate *priv;
+};
+
+struct _AnimationXSheetClass
+{
+ GtkScrolledWindowClass parent_class;
+};
+
+GType animation_xsheet_get_type (void) G_GNUC_CONST;
+
+GtkWidget * animation_xsheet_new (AnimationCelAnimation *animation,
+ GtkWidget *layer_view);
+
+#endif /* __ANIMATION_XSHEET_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]