diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_clip.py | 1 | ||||
-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 |
4 files changed, 39 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 6195ec2245a..26ca240b2f4 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -905,6 +905,7 @@ class CLIP_PT_tools_clip(CLIP_PT_clip_view_panel, Panel): layout.operator("clip.set_viewport_background") layout.operator("clip.setup_tracking_scene") layout.operator("clip.prefetch") + layout.operator("clip.set_scene_frames") class CLIP_MT_view(Menu): 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); |