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/transform/transform_convert_cursor.c | |
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/transform/transform_convert_cursor.c')
-rw-r--r-- | source/blender/editors/transform/transform_convert_cursor.c | 93 |
1 files changed, 62 insertions, 31 deletions
diff --git a/source/blender/editors/transform/transform_convert_cursor.c b/source/blender/editors/transform/transform_convert_cursor.c index 1f3eff31205..8a4a13eb4db 100644 --- a/source/blender/editors/transform/transform_convert_cursor.c +++ b/source/blender/editors/transform/transform_convert_cursor.c @@ -19,6 +19,8 @@ /** \file * \ingroup edtransform + * + * Instead of transforming the selection, move the 2D/3D cursor. */ #include "DNA_space_types.h" @@ -35,18 +37,12 @@ #include "transform_convert.h" /* -------------------------------------------------------------------- */ -/** \name Cursor Transform Creation - * - * Instead of transforming the selection, move the 2D/3D cursor. - * +/** \name Shared 2D Cursor Utilities * \{ */ -void createTransCursor_image(TransInfo *t) +static void createTransCursor_2D_impl(TransInfo *t, float cursor_location[2]) { TransData *td; - SpaceImage *sima = t->area->spacedata.first; - float *cursor_location = sima->cursor; - { BLI_assert(t->data_container_len == 1); TransDataContainer *tc = t->data_container; @@ -57,7 +53,7 @@ void createTransCursor_image(TransInfo *t) td->flag = TD_SELECTED; - /* UV coords are scaled by aspects (see UVsToTransData). This also applies for the Cursor in the + /* UV coords are scaled by aspects (see #UVsToTransData). This also applies for the Cursor in the * UV Editor which also means that for display and when the cursor coords are flushed * (recalcData_cursor_image), these are converted each time. */ cursor_location[0] = cursor_location[0] * t->aspect[0]; @@ -74,6 +70,62 @@ void createTransCursor_image(TransInfo *t) copy_v3_v3(td->iloc, cursor_location); } +static void recalcData_cursor_2D_impl(TransInfo *t) +{ + TransDataContainer *tc = t->data_container; + TransData *td = tc->data; + float aspect_inv[2]; + + aspect_inv[0] = 1.0f / t->aspect[0]; + aspect_inv[1] = 1.0f / t->aspect[1]; + + td->loc[0] = td->loc[0] * aspect_inv[0]; + td->loc[1] = td->loc[1] * aspect_inv[1]; + + DEG_id_tag_update(&t->scene->id, ID_RECALC_COPY_ON_WRITE); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Image Cursor + * \{ */ + +void createTransCursor_image(TransInfo *t) +{ + SpaceImage *sima = t->area->spacedata.first; + createTransCursor_2D_impl(t, sima->cursor); +} + +void recalcData_cursor_image(TransInfo *t) +{ + recalcData_cursor_2D_impl(t); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Sequencer Cursor + * \{ */ + +void createTransCursor_sequencer(TransInfo *t) +{ + SpaceSeq *sseq = t->area->spacedata.first; + + createTransCursor_2D_impl(t, sseq->cursor); +} + +void recalcData_cursor_sequencer(TransInfo *t) +{ + recalcData_cursor_2D_impl(t); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name View 3D Cursor + * \{ */ + void createTransCursor_view3d(TransInfo *t) { TransData *td; @@ -133,28 +185,7 @@ void createTransCursor_view3d(TransInfo *t) td->ext->rotOrder = cursor->rotation_mode; } -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name Recalc Cursor - * \{ */ - -void recalcData_cursor_image(TransInfo *t) -{ - TransDataContainer *tc = t->data_container; - TransData *td = tc->data; - float aspect_inv[2]; - - aspect_inv[0] = 1.0f / t->aspect[0]; - aspect_inv[1] = 1.0f / t->aspect[1]; - - td->loc[0] = td->loc[0] * aspect_inv[0]; - td->loc[1] = td->loc[1] * aspect_inv[1]; - - DEG_id_tag_update(&t->scene->id, ID_RECALC_COPY_ON_WRITE); -} - -void recalcData_cursor(TransInfo *t) +void recalcData_cursor_view3d(TransInfo *t) { DEG_id_tag_update(&t->scene->id, ID_RECALC_COPY_ON_WRITE); } |