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
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/blender/editors/mask
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/blender/editors/mask')
-rw-r--r--source/blender/editors/mask/mask_editaction.c55
1 files changed, 55 insertions, 0 deletions
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;
+ }
+}
+