diff options
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 9374d46b7dc..6db6d8d06a5 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2042,6 +2042,47 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) /* ************** frame change operator ***************************** */ +static void areas_do_frame_follow (bContext *C, bool middle) { + bScreen *scr = CTX_wm_screen(C); + Scene *scene = CTX_data_scene(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *window; + for (window = wm->windows.first; window; window = window->next) { + ScrArea *sa; + for (sa = window->screen->areabase.first; sa; sa = sa->next) { + ARegion *ar; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + /* do follow here if editor type supports it */ + if ((scr->redraws_flag & TIME_FOLLOW)) { + if ((ar->regiontype == RGN_TYPE_WINDOW && + ELEM (sa->spacetype, SPACE_SEQ, SPACE_TIME, SPACE_IPO, SPACE_ACTION, SPACE_NLA)) || + (sa->spacetype == SPACE_CLIP && ar->regiontype == RGN_TYPE_PREVIEW)) + { + float w = BLI_rctf_size_x(&ar->v2d.cur); + + if (middle) { + if (scene->r.cfra < ar->v2d.cur.xmin || scene->r.cfra > ar->v2d.cur.xmax) { + ar->v2d.cur.xmax = scene->r.cfra + w/2; + ar->v2d.cur.xmin = scene->r.cfra - w/2; + } + } + else { + if (scene->r.cfra < ar->v2d.cur.xmin) { + ar->v2d.cur.xmax = scene->r.cfra; + ar->v2d.cur.xmin = ar->v2d.cur.xmax - w; + } + else if (scene->r.cfra > ar->v2d.cur.xmax) { + ar->v2d.cur.xmin = scene->r.cfra; + ar->v2d.cur.xmax = ar->v2d.cur.xmin + w; + } + } + } + } + } + } + } +} + /* function to be called outside UI context, or for redo */ static int frame_offset_exec(bContext *C, wmOperator *op) { @@ -2055,6 +2096,8 @@ static int frame_offset_exec(bContext *C, wmOperator *op) FRAMENUMBER_MIN_CLAMP(CFRA); SUBFRA = 0.f; + areas_do_frame_follow(C, false); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -2105,6 +2148,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op) else CFRA = PSFRA; + areas_do_frame_follow(C, true); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -2209,6 +2254,8 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { + areas_do_frame_follow(C, true); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -2269,6 +2316,8 @@ static int marker_jump_exec(bContext *C, wmOperator *op) else { CFRA = closest; + areas_do_frame_follow(C, true); + sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); @@ -3488,7 +3537,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv float w = BLI_rctf_size_x(&ar->v2d.cur); if (scene->r.cfra < ar->v2d.cur.xmin) { ar->v2d.cur.xmax = scene->r.cfra; - ar->v2d.cur.xmin = ar->v2d.cur.xmin - w; + ar->v2d.cur.xmin = ar->v2d.cur.xmax - w; } else if (scene->r.cfra > ar->v2d.cur.xmax) { ar->v2d.cur.xmin = scene->r.cfra; |