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:
authorCampbell Barton <ideasman42@gmail.com>2011-03-28 08:55:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-03-28 08:55:24 +0400
commit412eed6a2753bfdeaf158dd2f82e4ba070f2c254 (patch)
treecf73499fe542a86547af85b311c88d0fecd6638c /source/blender/makesrna/intern/rna_wm_api.c
parentdd56ebe6076d7ffbe9dd698a5c1bc94fff6ff306 (diff)
RNA functions for adding timer (needed for demo mode, also useful for python modal operators).
- timer = WindowManager.event_timer_add(time_step, window=None) - WindowManager.event_timer_remove(timer) Still TODO, is a way for python to check the timer identity.
Diffstat (limited to 'source/blender/makesrna/intern/rna_wm_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index 4891d8b1078..ab2775b7184 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -73,6 +73,17 @@ static int rna_event_modal_handler_add(struct bContext *C, struct wmOperator *op
return WM_event_add_modal_handler(C, operator) != NULL;
}
+/* XXX, need a way for python to know event types, 0x0110 is hard coded */
+struct wmTimer *rna_event_timer_add(struct wmWindowManager *wm, float time_step, wmWindow *win)
+{
+ return WM_event_add_timer(wm, win, 0x0110, time_step);
+}
+
+void rna_event_timer_remove(struct wmWindowManager *wm, wmTimer *timer)
+{
+ return WM_event_remove_timer(wm, timer->win, timer);
+}
+
#else
#define WM_GEN_INVOKE_EVENT (1<<0)
@@ -118,6 +129,22 @@ void RNA_api_wm(StructRNA *srna)
RNA_def_property_flag(parm, PROP_REQUIRED);
RNA_def_function_return(func, RNA_def_boolean(func, "handle", 1, "", ""));
+
+ func= RNA_def_function(srna, "event_timer_add", "rna_event_timer_add");
+ parm= RNA_def_property(func, "time_step", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_property_range(parm, 0.0, FLT_MAX);
+ RNA_def_property_ui_text(parm, "Time Step", "Interval in seconds between timer events");
+ parm= RNA_def_pointer(func, "window", "Window", "", "Window to attach the timer to or None.");
+ parm= RNA_def_pointer(func, "result", "Timer", "", "");
+ RNA_def_function_return(func, parm);
+
+
+ func= RNA_def_function(srna, "event_timer_remove", "rna_event_timer_remove");
+ parm= RNA_def_pointer(func, "timer", "Timer", "", "");
+ RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
+
+
/* invoke functions, for use with python */
func= RNA_def_function(srna, "invoke_props_popup", "WM_operator_props_popup");
RNA_def_function_ui_description(func, "Operator popup invoke.");