diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-10-01 13:19:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-10-01 13:20:53 +0300 |
commit | ba798e0412cdcb5e6a10464ced105c8d6708c4b7 (patch) | |
tree | 6c2b781f07ead1f06342616187128b689fb7bf0f /source/blender/editors/space_clip | |
parent | 3370af2dc1ced49099a4a7e6e15f3ffd009d91ca (diff) |
Image/Clip Space: Add view center to cursor operators
D5932 by @a.monti with edits
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 30 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 1fae4c91a48..bd54d4f0016 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -94,6 +94,7 @@ void CLIP_OT_view_zoom_out(struct wmOperatorType *ot); void CLIP_OT_view_zoom_ratio(struct wmOperatorType *ot); void CLIP_OT_view_all(struct wmOperatorType *ot); void CLIP_OT_view_selected(struct wmOperatorType *ot); +void CLIP_OT_view_center_cursor(struct wmOperatorType *ot); void CLIP_OT_change_frame(wmOperatorType *ot); void CLIP_OT_rebuild_proxy(struct wmOperatorType *ot); void CLIP_OT_mode_set(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 446e3408d8c..192449a219d 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -993,6 +993,36 @@ void CLIP_OT_view_all(wmOperatorType *ot) /** \} */ /* -------------------------------------------------------------------- */ +/** \name Center View To Cursor Operator + * \{ */ + +static int view_center_cursor_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + ARegion *ar = CTX_wm_region(C); + + clip_view_center_to_point(sc, sc->cursor[0], sc->cursor[1]); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_view_center_cursor(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Center View to Cursor"; + ot->description = "Center the view so that the cursor is in the middle of the view"; + ot->idname = "CLIP_OT_view_center_cursor"; + + /* api callbacks */ + ot->exec = view_center_cursor_exec; + ot->poll = ED_space_clip_maskedit_poll; +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name View Selected Operator * \{ */ diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 2964a95648a..16305a9b17b 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -443,6 +443,7 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_view_zoom_ratio); WM_operatortype_append(CLIP_OT_view_all); WM_operatortype_append(CLIP_OT_view_selected); + WM_operatortype_append(CLIP_OT_view_center_cursor); WM_operatortype_append(CLIP_OT_change_frame); WM_operatortype_append(CLIP_OT_rebuild_proxy); WM_operatortype_append(CLIP_OT_mode_set); |