From ba798e0412cdcb5e6a10464ced105c8d6708c4b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2019 20:19:44 +1000 Subject: Image/Clip Space: Add view center to cursor operators D5932 by @a.monti with edits --- source/blender/editors/space_clip/clip_ops.c | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/blender/editors/space_clip/clip_ops.c') 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 @@ -992,6 +992,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 * \{ */ -- cgit v1.2.3