Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-12-03 17:07:43 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-12-03 17:07:43 +0400
commit582a9d1c45e5d75210a2d4010e55cd9a0f3673a2 (patch)
treeb9e9a1d5303324029d49bf69c526538b216cacd8 /source
parent4f3fdb8d5a4a3b01de3c3660f6111cf911d9569f (diff)
Fix for [#33378] Grease pencil dopesheet fails on a few operations
Snapping operator in action editor for grease pencil and mask wasn't implemented. We could probably re-enabled/fix/cleanup more things in this area (e.g. use a custom poll func for operators not supporting gp/mask, instead of silently doing nothing), but this is for after 2.65 imho).
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c19
-rw-r--r--source/blender/editors/include/ED_gpencil.h3
-rw-r--r--source/blender/editors/include/ED_mask.h3
-rw-r--r--source/blender/editors/mask/mask_editaction.c55
-rw-r--r--source/blender/editors/space_action/action_edit.c22
5 files changed, 81 insertions, 21 deletions
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index a59a3f7a5ec..137ef50be3c 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -49,6 +49,7 @@
#include "ED_anim_api.h"
#include "ED_gpencil.h"
#include "ED_keyframes_edit.h"
+#include "ED_markers.h"
#include "gpencil_intern.h"
@@ -460,11 +461,12 @@ void paste_gpdata(Scene *scene)
/* undo and redraw stuff */
BIF_undo_push("Paste Grease Pencil Frames");
}
+#endif /* XXX disabled until Grease Pencil code stabilises again... */
/* -------------------------------------- */
/* Snap Tools */
-static short snap_gpf_nearest(bGPDframe *gpf, Scene *scene)
+static short snap_gpf_nearest(bGPDframe *gpf, Scene *UNUSED(scene))
{
if (gpf->flag & GP_FRAME_SELECT)
gpf->framenum = (int)(floor(gpf->framenum + 0.5));
@@ -489,33 +491,32 @@ static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene)
static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene)
{
if (gpf->flag & GP_FRAME_SELECT)
- gpf->framenum = (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum);
+ gpf->framenum = (int)ED_markers_find_nearest_marker_time(&scene->markers, (float)gpf->framenum);
return 0;
}
-
/* snap selected frames to ... */
-void snap_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode)
+void ED_gplayer_snap_frames(bGPDlayer *gpl, Scene *scene, short mode)
{
switch (mode) {
- case 1: /* snap to nearest frame */
+ case SNAP_KEYS_NEARFRAME: /* snap to nearest frame */
ED_gplayer_frames_looper(gpl, scene, snap_gpf_nearest);
break;
- case 2: /* snap to current frame */
+ case SNAP_KEYS_CURFRAME: /* snap to current frame */
ED_gplayer_frames_looper(gpl, scene, snap_gpf_cframe);
break;
- case 3: /* snap to nearest marker */
+ case SNAP_KEYS_NEARMARKER: /* snap to nearest marker */
ED_gplayer_frames_looper(gpl, scene, snap_gpf_nearmarker);
break;
- case 4: /* snap to nearest second */
+ case SNAP_KEYS_NEARSEC: /* snap to nearest second */
ED_gplayer_frames_looper(gpl, scene, snap_gpf_nearestsec);
break;
default: /* just in case */
- ED_gplayer_frames_looper(gpl, scene, snap_gpf_nearest);
break;
}
}
+#if 0 /* XXX disabled until grease pencil code stabilises again */
/* -------------------------------------- */
/* Mirror Tools */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 39dd8822267..5cc1ecade3e 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -97,12 +97,13 @@ void ED_gpencil_select_frame(struct bGPDlayer *gpl, int selx, short select_mode
void ED_gplayer_frames_delete(struct bGPDlayer *gpl);
void ED_gplayer_frames_duplicate(struct bGPDlayer *gpl);
+void ED_gplayer_snap_frames(struct bGPDlayer *gpl, struct Scene *scene, short mode);
+
#if 0
void free_gpcopybuf(void);
void copy_gpdata(void);
void paste_gpdata(void);
-void snap_gplayer_frames(struct bGPDlayer *gpl, short mode);
void mirror_gplayer_frames(struct bGPDlayer *gpl, short mode);
#endif
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 46ed9798d32..6644f59be94 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -83,12 +83,13 @@ void ED_mask_select_frame(struct MaskLayer *masklay, int selx, short select_mod
void ED_masklayer_frames_delete(struct MaskLayer *masklay);
void ED_masklayer_frames_duplicate(struct MaskLayer *masklay);
+void ED_masklayer_snap_frames(struct MaskLayer *masklay, struct Scene *scene, short mode);
+
#if 0
void free_gpcopybuf(void);
void copy_gpdata(void);
void paste_gpdata(void);
-void snap_masklayer_frames(struct MaskLayer *masklay, short mode);
void mirror_masklayer_frames(struct MaskLayer *masklay, short mode);
#endif
diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c
index a0e33d0c311..1d2cb1f9ff3 100644
--- a/source/blender/editors/mask/mask_editaction.c
+++ b/source/blender/editors/mask/mask_editaction.c
@@ -49,6 +49,7 @@
#include "ED_anim_api.h"
#include "ED_keyframes_edit.h"
#include "ED_mask.h" /* own include */
+#include "ED_markers.h"
/* ***************************************** */
/* NOTE ABOUT THIS FILE:
@@ -249,3 +250,57 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay)
}
}
}
+
+/* -------------------------------------- */
+/* Snap Tools */
+
+static short snap_masklayer_nearest(MaskLayerShape *masklay_shape, Scene *UNUSED(scene))
+{
+ if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ masklay_shape->frame = (int)(floor(masklay_shape->frame + 0.5));
+ return 0;
+}
+
+static short snap_masklayer_nearestsec(MaskLayerShape *masklay_shape, Scene *scene)
+{
+ float secf = (float)FPS;
+ if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ masklay_shape->frame = (int)(floor(masklay_shape->frame / secf + 0.5f) * secf);
+ return 0;
+}
+
+static short snap_masklayer_cframe(MaskLayerShape *masklay_shape, Scene *scene)
+{
+ if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ masklay_shape->frame = (int)CFRA;
+ return 0;
+}
+
+static short snap_masklayer_nearmarker(MaskLayerShape *masklay_shape, Scene *scene)
+{
+ if (masklay_shape->flag & MASK_SHAPE_SELECT)
+ masklay_shape->frame = (int)ED_markers_find_nearest_marker_time(&scene->markers, (float)masklay_shape->frame);
+ return 0;
+}
+
+/* snap selected frames to ... */
+void ED_masklayer_snap_frames(MaskLayer *masklay, Scene *scene, short mode)
+{
+ switch (mode) {
+ case SNAP_KEYS_NEARFRAME: /* snap to nearest frame */
+ ED_masklayer_frames_looper(masklay, scene, snap_masklayer_nearest);
+ break;
+ case SNAP_KEYS_CURFRAME: /* snap to current frame */
+ ED_masklayer_frames_looper(masklay, scene, snap_masklayer_cframe);
+ break;
+ case SNAP_KEYS_NEARMARKER: /* snap to nearest marker */
+ ED_masklayer_frames_looper(masklay, scene, snap_masklayer_nearmarker);
+ break;
+ case SNAP_KEYS_NEARSEC: /* snap to nearest second */
+ ED_masklayer_frames_looper(masklay, scene, snap_masklayer_nearestsec);
+ break;
+ default: /* just in case */
+ break;
+ }
+}
+
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 5170914865c..092b738bab9 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -1412,15 +1412,20 @@ static void snap_action_keys(bAnimContext *ac, short mode)
for (ale = anim_data.first; ale; ale = ale->next) {
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
- if (adt) {
+ if (ale->type == ANIMTYPE_GPLAYER) {
+ ED_gplayer_snap_frames(ale->data, ac->scene, mode);
+ }
+ else if (ale->type == ANIMTYPE_MASKLAYER) {
+ ED_masklayer_snap_frames(ale->data, ac->scene, mode);
+ }
+ else if (adt) {
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
- //else if (ale->type == ACTTYPE_GPLAYER)
- // snap_gplayer_frames(ale->data, mode);
- else
+ else {
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
+ }
}
BLI_freelistN(&anim_data);
@@ -1436,11 +1441,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
-
- /* XXX... */
- if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
- return OPERATOR_PASS_THROUGH;
-
+
/* get snapping mode */
mode = RNA_enum_get(op->ptr, "type");
@@ -1448,7 +1449,8 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op)
snap_action_keys(&ac, mode);
/* validate keyframes after editing */
- ANIM_editkeyframes_refresh(&ac);
+ if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK))
+ ANIM_editkeyframes_refresh(&ac);
/* set notifier that keyframes have changed */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);