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:
authorMatt Ebb <matt@mke3.net>2010-06-03 11:27:55 +0400
committerMatt Ebb <matt@mke3.net>2010-06-03 11:27:55 +0400
commit21d112c36f661f3ce8648f4eadfe1325929e9184 (patch)
tree0f880b11d750b7d5800154faa67e9920012e8b83 /source/blender/windowmanager
parent3b6aa5b6a588b76e1ed6f25f11ae77dd07ecfa46 (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/windowmanager')
-rw-r--r--source/blender/windowmanager/intern/wm.c16
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c87
2 files changed, 63 insertions, 40 deletions
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 452c37dbe77..fcf8951d796 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -98,13 +98,18 @@ void WM_operator_free(wmOperator *op)
MEM_freeN(op);
}
+static void wm_reports_free(wmWindowManager *wm)
+{
+ BKE_reports_clear(&wm->reports);
+ WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
+}
+
/* all operations get registered in the windowmanager here */
/* called on event handling by event_system.c */
void wm_operator_register(bContext *C, wmOperator *op)
{
wmWindowManager *wm= CTX_wm_manager(C);
int tot;
- char *buf;
BLI_addtail(&wm->operators, op);
tot= BLI_countlist(&wm->operators);
@@ -116,12 +121,6 @@ void wm_operator_register(bContext *C, wmOperator *op)
tot--;
}
-
- /* Report the string representation of the operator */
- buf = WM_operator_pystring(C, op->type, op->ptr, 1);
- BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
- MEM_freeN(buf);
-
/* so the console is redrawn */
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CONSOLE_REPORT, NULL);
WM_event_add_notifier(C, NC_WM|ND_HISTORY, NULL);
@@ -309,7 +308,8 @@ void wm_close_and_free(bContext *C, wmWindowManager *wm)
BLI_freelistN(&wm->paintcursors);
BLI_freelistN(&wm->drags);
- BKE_reports_clear(&wm->reports);
+
+ wm_reports_free(wm);
if(C && CTX_wm_manager(C)==wm) CTX_wm_manager_set(C, NULL);
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 84a6b3598d7..b55c68ce029 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -372,15 +372,56 @@ int WM_operator_poll(bContext *C, wmOperatorType *ot)
return 1;
}
+static void wm_operator_print(wmOperator *op)
+{
+ char *buf = WM_operator_pystring(NULL, op->type, op->ptr, 1);
+ printf("%s\n", buf);
+ MEM_freeN(buf);
+}
+
+static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int popup)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ ReportList *reports = CTX_wm_reports(C);
+ char *buf;
+
+ if(popup)
+ if(op->reports->list.first)
+ uiPupMenuReports(C, op->reports);
+
+ if(retval & OPERATOR_FINISHED) {
+ if(G.f & G_DEBUG)
+ wm_operator_print(op); /* todo - this print may double up, might want to check more flags then the FINISHED */
+
+ /* Report the python string representation of the operator */
+ buf = WM_operator_pystring(C, op->type, op->ptr, 1);
+ BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
+ MEM_freeN(buf);
+ }
+
+ if (op->reports->list.first) {
+ ReportTimerInfo *rti;
+
+ /* add reports to the global list, otherwise they are not seen */
+ addlisttolist(&CTX_wm_reports(C)->list, &op->reports->list);
+
+ /* After adding reports to the global list, reset the report timer. */
+ WM_event_remove_timer(wm, NULL, reports->reporttimer);
+
+ /* Records time since last report was added */
+ reports->reporttimer= WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02);
+
+ rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
+ reports->reporttimer->customdata = rti;
+ }
+}
+
static void wm_operator_finished(bContext *C, wmOperator *op, int repeat)
{
wmWindowManager *wm= CTX_wm_manager(C);
op->customdata= NULL;
- /* add reports to the global list, otherwise they are not seen */
- addlisttolist(&CTX_wm_reports(C)->list, &op->reports->list);
-
/* we don't want to do undo pushes for operators that are being
called from operators that already do an undo push. usually
this will happen for python operators that call C operators */
@@ -424,9 +465,8 @@ static int wm_operator_exec(bContext *C, wmOperator *op, int repeat)
wm->op_undo_depth--;
}
- if(retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED))
- if(op->reports->list.first)
- uiPupMenuReports(C, op->reports);
+ if (retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED) && repeat == 0)
+ wm_operator_reports(C, op, retval, 0);
if(retval & OPERATOR_FINISHED)
wm_operator_finished(C, op, repeat);
@@ -534,13 +574,6 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P
return op;
}
-static void wm_operator_print(wmOperator *op)
-{
- char *buf = WM_operator_pystring(NULL, op->type, op->ptr, 1);
- printf("%s\n", buf);
- MEM_freeN(buf);
-}
-
static void wm_region_mouse_co(bContext *C, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
@@ -584,18 +617,14 @@ int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, PointerR
}
else
printf("invalid operator call %s\n", ot->idname); /* debug, important to leave a while, should never happen */
-
+
/* Note, if the report is given as an argument then assume the caller will deal with displaying them
* currently python only uses this */
- if((retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED)) && reports==NULL)
- if(op->reports->list.first) /* only show the report if the report list was not given in the function */
- uiPupMenuReports(C, op->reports);
+ if (!(retval & OPERATOR_HANDLED) && retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED))
+ /* only show the report if the report list was not given in the function */
+ wm_operator_reports(C, op, retval, (reports==NULL));
+
- if (retval & OPERATOR_FINISHED) { /* todo - this may conflict with the other wm_operator_print, if theres ever 2 prints for 1 action will may need to add modal check here */
- if(G.f & G_DEBUG)
- wm_operator_print(op);
- }
-
if(retval & OPERATOR_HANDLED)
; /* do nothing, wm_operator_exec() has been called somewhere */
else if(retval & OPERATOR_FINISHED) {
@@ -1084,17 +1113,11 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
/* this special cases is for areas and regions that get removed */
CTX_wm_area_set(C, NULL);
CTX_wm_region_set(C, NULL);
- }
-
- if(retval & (OPERATOR_FINISHED|OPERATOR_CANCELLED))
- if(op->reports->list.first)
- uiPupMenuReports(C, op->reports);
-
- if (retval & OPERATOR_FINISHED) {
- if(G.f & G_DEBUG)
- wm_operator_print(op); /* todo - this print may double up, might want to check more flags then the FINISHED */
- }
+ }
+ if(retval & (OPERATOR_CANCELLED|OPERATOR_FINISHED))
+ wm_operator_reports(C, op, retval, 0);
+
if(retval & OPERATOR_FINISHED) {
wm_operator_finished(C, op, 0);
handler->op= NULL;