[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29174] trunk/blender: Reworked the non-blocking reports display in the info header:
Matt Ebb
matt at mke3.net
Thu Jun 3 09:27:55 CEST 2010
Revision: 29174
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29174
Author: broken
Date: 2010-06-03 09:27:55 +0200 (Thu, 03 Jun 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/space_info.py
trunk/blender/source/blender/blenkernel/BKE_report.h
trunk/blender/source/blender/blenkernel/intern/report.c
trunk/blender/source/blender/editors/include/UI_interface.h
trunk/blender/source/blender/editors/interface/interface_templates.c
trunk/blender/source/blender/editors/interface/interface_widgets.c
trunk/blender/source/blender/editors/mesh/editmesh_tools.c
trunk/blender/source/blender/editors/space_info/info_intern.h
trunk/blender/source/blender/editors/space_info/info_ops.c
trunk/blender/source/blender/editors/space_info/space_info.c
trunk/blender/source/blender/makesdna/DNA_windowmanager_types.h
trunk/blender/source/blender/makesrna/intern/rna_ui_api.c
trunk/blender/source/blender/windowmanager/intern/wm.c
trunk/blender/source/blender/windowmanager/intern/wm_event_system.c
Modified: trunk/blender/release/scripts/ui/space_info.py
===================================================================
--- trunk/blender/release/scripts/ui/space_info.py 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/release/scripts/ui/space_info.py 2010-06-03 07:27:55 UTC (rev 29174)
@@ -65,10 +65,9 @@
layout.template_running_jobs()
- if last_op and last_op.has_reports:
- layout.template_reports_banner(last_op)
- else:
- layout.label(text=scene.statistics())
+ layout.template_reports_banner()
+
+ layout.label(text=scene.statistics())
# XXX: this should be right-aligned to the RHS of the region
layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
Modified: trunk/blender/source/blender/blenkernel/BKE_report.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_report.h 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/blenkernel/BKE_report.h 2010-06-03 07:27:55 UTC (rev 29174)
@@ -59,6 +59,8 @@
char *BKE_reports_string(ReportList *reports, ReportType level);
void BKE_reports_print(ReportList *reports, ReportType level);
+Report *BKE_reports_last_displayable(ReportList *reports);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/blender/source/blender/blenkernel/intern/report.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/report.c 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/blenkernel/intern/report.c 2010-06-03 07:27:55 UTC (rev 29174)
@@ -32,6 +32,7 @@
#include "BKE_report.h"
#include "BKE_global.h" /* G.background only */
+#include "BKE_utildefines.h"
#include <stdarg.h>
#include <stdio.h>
@@ -262,3 +263,14 @@
MEM_freeN(cstring);
}
+Report *BKE_reports_last_displayable(ReportList *reports)
+{
+ Report *report=NULL;
+
+ for (report= (Report *)reports->list.last; report; report=report->prev) {
+ if (ELEM3(report->type, RPT_ERROR, RPT_WARNING, RPT_INFO))
+ return report;
+ }
+
+ return NULL;
+}
\ No newline at end of file
Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/editors/include/UI_interface.h 2010-06-03 07:27:55 UTC (rev 29174)
@@ -693,7 +693,7 @@
void uiTemplateOperatorSearch(uiLayout *layout);
void uiTemplateHeader3D(uiLayout *layout, struct bContext *C);
void uiTemplateTextureImage(uiLayout *layout, struct bContext *C, struct Tex *tex);
-void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C, struct wmOperator *op);
+void uiTemplateReportsBanner(uiLayout *layout, struct bContext *C);
void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, char *propname, struct PointerRNA *activeptr, char *activeprop, int rows, int maxrows, int type);
Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c 2010-06-03 07:27:55 UTC (rev 29174)
@@ -30,6 +30,7 @@
#include "DNA_scene_types.h"
#include "DNA_userdef_types.h"
+#include "DNA_windowmanager_types.h"
#include "BLI_string.h"
@@ -53,6 +54,8 @@
#include "UI_interface.h"
#include "interface_intern.h"
+#include "BLF_api.h"
+
void ui_template_fix_linking()
{
}
@@ -2455,49 +2458,59 @@
uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, "Capture", 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop screencast");
if(screen->animtimer)
uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, "Anim Player", 0,0,100,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "Stop animation playback");
-
- uiItemS(layout);
}
/************************* Reports for Last Operator Template **************************/
-void uiTemplateReportsBanner(uiLayout *layout, bContext *C, wmOperator *op)
+void uiTemplateReportsBanner(uiLayout *layout, bContext *C)
{
- ReportList *reports = op->reports;
- uiLayout *box;
+ ReportList *reports = CTX_wm_reports(C);
+ Report *report= BKE_reports_last_displayable(reports);
+ ReportTimerInfo *rti;
- /* sanity checks */
- if (ELEM(NULL, op, reports)) {
- printf("uiTemplateReportsBanner: no operator with reports!\n");
- return;
- }
+ uiLayout *abs;
+ uiBlock *block;
+ uiBut *but;
+ uiStyle *style= U.uistyles.first;
+ int width;
+ float hsv[3];
+ /* if the report display has timed out, don't show */
+ if (!reports->reporttimer) return;
+
+ rti= (ReportTimerInfo *)reports->reporttimer->customdata;
+
+ if (!rti || rti->widthfac==0.0 || !report) return;
+
+ abs = uiLayoutAbsolute(layout, 0);
+ block= uiLayoutGetBlock(abs);
+
+ rgb_to_hsv(rti->col[0], rti->col[1], rti->col[2], hsv+0, hsv+1, hsv+2);
+
+ width = BLF_width(style->widget.uifont_id, report->message);
+ width = MIN2(rti->widthfac*width, width);
+ width = MAX2(width, 10);
+
/* make a box around the report to make it stand out */
- box = uiLayoutBox(layout);
- uiLayoutSetScaleY(box, 0.48); /* experimentally determined value to reduce execessive padding... */
+ uiBlockBeginAlign(block);
+ but= uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X+10, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ copy_v3_v3(but->hsv, hsv); /* set the report's bg colour in but->hsv - ROUNDBOX feature */
- /* if more than one report, we need to show the popup when user clicks on the temp label... */
- if (reports->list.first != reports->list.last) {
- int numReports = BLI_countlist(&reports->list);
- char buf[64];
-
- // XXX: we need uiItem* to return uiBut pointer so that we can use it to set callbacks
- // used to call uiPupMenuReports... as alternative, we could fall back to the "old ways"
- //sprintf(buf, "Last Operator had %d errors. Click to see more...", numReports);
- sprintf(buf, "Last Operator had %d errors", numReports);
- uiItemL(box, buf, ICON_INFO);
- }
- else {
- /* single report, so show report directly */
- // XXX: what if the report is too long? should we truncate the text?
- Report *report= (Report *)reports->list.first;
-
- if(report->type >= RPT_ERROR)
- uiItemL(box, report->message, ICON_ERROR);
- else if(report->type >= RPT_WARNING)
- uiItemL(box, report->message, ICON_ERROR);
- else if(report->type >= RPT_INFO)
- uiItemL(box, report->message, ICON_INFO);
- }
+ but= uiDefBut(block, ROUNDBOX, 0, "", UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ but->hsv[0] = but->hsv[1] = 0.0; /* set a greyscale bg colour in but->hsv - ROUNDBOX feature */
+ but->hsv[2] = rti->greyscale;
+ uiBlockEndAlign(block);
+
+
+ /* icon and report message on top */
+ if(report->type & RPT_ERROR_ALL)
+ uiDefIconBut(block, LABEL, 0, ICON_ERROR, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ else if(report->type & RPT_WARNING_ALL)
+ uiDefIconBut(block, LABEL, 0, ICON_ERROR, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+ else if(report->type & RPT_INFO_ALL)
+ uiDefIconBut(block, LABEL, 0, ICON_INFO, 2, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+
+ uiDefBut(block, LABEL, 0, report->message, UI_UNIT_X+10, 0, UI_UNIT_X+width, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, "");
+
}
Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c 2010-06-03 07:27:55 UTC (rev 29174)
@@ -2368,9 +2368,21 @@
static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
uiWidgetBase wtb;
+ char old_col[3];
widget_init(&wtb);
+ VECCOPY(old_col, wcol->inner);
+
+ /* abuse but->hsv - if it's non-zero, use this colour as the box's background */
+ if ((but->hsv[0] != 0.0) || (but->hsv[1] != 0.0) || (but->hsv[2] != 0.0)) {
+ float rgb[3];
+ hsv_to_rgb(but->hsv[0], but->hsv[1], but->hsv[2], rgb+0, rgb+1, rgb+2);
+ wcol->inner[0] = rgb[0] * 255;
+ wcol->inner[1] = rgb[1] * 255;
+ wcol->inner[2] = rgb[2] * 255;
+ }
+
/* half rounded */
round_box_edges(&wtb, roundboxalign, rect, 4.0f);
@@ -2379,6 +2391,8 @@
/* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects
* over the top to indicate disabled buttons */
glClearColor(wcol->inner[0]/255.0, wcol->inner[1]/255.0, wcol->inner[2]/255.0, 1.0);
+
+ VECCOPY(wcol->inner, old_col);
}
static void widget_but(uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
Modified: trunk/blender/source/blender/editors/mesh/editmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/editors/mesh/editmesh_tools.c 2010-06-03 07:27:55 UTC (rev 29174)
@@ -481,15 +481,11 @@
{
Object *obedit= CTX_data_edit_object(C);
EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
- /*char msg[100];*/
- /*int cnt =*/ removedoublesflag(em,1,0,RNA_float_get(op->ptr, "limit"));
- /*XXX this messes up last operator panel
- if(cnt)
- {
- sprintf(msg, "Removed %d vertices", cnt);
- BKE_report(op->reports, RPT_INFO, msg);
- }*/
+ int count = removedoublesflag(em,1,0,RNA_float_get(op->ptr, "limit"));
+
+ if(count)
+ BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", cnt);
DAG_id_flush_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
Modified: trunk/blender/source/blender/editors/space_info/info_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_info/info_intern.h 2010-06-03 06:45:55 UTC (rev 29173)
+++ trunk/blender/source/blender/editors/space_info/info_intern.h 2010-06-03 07:27:55 UTC (rev 29174)
@@ -39,5 +39,7 @@
void FILE_OT_report_missing_files(struct wmOperatorType *ot);
void FILE_OT_find_missing_files(struct wmOperatorType *ot);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list