diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-10-07 04:32:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-10-07 19:27:55 +0300 |
commit | d04d27b406b856396102452cab0eedf315e94a54 (patch) | |
tree | 4a881ab29123828287f83272a0ca1d03b62b4472 /source/blender/editors/space_sequencer | |
parent | 919e513fa8f9fb4f1304ea4b752869b6d63b1608 (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')
5 files changed, 81 insertions, 0 deletions
diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index 1471929defb..bf8cf89699d 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -22,6 +22,7 @@ set(INC ../../blenlib ../../blentranslation ../../depsgraph + ../../draw ../../gpu ../../imbuf ../../makesdna 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( + ®ion->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); +} + +/** \} */ diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 730d4d11e78..5982a0a8993 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -165,6 +165,7 @@ void SEQUENCER_OT_strip_transform_clear(struct wmOperatorType *ot); void SEQUENCER_OT_strip_transform_fit(struct wmOperatorType *ot); void SEQUENCER_OT_strip_color_tag_set(struct wmOperatorType *ot); +void SEQUENCER_OT_cursor_set(struct wmOperatorType *ot); /* sequencer_select.c */ void SEQUENCER_OT_select_all(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 95f7b44264c..2c5f211b0e4 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -80,6 +80,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_strip_transform_fit); WM_operatortype_append(SEQUENCER_OT_strip_color_tag_set); + WM_operatortype_append(SEQUENCER_OT_cursor_set); /* sequencer_select.c */ WM_operatortype_append(SEQUENCER_OT_select_all); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index ad0ceb82709..c1f853270e9 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -41,6 +41,8 @@ #include "BKE_screen.h" #include "BKE_sequencer_offscreen.h" +#include "GPU_state.h" + #include "ED_screen.h" #include "ED_space_api.h" #include "ED_transform.h" @@ -53,6 +55,7 @@ #include "RNA_access.h" +#include "SEQ_transform.h" #include "SEQ_utils.h" #include "UI_interface.h" @@ -61,6 +64,9 @@ #include "IMB_imbuf.h" +/* Only for cursor drawing. */ +#include "DRW_engine.h" + /* Own include. */ #include "sequencer_intern.h" @@ -803,6 +809,17 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *region) } } + { + GPU_color_mask(true, true, true, true); + GPU_depth_mask(false); + GPU_depth_test(GPU_DEPTH_NONE); + + float cursor_pixel[2]; + SEQ_image_preview_unit_to_px(scene, sseq->cursor, cursor_pixel); + + DRW_draw_cursor_2d_ex(region, cursor_pixel); + } + WM_gizmomap_draw(region->gizmo_map, C, WM_GIZMOMAP_DRAWSTEP_2D); if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) { |