diff options
Diffstat (limited to 'source/blender/editors/space_info/info_ops.c')
-rw-r--r-- | source/blender/editors/space_info/info_ops.c | 110 |
1 files changed, 100 insertions, 10 deletions
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 072c5bf1573..62e82f83e58 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -31,14 +31,12 @@ #include "DNA_packedFile_types.h" #include "DNA_space_types.h" -#include "DNA_scene_types.h" -#include "DNA_screen_types.h" -#include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "BLI_bpath.h" #include "BKE_context.h" @@ -49,9 +47,6 @@ #include "BKE_report.h" #include "BKE_screen.h" -#include "ED_screen.h" -#include "ED_types.h" -#include "ED_util.h" #include "WM_api.h" #include "WM_types.h" @@ -60,14 +55,12 @@ #include "BIF_glutil.h" #include "UI_interface.h" -#include "UI_resources.h" #include "IMB_imbuf_types.h" #include "RNA_access.h" #include "RNA_define.h" -#include "WM_types.h" #include "info_intern.h" @@ -278,7 +271,7 @@ static int find_missing_files_exec(bContext *C, wmOperator *op) { char *path; - path= RNA_string_get_alloc(op->ptr, "path", NULL, 0); + path= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); findMissingFiles(path, G.sce); MEM_freeN(path); @@ -306,5 +299,102 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); +} + +/********************* 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 */ } |