From df57beb6764553c6cf2555d188d0bcec630ecd8d Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sun, 5 Jan 2025 02:00:37 +0100 Subject: [PATCH] UI: Improved User Feedback for Animation Playback Timer The "Blender" menu contains seven items in "System / "Redraw Timer" that are for troubleshooting and testing. Six of the items take far less than a second, but one takes a long time. "Animation Play" times how long it takes to play through your current animation ten times. But there is no way to guess this and some users have run it accidentally by finding it in menu search. It gives no feedback at all, and there are no hints on how long it will take. Once it plays through your animation once you might guess that it runs forever. This PR shows the test name and where it is in its ten runs. On platforms that support it this also shows an app progress bar (on the taskbar icon for Windows). Pull Request: https://projects.blender.org/blender/blender/pulls/132648 --- .../windowmanager/intern/wm_operators.cc | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 0228c8a2b3a..0a395ff645e 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -3590,7 +3590,9 @@ static void redraw_timer_step(bContext *C, ScrArea *area, ARegion *region, const int type, - const int cfra) + const int cfra, + const int steps_done, + const int steps_total) { if (type == eRTDrawRegion) { if (region) { @@ -3636,8 +3638,13 @@ static void redraw_timer_step(bContext *C, else if (type == eRTAnimationPlay) { /* Play anim, return on same frame as started with. */ int tot = (scene->r.efra - scene->r.sfra) + 1; + const int frames_total = tot * steps_total; + int frames_done = tot * steps_done; while (tot--) { + WM_progress_set(win, float(frames_done) / float(frames_total)); + frames_done++; + /* TODO: ability to escape! */ scene->r.cfra++; if (scene->r.cfra > scene->r.efra) { @@ -3684,6 +3691,8 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) */ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); + RNA_enum_description(redraw_timer_type_items, type, &infostr); + WM_cursor_wait(true); double time_start = BLI_time_now_seconds(); @@ -3692,7 +3701,13 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) int iter_steps = 0; for (int a = 0; a < iter; a++) { - redraw_timer_step(C, scene, depsgraph, win, area, region, type, cfra); + + if (type == eRTAnimationPlay) { + WorkspaceStatus status(C); + status.item(fmt::format("{} / {} {}", a + 1, iter, infostr), ICON_INFO); + } + + redraw_timer_step(C, scene, depsgraph, win, area, region, type, cfra, a, iter); iter_steps += 1; if (time_limit != 0.0) { @@ -3705,7 +3720,10 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) double time_delta = (BLI_time_now_seconds() - time_start) * 1000; - RNA_enum_description(redraw_timer_type_items, type, &infostr); + if (type == eRTAnimationPlay) { + ED_workspace_status_text(C, nullptr); + WM_progress_clear(win); + } WM_cursor_wait(false);