Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_ops.c
| Show First 20 Lines • Show All 4,267 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Animation Step Operator | /** \name Animation Step Operator | ||||
| * | * | ||||
| * Animation Step. | * Animation Step. | ||||
| * \{ */ | * \{ */ | ||||
| static bool screen_animation_region_supports_time_follow(eSpace_Type spacetype, | |||||
| eRegionType regiontype) | |||||
| { | |||||
| return (regiontype == RGN_TYPE_WINDOW && | |||||
| ELEM(spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || | |||||
| (spacetype == SPACE_CLIP && regiontype == RGN_TYPE_PREVIEW); | |||||
| } | |||||
| static bool match_region_with_redraws(eSpace_Type spacetype, | static bool match_region_with_redraws(eSpace_Type spacetype, | ||||
| eRegionType regiontype, | eRegionType regiontype, | ||||
| eScreen_Redraws_Flag redraws, | eScreen_Redraws_Flag redraws, | ||||
| bool from_anim_edit) | bool from_anim_edit) | ||||
| { | { | ||||
| if (regiontype == RGN_TYPE_WINDOW) { | if (regiontype == RGN_TYPE_WINDOW) { | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | switch (spacetype) { | ||||
| return true; | return true; | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void screen_animation_region_tag_redraw(ScrArea *area, | |||||
| ARegion *region, | |||||
| const Scene *scene, | |||||
| eScreen_Redraws_Flag redraws) | |||||
| { | |||||
| /* Do follow time here if editor type supports it */ | |||||
| if ((redraws & TIME_FOLLOW) && | |||||
| (screen_animation_region_supports_time_follow(area->spacetype, region->regiontype))) { | |||||
| float w = BLI_rctf_size_x(®ion->v2d.cur); | |||||
| if (scene->r.cfra < region->v2d.cur.xmin) { | |||||
| region->v2d.cur.xmax = scene->r.cfra; | |||||
| region->v2d.cur.xmin = region->v2d.cur.xmax - w; | |||||
| ED_region_tag_redraw(region); | |||||
| return; | |||||
| } | |||||
| else if (scene->r.cfra > region->v2d.cur.xmax) { | |||||
| region->v2d.cur.xmin = scene->r.cfra; | |||||
| region->v2d.cur.xmax = region->v2d.cur.xmin + w; | |||||
| ED_region_tag_redraw (region); | |||||
| return; | |||||
| } | |||||
| } | |||||
| if ((region->regiontype == RGN_TYPE_WINDOW) && | |||||
| (ELEM(area->spacetype, SPACE_GRAPH, SPACE_NLA, SPACE_ACTION, SPACE_SEQ))) { | |||||
| /* No need to do a full redraw as the playhead is only updated. */ | |||||
| return; | |||||
| } | |||||
| ED_region_tag_redraw(region); | |||||
| } | |||||
| //#define PROFILE_AUDIO_SYNCH | //#define PROFILE_AUDIO_SYNCH | ||||
| static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| { | { | ||||
| bScreen *screen = CTX_wm_screen(C); | bScreen *screen = CTX_wm_screen(C); | ||||
| wmWindow *win = CTX_wm_window(C); | wmWindow *win = CTX_wm_window(C); | ||||
| #ifdef PROFILE_AUDIO_SYNCH | #ifdef PROFILE_AUDIO_SYNCH | ||||
| Show All 22 Lines | if (screen->animtimer && screen->animtimer == event->customdata) { | ||||
| else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) { | else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) { | ||||
| sync = 0; | sync = 0; | ||||
| } | } | ||||
| else { | else { | ||||
| sync = (scene->flag & SCE_FRAME_DROP); | sync = (scene->flag & SCE_FRAME_DROP); | ||||
| } | } | ||||
| if (scene_eval == NULL) { | if (scene_eval == NULL) { | ||||
| /* Happens when undo/redo system is used during playback, nothing meaningful we can do here. | /* Happens when undo/redo system is used during playback, nothing meaningful we can do | ||||
| * here. | |||||
| */ | */ | ||||
| } | } | ||||
| else if (scene_eval->id.recalc & ID_RECALC_AUDIO_SEEK) { | else if (scene_eval->id.recalc & ID_RECALC_AUDIO_SEEK) { | ||||
| /* Ignore seek here, the audio will be updated to the scene frame after jump during next | /* Ignore seek here, the audio will be updated to the scene frame after jump during next | ||||
| * dependency graph update. */ | * dependency graph update. */ | ||||
| } | } | ||||
| else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false && | else if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false && | ||||
| isfinite(time = BKE_sound_sync_scene(scene_eval))) { | isfinite(time = BKE_sound_sync_scene(scene_eval))) { | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | for (window = wm->windows.first; window; window = window->next) { | ||||
| redraw = true; | redraw = true; | ||||
| } | } | ||||
| else if (match_region_with_redraws( | else if (match_region_with_redraws( | ||||
| area->spacetype, region->regiontype, sad->redraws, sad->from_anim_edit)) { | area->spacetype, region->regiontype, sad->redraws, sad->from_anim_edit)) { | ||||
| redraw = true; | redraw = true; | ||||
| } | } | ||||
| if (redraw) { | if (redraw) { | ||||
| ED_region_tag_redraw(region); | screen_animation_region_tag_redraw(area, region, scene, sad->redraws); | ||||
| /* do follow here if editor type supports it */ | |||||
| if ((sad->redraws & TIME_FOLLOW)) { | |||||
| if ((region->regiontype == RGN_TYPE_WINDOW && | |||||
| ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || | |||||
| (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { | |||||
| float w = BLI_rctf_size_x(®ion->v2d.cur); | |||||
| if (scene->r.cfra < region->v2d.cur.xmin) { | |||||
| region->v2d.cur.xmax = scene->r.cfra; | |||||
| region->v2d.cur.xmin = region->v2d.cur.xmax - w; | |||||
| } | |||||
| else if (scene->r.cfra > region->v2d.cur.xmax) { | |||||
| region->v2d.cur.xmin = scene->r.cfra; | |||||
| region->v2d.cur.xmax = region->v2d.cur.xmin + w; | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* update frame rate info too | /* update frame rate info too | ||||
| * NOTE: this may not be accurate enough, since we might need this after modifiers/etc. | * NOTE: this may not be accurate enough, since we might need this after modifiers/etc. | ||||
| * have been calculated instead of just before updates have been done? | * have been calculated instead of just before updates have been done? | ||||
| ▲ Show 20 Lines • Show All 1,025 Lines • Show Last 20 Lines | |||||