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 match_region_with_redraws(const ScrArea *area, | |||||
| static int match_region_with_redraws(int spacetype, | eRegionType regiontype, | ||||
| int regiontype, | eScreen_Redraws_Flag redraws, | ||||
| int redraws, | |||||
| bool from_anim_edit) | bool from_anim_edit) | ||||
| { | { | ||||
| const eSpace_Type spacetype = area->spacetype; | |||||
| if (regiontype == RGN_TYPE_WINDOW) { | if (regiontype == RGN_TYPE_WINDOW) { | ||||
| switch (spacetype) { | switch (spacetype) { | ||||
| case SPACE_VIEW3D: | case SPACE_VIEW3D: | ||||
| if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit) { | if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_GRAPH: | case SPACE_GRAPH: | ||||
| case SPACE_NLA: | case SPACE_NLA: | ||||
| if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit) { | if ((redraws & TIME_ALL_ANIM_WIN) || from_anim_edit) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_ACTION: | case SPACE_ACTION: | ||||
| /* if only 1 window or 3d windows, we do timeline too | /* if only 1 window or 3d windows, we do timeline too | ||||
| * NOTE: Now we do action editor in all these cases, since timeline is here. */ | * NOTE: Now we do action editor in all these cases, since timeline is here. */ | ||||
| if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit) { | if ((redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) || from_anim_edit) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_PROPERTIES: | case SPACE_PROPERTIES: | ||||
| if (redraws & TIME_ALL_BUTS_WIN) { | if (redraws & TIME_ALL_BUTS_WIN) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_SEQ: | case SPACE_SEQ: | ||||
| if ((redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) || from_anim_edit) { | if ((redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) || from_anim_edit) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_NODE: | case SPACE_NODE: | ||||
| if (redraws & TIME_NODES) { | if (redraws & TIME_NODES) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_IMAGE: | case SPACE_IMAGE: | ||||
| if ((redraws & TIME_ALL_IMAGE_WIN) || from_anim_edit) { | if ((redraws & TIME_ALL_IMAGE_WIN) || from_anim_edit) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_CLIP: | case SPACE_CLIP: | ||||
| if ((redraws & TIME_CLIPS) || from_anim_edit) { | if ((redraws & TIME_CLIPS) || from_anim_edit) { | ||||
| return 1; | return true; | ||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| else if (regiontype == RGN_TYPE_CHANNELS) { | |||||
| switch (spacetype) { | |||||
| case SPACE_GRAPH: | |||||
| case SPACE_ACTION: | |||||
| case SPACE_NLA: | |||||
| if (redraws & TIME_ALL_ANIM_WIN) { | |||||
| return 1; | |||||
| } | } | ||||
| break; | break; | ||||
| default: | |||||
| return false; | |||||
| } | } | ||||
| } | } | ||||
| else if (regiontype == RGN_TYPE_UI) { | else if (regiontype == RGN_TYPE_UI) { | ||||
| if (spacetype == SPACE_CLIP) { | if (spacetype == SPACE_CLIP) { | ||||
| /* Track Preview button is on Properties Editor in SpaceClip, | /* Track Preview button is on Properties Editor in SpaceClip, | ||||
| * and it's very common case when users want it be refreshing | * and it's very common case when users want it be refreshing | ||||
| * during playback, so asking people to enable special option | * during playback, so asking people to enable special option | ||||
| * for this is a bit tricky, so add exception here for refreshing | * for this is a bit tricky, so add exception here for refreshing | ||||
| * Properties Editor for SpaceClip always */ | * Properties Editor for SpaceClip always */ | ||||
| return 1; | return true; | ||||
| } | } | ||||
| if (redraws & TIME_ALL_BUTS_WIN) { | if (redraws & TIME_ALL_BUTS_WIN) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| } | } | ||||
| else if (ELEM(regiontype, RGN_TYPE_HEADER, RGN_TYPE_TOOL_HEADER)) { | else if (regiontype == RGN_TYPE_HEADER) { | ||||
| if (spacetype == SPACE_ACTION) { | if (spacetype == SPACE_ACTION) { | ||||
| return 1; | /* The timeline shows the current frame in the header. Other headers | ||||
| * don't need to be updated */ | |||||
| SpaceAction *saction = (SpaceAction *)area->spacedata.first; | |||||
| return saction->mode == SACTCONT_TIMELINE; | |||||
| } | } | ||||
| } | } | ||||
| else if (regiontype == RGN_TYPE_PREVIEW) { | else if (regiontype == RGN_TYPE_PREVIEW) { | ||||
| switch (spacetype) { | switch (spacetype) { | ||||
| case SPACE_SEQ: | case SPACE_SEQ: | ||||
| if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) { | if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) { | ||||
| return 1; | return true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SPACE_CLIP: | case SPACE_CLIP: | ||||
| return 1; | return true; | ||||
| default: | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| return 0; | return false; | ||||
| } | |||||
| static void screen_animation_action_region_tag_redraw(ARegion *region) | |||||
| { | |||||
| switch (region->regiontype) { | |||||
| case RGN_TYPE_UI: | |||||
| case RGN_TYPE_HEADER: { | |||||
| ED_region_tag_redraw(region); | |||||
| break; | |||||
| } | |||||
| case RGN_TYPE_WINDOW: { | |||||
| ED_region_tag_redraw_editor_overlays(region); | |||||
| break; | |||||
| } | |||||
| default: { | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| static void screen_animation_region_tag_redraw(ScrArea *area, ARegion *region) | |||||
| { | |||||
| switch (area->spacetype) { | |||||
| case SPACE_ACTION: { | |||||
| /* for TIME mode we should draw the header as it contains the current frame number | |||||
| */ | |||||
| screen_animation_action_region_tag_redraw(region); | |||||
| break; | |||||
| } | |||||
| default: | |||||
| ED_region_tag_redraw(region); | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| //#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); | ||||
| Show All 24 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 123 Lines • ▼ Show 20 Lines | for (window = wm->windows.first; window; window = window->next) { | ||||
| for (area = win_screen->areabase.first; area; area = area->next) { | for (area = win_screen->areabase.first; area; area = area->next) { | ||||
| ARegion *region; | ARegion *region; | ||||
| for (region = area->regionbase.first; region; region = region->next) { | for (region = area->regionbase.first; region; region = region->next) { | ||||
| bool redraw = false; | bool redraw = false; | ||||
| if (region == sad->region) { | if (region == sad->region) { | ||||
| 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, 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); | ||||
| /* do follow here if editor type supports it */ | /* do follow here if editor type supports it */ | ||||
| if ((sad->redraws & TIME_FOLLOW)) { | if ((sad->redraws & TIME_FOLLOW)) { | ||||
| if ((region->regiontype == RGN_TYPE_WINDOW && | if ((region->regiontype == RGN_TYPE_WINDOW && | ||||
| ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || | ELEM(area->spacetype, SPACE_SEQ, SPACE_GRAPH, SPACE_ACTION, SPACE_NLA)) || | ||||
| (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { | (area->spacetype == SPACE_CLIP && region->regiontype == RGN_TYPE_PREVIEW)) { | ||||
| float w = BLI_rctf_size_x(®ion->v2d.cur); | float w = BLI_rctf_size_x(®ion->v2d.cur); | ||||
| if (scene->r.cfra < region->v2d.cur.xmin) { | if (scene->r.cfra < region->v2d.cur.xmin) { | ||||
| region->v2d.cur.xmax = scene->r.cfra; | region->v2d.cur.xmax = scene->r.cfra; | ||||
| ▲ Show 20 Lines • Show All 1,041 Lines • Show Last 20 Lines | |||||