From 3f326354b8b09c2f08b114b4030e49bbbfa693af Mon Sep 17 00:00:00 2001 From: Damien Plisson Date: Tue, 1 Jun 2010 20:21:40 +0000 Subject: Progress indicator in the application icon Displays a global progress indicator in the application icon reflecting the total progress of all running jobs. Currently fully implemented on OSX (Cocoa). On other OSes that do not allow to redraw the app icon, this can be implemented as a [x%] display in the app title, so to appear in the taskbar. Thanks to Matt for the windowmanager wrapper. --- source/blender/windowmanager/intern/wm_jobs.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/windowmanager/intern/wm_jobs.c') diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index a92a3d746ad..e7df703ba79 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -381,6 +381,9 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) { wmJob *steve= wm->jobs.first, *stevenext; + float total_progress= 0.f; + float jobs_progress=0; + for(; steve; steve= stevenext) { stevenext= steve->next; @@ -434,6 +437,10 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) BLI_remlink(&wm->jobs, steve); MEM_freeN(steve); } + } else if (steve->flag & WM_JOB_PROGRESS) { + /* accumulate global progress for running jobs */ + jobs_progress++; + total_progress += steve->progress; } } else if(steve->suspended) { @@ -441,5 +448,13 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) } } } + + /* if there are running jobs, set the global progress indicator */ + if (jobs_progress > 0) { + float progress = total_progress / (float)jobs_progress; + WM_progress_set(wm->winactive, progress); + } else { + WM_progress_clear(wm->winactive); + } } -- cgit v1.2.3