[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56169] trunk/blender/source/blender/ makesrna/intern/rna_wm_api.c: Added minimal support for progressbar in python
Gaia Clary
gaia.clary at machinimatrix.org
Fri Apr 19 16:47:12 CEST 2013
Revision: 56169
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56169
Author: gaiaclary
Date: 2013-04-19 14:47:11 +0000 (Fri, 19 Apr 2013)
Log Message:
-----------
Added minimal support for progressbar in python
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_wm_api.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_wm_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_wm_api.c 2013-04-19 13:26:17 UTC (rev 56168)
+++ trunk/blender/source/blender/makesrna/intern/rna_wm_api.c 2013-04-19 14:47:11 UTC (rev 56169)
@@ -86,6 +86,44 @@
WM_event_remove_timer(wm, timer->win, timer);
}
+/* placeholder data for final implementation of a true progressbar */
+struct wmStaticProgress {
+ float min;
+ float max;
+ bool is_valid;
+} wm_progress_state = {0, 0, false};
+
+
+static void rna_progress_begin(struct wmWindowManager *wm, float min, float max)
+{
+ float range = max - min;
+ if (range != 0) {
+ wm_progress_state.min = min;
+ wm_progress_state.max = max;
+ wm_progress_state.is_valid = true;
+ }
+ else {
+ wm_progress_state.is_valid = false;
+ }
+}
+
+static void rna_progress_update(struct wmWindowManager *wm, float value)
+{
+ if (wm_progress_state.is_valid) {
+ /* Map to cursor_time range [0,9999] */
+ int val = (int)(10000 * (value - wm_progress_state.min) / (wm_progress_state.max - wm_progress_state.min));
+ WM_cursor_time(wm->winactive, val);
+ }
+}
+
+static void rna_progress_end(struct wmWindowManager *wm)
+{
+ if (wm_progress_state.is_valid) {
+ WM_cursor_restore(wm->winactive);
+ wm_progress_state.is_valid = false;
+ }
+}
+
/* wrap these because of 'const wmEvent *' */
static int rna_Operator_confirm(bContext *C, wmOperator *op, wmEvent *event)
{
@@ -274,7 +312,20 @@
parm = RNA_def_pointer(func, "timer", "Timer", "", "");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
+ /* Progress bar interface */
+ func = RNA_def_function(srna, "progress_begin", "rna_progress_begin");
+ parm = RNA_def_property(func, "min", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ parm = RNA_def_property(func, "max", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ func = RNA_def_function(srna, "progress_update", "rna_progress_update");
+ parm = RNA_def_property(func, "value", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_ui_text(parm, "value", "any value between min and max as set in progress_init()");
+
+ func = RNA_def_function(srna, "progress_end", "rna_progress_end");
+
/* invoke functions, for use with python */
func = RNA_def_function(srna, "invoke_props_popup", "rna_Operator_props_popup");
RNA_def_function_ui_description(func, "Operator popup invoke");
More information about the Bf-blender-cvs
mailing list