diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-05-10 19:56:32 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-05-10 19:56:32 +0400 |
commit | 764420ed3dec8e65fdfda1e42401362a6878ed0b (patch) | |
tree | d148c3aa64eb28a209ec425aa71608a62e1a04a6 /source/blender/editors/space_clip | |
parent | 8e9b6daa8ea5d47fad5e9ec4e8a75c2df7f9b2dc (diff) |
Set scene frames operator for clip editor.
This operator will set scene's start/end frames to
match clip's start frame and footage duration.
Available in Clip panel in clip editor's toolbox.
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 35 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 805e36c7c56..1568ecf010e 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -110,6 +110,8 @@ void CLIP_OT_view_ndof(struct wmOperatorType *ot); void CLIP_OT_prefetch(struct wmOperatorType *ot); +void CLIP_OT_set_scene_frames(wmOperatorType *ot); + /* clip_toolbar.c */ struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa); void CLIP_OT_tools(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index ab00c078226..7a6da5d8896 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1419,6 +1419,41 @@ void CLIP_OT_prefetch(wmOperatorType *ot) ot->modal = clip_prefetch_modal; } +/********************** Set scene frames *********************/ + +static int clip_set_scene_frames_exec(bContext *C, wmOperator *UNUSED(op)) +{ + MovieClip *clip = CTX_data_edit_movieclip(C); + Scene *scene = CTX_data_scene(C); + int clip_length; + + if (ELEM(NULL, scene, clip)) + return OPERATOR_CANCELLED; + + clip_length = BKE_movieclip_get_duration(clip); + + scene->r.sfra = clip->start_frame; + scene->r.efra = scene->r.sfra + clip_length - 1; + + scene->r.efra = max_ii(scene->r.sfra, scene->r.efra); + + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_set_scene_frames(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Set Scene Frames"; + ot->idname = "CLIP_OT_set_scene_frames"; + ot->description = "Set scene's start and end frame to match clip's start frame and length"; + + /* api callbacks */ + ot->poll = ED_space_clip_view_clip_poll; + ot->exec = clip_set_scene_frames_exec; +} + /********************** macroses *********************/ void ED_operatormacros_clip(void) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 393b2ed2cb2..c4d92bc78eb 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -441,6 +441,7 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_mode_set); WM_operatortype_append(CLIP_OT_view_ndof); WM_operatortype_append(CLIP_OT_prefetch); + WM_operatortype_append(CLIP_OT_set_scene_frames); /* ** clip_toolbar.c ** */ WM_operatortype_append(CLIP_OT_tools); |