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:
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/intern/rna_wm.c31
-rw-r--r--source/blender/makesrna/intern/rna_wm_api.c27
3 files changed, 59 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index e67728def11..2816a8717c1 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -532,6 +532,7 @@ extern StructRNA RNA_ThemeView3D;
extern StructRNA RNA_ThemeWidgetColors;
extern StructRNA RNA_ThemeWidgetStateColors;
extern StructRNA RNA_TimelineMarker;
+extern StructRNA RNA_Timer;
extern StructRNA RNA_ToolSettings;
extern StructRNA RNA_TouchSensor;
extern StructRNA RNA_TrackToConstraint;
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index ea26663df44..df029c9d871 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -1418,6 +1418,36 @@ static void rna_def_event(BlenderRNA *brna)
RNA_define_verify_sdna(1); // not in sdna
}
+static void rna_def_timer(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "Timer", NULL);
+ RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
+ RNA_def_struct_sdna(srna, "wmTimer");
+
+ RNA_define_verify_sdna(0); // not in sdna
+
+ /* could wrap more, for now this is enough */
+ prop= RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "timestep");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Time Step", "");
+
+ prop= RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "delta");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
+
+ prop= RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "duration");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
+
+ RNA_define_verify_sdna(1); // not in sdna
+}
+
static void rna_def_window(BlenderRNA *brna)
{
StructRNA *srna;
@@ -1801,6 +1831,7 @@ void RNA_def_wm(BlenderRNA *brna)
rna_def_macro_operator(brna);
rna_def_operator_type_macro(brna);
rna_def_event(brna);
+ rna_def_timer(brna);
rna_def_window(brna);
rna_def_windowmanager(brna);
rna_def_keyconfig(brna);
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.");