Cleanup: remove unused defines, reduce variable scope

This commit is contained in:
Campbell Barton
2023-09-07 16:06:52 +10:00
parent 3f9a15bc30
commit 6a1ba2aca1

View File

@@ -573,16 +573,11 @@ void FILE_OT_find_missing_files(wmOperatorType *ot)
#define ERROR_TIMEOUT 10.0f
#define FLASH_TIMEOUT 1.0f
#define COLLAPSE_TIMEOUT 0.25f
#define BRIGHTEN_AMOUNT 0.1f
static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)
{
wmWindowManager *wm = CTX_wm_manager(C);
ReportList *reports = CTX_wm_reports(C);
Report *report;
ReportTimerInfo *rti;
float progress = 0.0, flash_progress = 0.0;
float timeout = 0.0, flash_timeout = FLASH_TIMEOUT;
int send_note = 0;
/* escape if not our timer */
if ((reports->reporttimer == nullptr) || (reports->reporttimer != event->customdata) ||
@@ -592,12 +587,16 @@ static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const
return OPERATOR_PASS_THROUGH;
}
rti = (ReportTimerInfo *)reports->reporttimer->customdata;
wmWindowManager *wm = CTX_wm_manager(C);
ReportTimerInfo *rti = (ReportTimerInfo *)reports->reporttimer->customdata;
const float flash_timeout = FLASH_TIMEOUT;
bool send_notifier = false;
timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
const float timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT;
const float time_duration = float(reports->reporttimer->time_duration);
/* clear the report display after timeout */
if (float(reports->reporttimer->time_duration) > timeout) {
if (time_duration > timeout) {
WM_event_timer_remove(wm, nullptr, reports->reporttimer);
reports->reporttimer = nullptr;
@@ -610,13 +609,13 @@ static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const
rti->widthfac = 1.0f;
}
progress = powf(float(reports->reporttimer->time_duration) / timeout, 2.0f);
flash_progress = powf(float(reports->reporttimer->time_duration) / flash_timeout, 2.0);
const float progress = powf(time_duration / timeout, 2.0f);
const float flash_progress = powf(time_duration / flash_timeout, 2.0);
/* save us from too many draws */
if (flash_progress <= 1.0f) {
/* Flash report briefly according to progress through fade-out duration. */
send_note = 1;
send_notifier = true;
}
rti->flash_progress = flash_progress;
@@ -624,10 +623,10 @@ static int update_reports_display_invoke(bContext *C, wmOperator * /*op*/, const
if (progress * timeout > timeout - COLLAPSE_TIMEOUT) {
rti->widthfac = (progress * timeout - (timeout - COLLAPSE_TIMEOUT)) / COLLAPSE_TIMEOUT;
rti->widthfac = 1.0f - rti->widthfac;
send_note = 1;
send_notifier = true;
}
if (send_note) {
if (send_notifier) {
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, nullptr);
}