Commit: 3b68a74c2a142f7962ed1ff9ab2c99e438937277
Author: Antony Riakiotakis
Date:   Thu Feb 12 13:08:22 2015 +0100
Branches: master
https://developer.blender.org/rB3b68a74c2a142f7962ed1ff9ab2c99e438937277

Follow functionality: Scrubbing with the arrow keys and during jumps,
will update the editors range.

Offsetting to a certain direction will put the editors min/max to the
new frame if the frame is out of the editor bounds while jumping will
set the new frame at the editor's center.

===================================================================

M       source/blender/editors/screen/screen_ops.c

===================================================================

diff --git a/source/blender/editors/screen/screen_ops.c 
b/source/blender/editors/screen/screen_ops.c
index 9374d46..6db6d8d 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;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to