Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_info/info_ops.c
| Show First 20 Lines • Show All 492 Lines • ▼ Show 20 Lines | |||||
| /* Hard to decide whether to keep this as an operator, | /* Hard to decide whether to keep this as an operator, | ||||
| * or turn it into a hardcoded ui control feature, | * or turn it into a hardcoded ui control feature, | ||||
| * handling TIMER events for all regions in interface_handlers.c | * handling TIMER events for all regions in interface_handlers.c | ||||
| * Not sure how good that is to be accessing UI data from | * Not sure how good that is to be accessing UI data from | ||||
| * inactive regions, so use this for now. --matt | * inactive regions, so use this for now. --matt | ||||
| */ | */ | ||||
| #define INFO_TIMEOUT 5.0f | #define INFO_TIMEOUT 5.0f | ||||
| #define INFO_COLOR_TIMEOUT 3.0f | |||||
| #define ERROR_TIMEOUT 10.0f | #define ERROR_TIMEOUT 10.0f | ||||
| #define ERROR_COLOR_TIMEOUT 6.0f | #define FLASH_TIMEOUT 1.0f | ||||
| #define COLLAPSE_TIMEOUT 0.25f | #define COLLAPSE_TIMEOUT 0.25f | ||||
| #define BRIGHTEN_AMOUNT 0.1f | |||||
| static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) | ||||
| { | { | ||||
| wmWindowManager *wm = CTX_wm_manager(C); | wmWindowManager *wm = CTX_wm_manager(C); | ||||
| ReportList *reports = CTX_wm_reports(C); | ReportList *reports = CTX_wm_reports(C); | ||||
| Report *report; | Report *report; | ||||
| ReportTimerInfo *rti; | ReportTimerInfo *rti; | ||||
| float progress = 0.0, color_progress = 0.0; | float target_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | ||||
| float neutral_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | float progress = 0.0, flash_progress = 0.0; | ||||
| float timeout = 0.0, color_timeout = 0.0; | float timeout = 0.0, flash_timeout = FLASH_TIMEOUT; | ||||
| int send_note = 0; | int send_note = 0; | ||||
| /* escape if not our timer */ | /* escape if not our timer */ | ||||
| if ((reports->reporttimer == NULL) || | if ((reports->reporttimer == NULL) || | ||||
| (reports->reporttimer != event->customdata) || | (reports->reporttimer != event->customdata) || | ||||
| ((report = BKE_reports_last_displayable(reports)) == NULL) /* may have been deleted */ | ((report = BKE_reports_last_displayable(reports)) == NULL) /* may have been deleted */ | ||||
| ) | ) | ||||
| { | { | ||||
| return OPERATOR_PASS_THROUGH; | return OPERATOR_PASS_THROUGH; | ||||
| } | } | ||||
| rti = (ReportTimerInfo *)reports->reporttimer->customdata; | rti = (ReportTimerInfo *)reports->reporttimer->customdata; | ||||
| timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT; | 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 */ | /* clear the report display after timeout */ | ||||
| if ((float)reports->reporttimer->duration > timeout) { | if ((float)reports->reporttimer->duration > timeout) { | ||||
| WM_event_remove_timer(wm, NULL, reports->reporttimer); | WM_event_remove_timer(wm, NULL, reports->reporttimer); | ||||
| reports->reporttimer = NULL; | reports->reporttimer = NULL; | ||||
| WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); | WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); | ||||
| return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH); | return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH); | ||||
| } | } | ||||
| if (rti->widthfac == 0.0f) { | /* set target color based on report type */ | ||||
| /* initialize colors based on report type */ | |||||
| if (report->type & RPT_ERROR_ALL) { | if (report->type & RPT_ERROR_ALL) { | ||||
| rti->col[0] = 1.0f; | UI_GetThemeColorType3fv(TH_INFO_ERROR, SPACE_INFO, target_col); | ||||
| rti->col[1] = 0.2f; | |||||
| rti->col[2] = 0.0f; | |||||
| } | } | ||||
| else if (report->type & RPT_WARNING_ALL) { | else if (report->type & RPT_WARNING_ALL) { | ||||
| rti->col[0] = 1.0f; | UI_GetThemeColorType3fv(TH_INFO_WARNING, SPACE_INFO, target_col); | ||||
| rti->col[1] = 1.0f; | |||||
| rti->col[2] = 0.0f; | |||||
| } | } | ||||
| else if (report->type & RPT_INFO_ALL) { | else if (report->type & RPT_INFO_ALL) { | ||||
| rti->col[0] = 0.3f; | UI_GetThemeColorType3fv(TH_INFO_INFO, SPACE_INFO, target_col); | ||||
| rti->col[1] = 0.45f; | |||||
| rti->col[2] = 0.7f; | |||||
| } | } | ||||
| rti->col[3] = 0.65f; | target_col[3] = 0.65f; | ||||
| if (rti->widthfac == 0.0f) { | |||||
| /* initialize color to a brighter shade of the target color */ | |||||
| rti->col[0] = target_col[0] + BRIGHTEN_AMOUNT; | |||||
| rti->col[1] = target_col[1] + BRIGHTEN_AMOUNT; | |||||
| rti->col[2] = target_col[2] + BRIGHTEN_AMOUNT; | |||||
| rti->col[3] = 1.0f; | |||||
| CLAMP3(rti->col, 0.0, 1.0); | |||||
| rti->widthfac = 1.0f; | rti->widthfac = 1.0f; | ||||
| } | } | ||||
| progress = powf((float)reports->reporttimer->duration / timeout, 2.0f); | progress = powf((float)reports->reporttimer->duration / timeout, 2.0f); | ||||
| color_progress = powf((float)reports->reporttimer->duration / color_timeout, 2.0); | flash_progress = powf((float)reports->reporttimer->duration / flash_timeout, 2.0); | ||||
| /* save us from too many draws */ | /* save us from too many draws */ | ||||
| if (color_progress <= 1.0f) { | if (flash_progress <= 1.0f) { | ||||
| send_note = 1; | send_note = 1; | ||||
| /* fade colors out sharply according to progress through fade-out duration */ | /* flash report briefly according to progress through fade-out duration */ | ||||
| interp_v4_v4v4(rti->col, rti->col, neutral_col, color_progress); | interp_v4_v4v4(rti->col, rti->col, target_col, flash_progress); | ||||
| } | } | ||||
| /* collapse report at end of timeout */ | /* collapse report at end of timeout */ | ||||
| if (progress * timeout > timeout - COLLAPSE_TIMEOUT) { | if (progress * timeout > timeout - COLLAPSE_TIMEOUT) { | ||||
| rti->widthfac = (progress * timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT; | rti->widthfac = (progress * timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT; | ||||
| rti->widthfac = 1.0f - rti->widthfac; | rti->widthfac = 1.0f - rti->widthfac; | ||||
| send_note = 1; | send_note = 1; | ||||
| } | } | ||||
| Show All 25 Lines | |||||