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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-02-11 15:01:14 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-02-11 15:01:14 +0300
commitf33faa8f5f1c37bad5e906f29429ab3278183505 (patch)
tree63f7d0aebcd343317fd073242159108ef3a59dbb /source
parentc5c53b0f2df4d9eeae6564fa3e2e500bef2d8d15 (diff)
python scriptlink for ObjectUpdate and ObDataUpdate, Redraw events are not practice in many real world cases, this can give more specific updates.
Discussed with Caedes, Brecht and Ton, can rework if needed.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/object.c2
-rw-r--r--source/blender/makesdna/DNA_scriptlink_types.h3
-rw-r--r--source/blender/python/api2_2x/gen_utils.c14
-rw-r--r--source/blender/src/buttons_script.c11
4 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 8dfb64d8b63..4505af65a0a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2163,6 +2163,7 @@ void object_handle_update(Object *ob)
}
else
where_is_object(ob);
+ if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBJECTUPDATE);
}
if(ob->recalc & OB_RECALC_DATA) {
@@ -2228,6 +2229,7 @@ void object_handle_update(Object *ob)
psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
}
}
+ if (G.f & G_DOSCRIPTLINKS) BPY_do_pyscript((ID *)ob, SCRIPT_OBDATAUPDATE);
}
/* the no-group proxy case, we call update */
diff --git a/source/blender/makesdna/DNA_scriptlink_types.h b/source/blender/makesdna/DNA_scriptlink_types.h
index 8a08d3f12c1..a21c67fc5e8 100644
--- a/source/blender/makesdna/DNA_scriptlink_types.h
+++ b/source/blender/makesdna/DNA_scriptlink_types.h
@@ -61,6 +61,9 @@ typedef struct ScriptLink {
* RENDER script links for clean-up actions */
#define SCRIPT_POSTRENDER 32
+#define SCRIPT_OBJECTUPDATE 64
+#define SCRIPT_OBDATAUPDATE 128
+
/* **************** SPACE HANDLERS ********************* */
/* these are special scriptlinks that can be assigned to
* a given space in a given ScrArea to:
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index f05be1ba68b..780712dac7b 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -1,5 +1,5 @@
/*
- * $Id: gen_utils.c 11932 2007-09-03 17:28:50Z stiv $
+ * $Id$
*
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
*
@@ -238,6 +238,10 @@ char *event_to_name( short event )
switch ( event ) {
case SCRIPT_FRAMECHANGED:
return "FrameChanged";
+ case SCRIPT_OBJECTUPDATE:
+ return "ObjectUpdate";
+ case SCRIPT_OBDATAUPDATE:
+ return "ObDataUpdate";
case SCRIPT_ONLOAD:
return "OnLoad";
case SCRIPT_ONSAVE:
@@ -406,6 +410,10 @@ PyObject *EXPP_getScriptLinks( ScriptLink * slink, PyObject * value,
if( !strcmp( eventname, "FrameChanged" ) )
event = SCRIPT_FRAMECHANGED;
+ else if( !strcmp( eventname, "ObjectUpdate" ) )
+ event = SCRIPT_OBJECTUPDATE;
+ else if( !strcmp( eventname, "ObDataUpdate" ) )
+ event = SCRIPT_OBDATAUPDATE;
else if( !strcmp( eventname, "Redraw" ) )
event = SCRIPT_REDRAW;
else if( !strcmp( eventname, "Render" ) )
@@ -562,6 +570,10 @@ PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene)
if( !strcmp( eventname, "FrameChanged" ) )
event = SCRIPT_FRAMECHANGED;
+ else if( !strcmp( eventname, "ObjectUpdate" ) )
+ event = SCRIPT_OBJECTUPDATE;
+ else if( !strcmp( eventname, "ObDataUpdate" ) )
+ event = SCRIPT_OBDATAUPDATE;
else if( !strcmp( eventname, "Redraw" ) )
event = SCRIPT_REDRAW;
else if( !strcmp( eventname, "Render" ) )
diff --git a/source/blender/src/buttons_script.c b/source/blender/src/buttons_script.c
index 52e7be7c93e..c6d3522a8d7 100644
--- a/source/blender/src/buttons_script.c
+++ b/source/blender/src/buttons_script.c
@@ -268,7 +268,7 @@ void do_scriptbuts(unsigned short event)
allqueue(REDRAWOOPS, 0);
}
-void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int scene)
+void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int idcode)
{
char str[256];
@@ -276,10 +276,13 @@ void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int sce
strcpy(str, "FrameChanged%x 1|");
strcat(str, "Redraw%x 4|");
strcat(str, "Render%x 16|");
- if (scene) {
+ if (idcode==ID_SCE) {
strcat(str, "OnLoad%x 2|");
strcat(str, "OnSave%x 8");
- }
+ } else {
+ strcat(str, "ObjectUpdate%x 64|");
+ strcat(str, "ObDataUpdate%x 128");
+ }
uiBlockBeginAlign(block);
uiDefButS(block, MENU, 1, str, (short)sx, (short)sy, 140, 19, &script->flag[script->actscript-1], 0, 0, 0, 0, "Script links for this event");
@@ -291,7 +294,7 @@ void draw_scriptlink(uiBlock *block, ScriptLink *script, int sx, int sy, int sce
uiDefButS(block, NUM, REDRAWBUTSSCRIPT, str, (short)(sx+140), (short)sy-20,60,19, &script->actscript, 1, script->totscript, 0, 0, "Total / Active Script link (LeftMouse + Drag to change)");
- if (scene) {
+ if (idcode==ID_SCE) {
if (script->totscript<32767)
uiDefBut(block, BUT, B_SSCRIPT_ADD, "New", (short)(sx+240), (short)sy-20, 40, 19, 0, 0, 0, 0, 0, "Add a new Script link");