diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2005-05-09 01:20:34 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2005-05-09 01:20:34 +0400 |
commit | 09fb5d6b8d1aafc66d33bded48b149105be41675 (patch) | |
tree | b609f8ab8b109fc26db4c23a5557cc0e8327f454 /source/blender/makesdna | |
parent | 8077caa96ec59aac67ff597ff3c96c23fb71b046 (diff) |
BPython:
- Made Blender.event var (previously only used by script links) hold ascii value -- where it applies -- of current event during events callback registered with Draw.Register(gui, events, button_events). Useful for gui scripts like Campbell's Python console. No problem using this var to hold the value, since in gui scripts it was not used (always None).
- Updated Window and Window.Theme with new theme vars and the Time space.
- Script links:
-- Added "Render" event for script links (runs twice, second time as "PostEvent", for clean-up actions). Now FrameChanged links don't run when a single pic is rendered.
-- Added "Enable Script Links" button in the script buttons tab. Now this bit gets saved in .blends along with the rest of G.f, so users can define per .blend if they are on or off by default. "blender -y" also disables all slinks as happened before with OnLoad ones only.
-- Other small changes in the script buttons tab:
When a link is added (button "new"), it becomes the active one for the window, no need to press a button to reach it.
Also, a pupmenu showing all available texts is shown when "new" is pressed, so users can choose a text w/o having to type. Cancel the popup to leave the string button empty (link exists, but has no script assigned). A pulldown would be better UI-wise, but it's kinda weird to show both scripts and normal texts (Blender doesn't differentiate them) in a script links pulldown. With a popup we can show only texts ending in ".py" (not done in this commit, need opinions) and if the script has no or another extension, case of many in old and current .blend's, there's still the string box for writing its name.
-- Implemented Ton's space handler script links:
Right now only for the 3d View, but it's trivial to add for others. There are two types: EVENT, to receive 3d View events from a chosen window and DRAW, to draw on the window. Ton's idea was to give scripts a controlled way to integrate better within Blender.
Here's how it works:
- scripts must have a proper header, like:
# SPACEHANDLER.VIEW3D.EVENT
and then they are shown in 3d View's View menu, "Space Handler Scripts" submenu. Check (mark, click on it) a script to make it active.
EVENT handlers should consult the Blender.event var to get the current event, which can be compared with values from the Draw module:
import Blender
from Blender import Draw
evt = Blender.event
if evt == Draw.AKEY:
print "a"
elif evt == Draw.LEFTMOUSE:
print "left mouse button"
else:
return # ignore, pass event back to Blender
Blender.event = None # tell Blender not to process itself the event
DRAW handlers are free to draw to their owner 3D View. OpenGL attributes and modelview and projection matrices are pushed before running the handler and poped when it finishes.
To communicate between EVENT and DRAW handler scripts we have the Blender.Registry module, as always.
Still need to code some nice example, which should also serve to test properly space handlers. Simple tests went fine.
- doc updates about the additions.
=======
Note: the UI part of the space handlers and script links is of course open for changes, I just tried to make it understandable. Probably we won't use the scriptlinks icon for "None Available" (check 3d View -> View -> Space Handler Scripts), though it hints at what space handlers are. The tooltips may not be accepted either, since other menus don't use them. Opinions welcomed.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_screen_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scriptlink_types.h | 16 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_text_types.h | 4 |
3 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 739bf7870ff..cd90c24b882 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -108,6 +108,8 @@ typedef struct ScrArea { short headbutlen, headbutofs; short cursor, flag; + ScriptLink scriptlink; + ListBase spacedata; ListBase uiblocks; ListBase panels; diff --git a/source/blender/makesdna/DNA_scriptlink_types.h b/source/blender/makesdna/DNA_scriptlink_types.h index 4983fa1d9dd..8a08d3f12c1 100644 --- a/source/blender/makesdna/DNA_scriptlink_types.h +++ b/source/blender/makesdna/DNA_scriptlink_types.h @@ -56,10 +56,22 @@ typedef struct ScriptLink { #define SCRIPT_ONLOAD 2 #define SCRIPT_REDRAW 4 #define SCRIPT_ONSAVE 8 +#define SCRIPT_RENDER 16 +/* POSTRENDER is not meant for the UI, it simply calls the + * RENDER script links for clean-up actions */ +#define SCRIPT_POSTRENDER 32 + +/* **************** SPACE HANDLERS ********************* */ +/* these are special scriptlinks that can be assigned to + * a given space in a given ScrArea to: + * - (EVENT type) handle events sent to that space; + * - (DRAW type) draw on the space after its own drawing function finishes + */ +#define SPACEHANDLER_VIEW3D_EVENT 1 +#define SPACEHANDLER_VIEW3D_DRAW 2 + #ifdef __cplusplus } #endif - #endif - diff --git a/source/blender/makesdna/DNA_text_types.h b/source/blender/makesdna/DNA_text_types.h index 391142db302..ea3ce237909 100644 --- a/source/blender/makesdna/DNA_text_types.h +++ b/source/blender/makesdna/DNA_text_types.h @@ -72,8 +72,8 @@ typedef struct Text { #define TXT_ISTMP 0x0002 #define TXT_ISMEM 0x0004 #define TXT_ISEXT 0x0008 -#define TXT_ISSCRIPT 0x0010 +#define TXT_ISSCRIPT 0x0010 /* used by space handler scriptlinks */ #define TXT_READONLY 0x0100 -#define TXT_FOLLOW 0x0200 // always follow cursor (console) +#define TXT_FOLLOW 0x0200 /* always follow cursor (console) */ #endif |