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:
authorCampbell Barton <ideasman42@gmail.com>2021-10-07 04:32:04 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-10-07 19:27:55 +0300
commitd04d27b406b856396102452cab0eedf315e94a54 (patch)
tree4a881ab29123828287f83272a0ca1d03b62b4472 /source/blender/editors/space_sequencer/sequencer_edit.c
parent919e513fa8f9fb4f1304ea4b752869b6d63b1608 (diff)
Sequencer: 2D cursor for the preview & transform
- Use 2D cursor in the preview space using shortcuts matching the UV editor and 3D view. - Add Cursor tool, cursor transform. - Support for cursor and bound-box pivot. - Add pivot pie menu.
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 655cfb9375c..50a74d9e636 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3397,3 +3397,64 @@ void SEQUENCER_OT_strip_color_tag_set(struct wmOperatorType *ot)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Set 2D Cursor Operator
+ * \{ */
+
+static int sequencer_set_2d_cursor_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
+
+ float cursor_pixel[2];
+ RNA_float_get_array(op->ptr, "location", cursor_pixel);
+
+ SEQ_image_preview_unit_from_px(scene, cursor_pixel, sseq->cursor);
+
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static int sequencer_set_2d_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+{
+ ARegion *region = CTX_wm_region(C);
+ float cursor_pixel[2];
+ UI_view2d_region_to_view(
+ &region->v2d, event->mval[0], event->mval[1], &cursor_pixel[0], &cursor_pixel[1]);
+
+ RNA_float_set_array(op->ptr, "location", cursor_pixel);
+
+ return sequencer_set_2d_cursor_exec(C, op);
+}
+
+void SEQUENCER_OT_cursor_set(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Set 2D Cursor";
+ ot->description = "Set 2D cursor location";
+ ot->idname = "SEQUENCER_OT_cursor_set";
+
+ /* api callbacks */
+ ot->exec = sequencer_set_2d_cursor_exec;
+ ot->invoke = sequencer_set_2d_cursor_invoke;
+ ot->poll = sequencer_view_preview_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_float_vector(ot->srna,
+ "location",
+ 2,
+ NULL,
+ -FLT_MAX,
+ FLT_MAX,
+ "Location",
+ "Cursor location in normalized preview coordinates",
+ -10.0f,
+ 10.0f);
+}
+
+/** \} */