diff options
author | Matt Ebb <matt@mke3.net> | 2010-06-03 11:27:55 +0400 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-06-03 11:27:55 +0400 |
commit | 21d112c36f661f3ce8648f4eadfe1325929e9184 (patch) | |
tree | 0f880b11d750b7d5800154faa67e9920012e8b83 /source/blender/editors/space_info/info_ops.c | |
parent | 3b6aa5b6a588b76e1ed6f25f11ae77dd07ecfa46 (diff) |
Reworked the non-blocking reports display in the info header:
* Now it displays the last report from the global list, not just from operators
* Rather than disappearing when a new operator is run, it stays until it times
out or a new report is added
* Fun animated transitions ;)
http://mke3.net/blender/devel/2.5/reports_header.mov
Now need to investigate report usage with popups. Ideally we can have most
reports non-blocking, so they're less intrusive, only popping up for dire errors.
Problem is many things in Blender right now are marked as RPT_ERROR
when probably RPT_WARNING is more appropriate. Should probably keep
RPT_ERROR for things that demand immediate attention.
Diffstat (limited to 'source/blender/editors/space_info/info_ops.c')
-rw-r--r-- | source/blender/editors/space_info/info_ops.c | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index e2baeb9abac..64d2c6138c7 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "BLI_bpath.h" #include "BKE_context.h" @@ -300,3 +301,100 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) /* properties */ WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE); } + +/********************* report box operator *********************/ + +/* Hard to decide whether to keep this as an operator, + * or turn it into a hardcoded ui control feature, + * handling TIMER events for all regions in interface_handlers.c + * Not sure how good that is to be accessing UI data from + * inactive regions, so use this for now. --matt + */ + +#define INFO_TIMEOUT 5.0 +#define INFO_COLOR_TIMEOUT 3.0 +#define ERROR_TIMEOUT 10.0 +#define ERROR_COLOR_TIMEOUT 6.0 +#define COLLAPSE_TIMEOUT 0.2 +static int update_reports_display_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + wmWindowManager *wm= CTX_wm_manager(C); + ReportList *reports= CTX_wm_reports(C); + Report *report; + ReportTimerInfo *rti; + float progress=0.0, color_progress=0.0; + float neutral_col[3] = {0.35, 0.35, 0.35}; + float neutral_grey= 0.6; + float timeout=0.0, color_timeout=0.0; + + /* escape if not our timer */ + if(reports->reporttimer==NULL || reports->reporttimer != event->customdata) + return OPERATOR_PASS_THROUGH; + + report= BKE_reports_last_displayable(reports); + rti = (ReportTimerInfo *)reports->reporttimer->customdata; + + timeout = (report->type & RPT_ERROR_ALL)?ERROR_TIMEOUT:INFO_TIMEOUT; + color_timeout = (report->type & RPT_ERROR_ALL)?ERROR_COLOR_TIMEOUT:INFO_COLOR_TIMEOUT; + + /* clear the report display after timeout */ + if (reports->reporttimer->duration > timeout) { + WM_event_remove_timer(wm, NULL, reports->reporttimer); + reports->reporttimer = NULL; + + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); + + return (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH); + } + + if (rti->widthfac == 0.0) { + /* initialise colours based on report type */ + if(report->type & RPT_ERROR_ALL) { + rti->col[0] = 1.0; + rti->col[1] = 0.2; + rti->col[2] = 0.0; + } else if(report->type & RPT_WARNING_ALL) { + rti->col[0] = 1.0; + rti->col[1] = 1.0; + rti->col[2] = 0.0; + } else if(report->type & RPT_INFO_ALL) { + rti->col[0] = 0.3; + rti->col[1] = 0.45; + rti->col[2] = 0.7; + } + rti->greyscale = 0.75; + rti->widthfac=1.0; + } + + progress = reports->reporttimer->duration / timeout; + color_progress = reports->reporttimer->duration / color_timeout; + + /* fade colours out sharply according to progress through fade-out duration */ + interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress); + rti->greyscale = interpf(neutral_grey, rti->greyscale, color_progress); + + /* collapse report at end of timeout */ + if (progress*timeout > timeout - COLLAPSE_TIMEOUT) { + rti->widthfac = (progress*timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT; + rti->widthfac = 1.0 - rti->widthfac; + } + + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); + + return (OPERATOR_FINISHED|OPERATOR_PASS_THROUGH); +} + +void INFO_OT_reports_display_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Update Reports Display"; + ot->idname= "INFO_OT_reports_display_update"; + + /* api callbacks */ + ot->invoke= update_reports_display_invoke; + + /* flags */ + ot->flag= 0; + + /* properties */ +}
\ No newline at end of file |