[gimp/wip/animation: 250/373] plug-ins: fix cel selection in animation.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 250/373] plug-ins: fix cel selection in animation.
- Date: Sat, 7 Oct 2017 02:15:44 +0000 (UTC)
commit 0493d810fef28e0a2c9490ec12ef219183daf0b3
Author: Jehan <jehan girinstud io>
Date: Wed Aug 10 19:38:19 2016 +0200
plug-ins: fix cel selection in animation.
plug-ins/animation-play/widgets/animation-xsheet.c | 89 ++++++++++++++------
1 files changed, 62 insertions(+), 27 deletions(-)
---
diff --git a/plug-ins/animation-play/widgets/animation-xsheet.c
b/plug-ins/animation-play/widgets/animation-xsheet.c
index 5569ad3..17627bf 100755
--- a/plug-ins/animation-play/widgets/animation-xsheet.c
+++ b/plug-ins/animation-play/widgets/animation-xsheet.c
@@ -267,6 +267,7 @@ animation_xsheet_reset_layout (AnimationXSheet *xsheet)
xsheet->priv->cels = NULL;
xsheet->priv->selected_track = -1;
g_queue_clear (xsheet->priv->selected_frames);
+
/*
* | Frame | Background | Track 1 | Track 2 | ... | Comments (x5) |
* | 1 | | | | | |
@@ -463,10 +464,11 @@ animation_xsheet_cel_clicked (GtkWidget *button,
shift = ((GdkEventButton *) event)->state & GDK_SHIFT_MASK;
ctrl = ((GdkEventButton *) event)->state & GDK_CONTROL_MASK;
- if ((! shift && ! ctrl) ||
+ if ((! shift && ! ctrl) ||
(xsheet->priv->selected_track >= 0 &&
xsheet->priv->selected_track != GPOINTER_TO_INT (track_num)))
{
+ /* Changing track and normal click resets selection. */
GList *track_iter;
GList *frame_iter;
@@ -478,44 +480,77 @@ animation_xsheet_cel_clicked (GtkWidget *button,
}
}
g_queue_clear (xsheet->priv->selected_frames);
+ xsheet->priv->selected_track = -1;
}
- else
+
+ if (ctrl)
{
- g_queue_remove (xsheet->priv->selected_frames, position);
+ /* Ctrl toggle the clicked selection. */
+ if (toggled)
+ {
+ g_queue_remove (xsheet->priv->selected_frames, position);
+ if (g_queue_is_empty (xsheet->priv->selected_frames))
+ {
+ xsheet->priv->selected_track = -1;
+ }
+ }
+ else
+ {
+ g_queue_push_head (xsheet->priv->selected_frames, position);
+ xsheet->priv->selected_track = GPOINTER_TO_INT (track_num);
+ }
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
+ ! toggled);
}
- xsheet->priv->selected_track = GPOINTER_TO_INT (track_num);
-
- if (! toggled)
+ else if (shift)
{
- GList *frame_iter;
- gint prev_selection = GPOINTER_TO_INT (position);
- gint direction = 1;
- gint selection_size;
- gint i;
-
- frame_iter = g_list_nth (xsheet->priv->cels, GPOINTER_TO_INT (track_num))->data;
-
- if (shift)
+ /* Shift selects all from the first selection, and unselects
+ * anything else. */
+ GList *track_iter;
+ GList *frame_iter;
+ gint from = GPOINTER_TO_INT (position);
+ gint to = from;
+ gint direction;
+ gint min;
+ gint max;
+ gint i;
+
+ xsheet->priv->selected_track = GPOINTER_TO_INT (track_num);
+ for (track_iter = xsheet->priv->cels; track_iter; track_iter = track_iter->next)
{
- prev_selection = GPOINTER_TO_INT (g_queue_pop_head (xsheet->priv->selected_frames));
- if (prev_selection > GPOINTER_TO_INT (position))
+ for (frame_iter = track_iter->data; frame_iter; frame_iter = frame_iter->next)
{
- direction = -1;
+ gtk_toggle_button_set_active (frame_iter->data, FALSE);
}
}
-
- selection_size = MAX (GPOINTER_TO_INT (position), prev_selection) - MIN (GPOINTER_TO_INT (position),
prev_selection) + 1;
- for (i = prev_selection; selection_size; i = i + direction, selection_size--)
+ if (! g_queue_is_empty (xsheet->priv->selected_frames))
{
- g_queue_push_head (xsheet->priv->selected_frames, GINT_TO_POINTER (i));
+ from = GPOINTER_TO_INT (g_queue_pop_tail (xsheet->priv->selected_frames));
+ g_queue_clear (xsheet->priv->selected_frames);
}
-
- frame_iter = g_list_nth (frame_iter, MIN (GPOINTER_TO_INT (position), prev_selection));
- selection_size = MAX (GPOINTER_TO_INT (position), prev_selection) - MIN (GPOINTER_TO_INT (position),
prev_selection) + 1;
- for (; frame_iter && selection_size > 0; frame_iter = frame_iter->next, selection_size--)
+ direction = from > to? -1 : 1;
+ for (i = from; i != to + direction; i = i + direction)
{
- gtk_toggle_button_set_active (frame_iter->data, TRUE);
+ g_queue_push_head (xsheet->priv->selected_frames,
+ GINT_TO_POINTER (i));
}
+ min = MIN (to, from);
+ max = MAX (to, from);
+ track_iter = g_list_nth (xsheet->priv->cels, xsheet->priv->selected_track);
+ frame_iter = track_iter->data;
+ for (i = 0; frame_iter && i <= max; frame_iter = frame_iter->next, i++)
+ {
+ if (i >= min)
+ {
+ gtk_toggle_button_set_active (frame_iter->data, TRUE);
+ }
+ }
+ }
+ else /* ! shift && ! ctrl */
+ {
+ xsheet->priv->selected_track = GPOINTER_TO_INT (track_num);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ g_queue_push_head (xsheet->priv->selected_frames, position);
}
/* Finally update the layer view. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]