Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2020-02-04 21:51:35 +0300
committerJulian Eisel <eiseljulian@gmail.com>2020-02-04 21:54:06 +0300
commitf7ca86369da89a6726bc9edc9bf4e875b2b43c46 (patch)
tree81fd5f2f163214d01f77fd2dc640ab2d9668d42e
parentc19112d755f1aa0e2343e07a8f6162a438189a7b (diff)
Reports: Add utility to cancel displayed reports
Sebastián Barschkis needs something like this to fix an issue, so he asked me to add this to the release branch. It's unused for now.
-rw-r--r--source/blender/blenkernel/intern/report.c5
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c10
3 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 5db091e6a43..6b8d7f856ce 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -76,6 +76,11 @@ void BKE_reports_init(ReportList *reports, int flag)
reports->flag = flag;
}
+/**
+ * Only frees the list \a reports.
+ * To make displayed reports disappear, either remove window-manager reports
+ * (wmWindowManager.reports, or CTX_wm_reports()), or use #WM_report_banners_cancel().
+ */
void BKE_reports_clear(ReportList *reports)
{
Report *report, *report_next;
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index d24157a22a6..e128f87f5b7 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -309,6 +309,7 @@ void WM_main_remap_editor_id_reference(struct ID *old_id, struct ID *new_id);
/* reports */
void WM_report_banner_show(void);
+void WM_report_banners_cancel(struct Main *bmain);
void WM_report(ReportType type, const char *message);
void WM_reportf(ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(2, 3);
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index f5970e8fb61..104fbc84306 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -861,6 +861,16 @@ void WM_report_banner_show(void)
wm_reports->reporttimer->customdata = rti;
}
+/**
+ * Hide all currently displayed banners and abort their timer.
+ */
+void WM_report_banners_cancel(Main *bmain)
+{
+ wmWindowManager *wm = bmain->wm.first;
+ BKE_reports_clear(&wm->reports);
+ WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
+}
+
bool WM_event_is_last_mousemove(const wmEvent *event)
{
while ((event = event->next)) {