diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-27 00:23:26 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-08-27 00:23:26 +0400 |
commit | 03dbae07d346dcfb5cdaeeeea3585f642cd90d31 (patch) | |
tree | 866db44539cf778c636cd774f524970d434c77d3 /source/blender/editors/space_clip/clip_ops.c | |
parent | 11aa7a76fab53809f891ab8ff7898a2dd70005b8 (diff) |
Mask primitives
Currently only circle and square, might be easily
extended in the future.
New primitives are creating at cursor location.
This also implied adding 2d cursor to space clip.
Also fix set 2D cursor location which didn't work
in image editor's mask mode since 2.67.
TODO: draw_image_cursor better be moved to some
more generic file, but it's not so much
important for now and might be solved later.
Thanks Campbell for the review!
Diffstat (limited to 'source/blender/editors/space_clip/clip_ops.c')
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index c6f8cf2466a..bed230a342c 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1458,6 +1458,51 @@ void CLIP_OT_set_scene_frames(wmOperatorType *ot) ot->exec = clip_set_scene_frames_exec; } +/******************** set 3d cursor operator ********************/ + +static int clip_set_2d_cursor_exec(bContext *C, wmOperator *op) +{ + SpaceClip *sclip = CTX_wm_space_clip(C); + + RNA_float_get_array(op->ptr, "location", sclip->cursor); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); + + return OPERATOR_FINISHED; +} + +static int clip_set_2d_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event) +{ + ARegion *ar = CTX_wm_region(C); + SpaceClip *sclip = CTX_wm_space_clip(C); + float location[2]; + + ED_clip_mouse_pos(sclip, ar, event->mval, location); + RNA_float_set_array(op->ptr, "location", location); + + return clip_set_2d_cursor_exec(C, op); +} + +void CLIP_OT_cursor_set(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Set 2D Cursor"; + ot->description = "Set 2D cursor location"; + ot->idname = "CLIP_OT_cursor_set"; + + /* api callbacks */ + ot->exec = clip_set_2d_cursor_exec; + ot->invoke = clip_set_2d_cursor_invoke; + ot->poll = ED_space_clip_maskedit_mask_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 clip coordinates", -10.0f, 10.0f); +} + /********************** macroses *********************/ void ED_operatormacros_clip(void) |