BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
# Blender.Window.Theme submodule and the Theme PyType object
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
The Blender.Window.Theme submodule.
|
|
|
|
|
|
|
|
|
|
Theme
|
|
|
|
|
=====
|
|
|
|
|
|
|
|
|
|
This module provides access to B{Theme} objects in Blender.
|
|
|
|
|
|
|
|
|
|
Example::
|
|
|
|
|
# this is a simplified version of the save_theme.py script
|
|
|
|
|
# shipped with Blender:
|
|
|
|
|
import Blender
|
|
|
|
|
from Blender.Window import Theme, FileSelector
|
|
|
|
|
|
|
|
|
|
theme = Theme.Get()[0] # get current theme
|
|
|
|
|
|
|
|
|
|
def write_theme(filename):
|
|
|
|
|
"Write the current theme as a bpython script"
|
|
|
|
|
|
|
|
|
|
f = file(filename, "w")
|
|
|
|
|
|
|
|
|
|
f.write("import Blender")
|
|
|
|
|
f.write("from Blender.Window import Theme")
|
|
|
|
|
f.write("theme = Theme.New('%s')" % theme.name)
|
|
|
|
|
|
|
|
|
|
for tsp in theme.get(): # write each theme space
|
|
|
|
|
command = "\\n%s = theme.get('%s')" % (tsp, tsp)
|
|
|
|
|
f.write(command + "\\n")
|
|
|
|
|
exec(command)
|
|
|
|
|
exec("vars = dir(%s)" % tsp)
|
|
|
|
|
vars.remove('theme')
|
|
|
|
|
|
|
|
|
|
for var in vars: # write each variable from each theme space
|
|
|
|
|
v = "%s.%s" % (tsp, var)
|
|
|
|
|
exec("value = %s" % v)
|
|
|
|
|
f.write("%s = %s\\n" % (v, value))
|
|
|
|
|
|
|
|
|
|
f.write('\\nBlender.Redraw(-1)') # redraw to update the screen
|
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
|
|
FileSelector(write_theme, "Save Current Theme", default_fname)
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def New (name = "New Theme", theme = '<default>'):
|
|
|
|
|
"""
|
|
|
|
|
Create a new Theme object.
|
|
|
|
|
@type name: string
|
|
|
|
|
@param name: The name of the new theme.
|
|
|
|
|
@type theme: Blender Theme
|
|
|
|
|
@param theme: a base theme to copy all data from. It defaults to the current
|
|
|
|
|
one.
|
|
|
|
|
@rtype: Blender Theme
|
|
|
|
|
@return: A new Blender Theme object.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def Get (name = None):
|
|
|
|
|
"""
|
|
|
|
|
Get the Theme object(s) from Blender.
|
|
|
|
|
@type name: string
|
|
|
|
|
@param name: The name of the Theme object.
|
|
|
|
|
@rtype: Blender Theme or a list of Blender Themes
|
|
|
|
|
@return: It depends on the I{name} parameter:
|
|
|
|
|
- (name): The Theme object called I{name}, None if not found;
|
|
|
|
|
- (): A list with all Theme objects currently in Blender.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Theme:
|
|
|
|
|
"""
|
|
|
|
|
The Theme object
|
|
|
|
|
================
|
|
|
|
|
This object gives access to Themes in Blender. Each Theme object is
|
|
|
|
|
composed of one UI (Use Interface) theme and many Space themes
|
|
|
|
|
(3d view, Text Editor, Buttons window, etc).
|
|
|
|
|
@cvar name: The name of this Theme object.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def getName():
|
|
|
|
|
"""
|
|
|
|
|
Get the name of this Theme object.
|
|
|
|
|
@rtype: string
|
|
|
|
|
@return: the name of this Theme object.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def setName(s):
|
|
|
|
|
"""
|
|
|
|
|
Rename this theme.
|
|
|
|
|
@type s: string
|
|
|
|
|
@param s: the new name.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def get(t = None):
|
|
|
|
|
"""
|
|
|
|
|
Get a space or the ui (sub)theme from this Theme.
|
|
|
|
|
@type t: string, int or None
|
|
|
|
|
@param t: the wanted sub-theme as either:
|
|
|
|
|
- int: -1 for UI or the types in L{Window.Types} for the others;
|
|
|
|
|
- string: use get() to know them (they are case insensitive);
|
|
|
|
|
- nothing: as written above, get() returns a list of names.
|
|
|
|
|
@rtype: Blender ThemeSpace or ThemeUI or list of sub-theme types as strings.
|
|
|
|
|
@return: It depends on the given parameter:
|
|
|
|
|
- (): a list with all available types, as strings;
|
|
|
|
|
- (type): the chosen sub-theme.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
class ThemeUI:
|
|
|
|
|
"""
|
|
|
|
|
The User Interface sub-theme
|
|
|
|
|
============================
|
|
|
|
|
This can be accessed with theme.get(t), where t can be 'ui' or -1.
|
|
|
|
|
The available variables follow the internal (C coded) ThemeUI struct in
|
|
|
|
|
Blender. Most of them represent rgba (red, green, blue, alpha) colors,
|
|
|
|
|
with each component in the range [0, 255]. There is more than one way to
|
|
|
|
|
access them.
|
|
|
|
|
|
|
|
|
|
Examples::
|
|
|
|
|
print outline.R
|
|
|
|
|
outline.r = 180 # it's case insensitive
|
|
|
|
|
outline[0] = 94 # 0 for red, 1 for green, ...
|
|
|
|
|
outline = [200, 200, 200, 255] # setting all components at once
|
|
|
|
|
@type theme: string
|
|
|
|
|
@cvar theme: the parent Theme for this object.
|
|
|
|
|
@cvar outline: theme rgba var.
|
|
|
|
|
@cvar neutral: theme rgba var.
|
|
|
|
|
@cvar action: theme rgba var.
|
|
|
|
|
@cvar setting: theme rgba var.
|
|
|
|
|
@cvar setting1: theme rgba var.
|
|
|
|
|
@cvar setting2: theme rgba var.
|
|
|
|
|
@cvar num: theme rgba var.
|
|
|
|
|
@cvar textfield: theme rgba var.
|
|
|
|
|
@cvar popup: theme rgba var.
|
|
|
|
|
@cvar text: theme rgba var.
|
|
|
|
|
@cvar text_hi: theme rgba var.
|
|
|
|
|
@cvar menu_back: theme rgba var.
|
|
|
|
|
@cvar menu_item: theme rgba var.
|
|
|
|
|
@cvar menu_hilite: theme rgba var.
|
|
|
|
|
@cvar menu_text: theme rgba var.
|
|
|
|
|
@cvar menu_text_hi: theme rgba var.
|
|
|
|
|
@type drawType: int
|
|
|
|
|
@cvar drawType: the draw type (minimal, rounded, etc) in the range [1, 4].
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
class ThemeSpace:
|
|
|
|
|
"""
|
|
|
|
|
The Space sub-themes
|
|
|
|
|
====================
|
|
|
|
|
There is a sub-theme for each space in Blender (except for the Scripts
|
|
|
|
|
window, but it will be added soon). Please read the information about
|
|
|
|
|
L{Theme.ThemeUI}, since it is also relevant here. In Blender,
|
|
|
|
|
all theme spaces share the same C structure. For this reason, all of
|
|
|
|
|
them here share the same variables, event though some spaces only use
|
|
|
|
|
a few of them. This lower-level access is acceptable because generally
|
|
|
|
|
users will prefer to use the interface to change single theme options
|
|
|
|
|
and only use scripting to save or restore themes. But anyway, checking
|
|
|
|
|
the Themes tab in the User Preferences space in Blender and using the
|
|
|
|
|
bundled "Save current theme" script (or its simplified version written
|
|
|
|
|
on the top of this page) can help you finding out any specific info you
|
|
|
|
|
may need.
|
|
|
|
|
@type theme: string
|
|
|
|
|
@cvar theme: the parent Theme for this object.
|
|
|
|
|
@cvar back: theme rgba var.
|
|
|
|
|
@cvar text: theme rgba var.
|
|
|
|
|
@cvar text_hi: theme rgba var.
|
|
|
|
|
@cvar header: theme rgba var.
|
|
|
|
|
@cvar panel: theme rgba var.
|
|
|
|
|
@cvar shade1: theme rgba var.
|
|
|
|
|
@cvar shade2: theme rgba var.
|
|
|
|
|
@cvar hilite: theme rgba var.
|
|
|
|
|
@cvar grid: theme rgba var.
|
|
|
|
|
@cvar wire: theme rgba var.
|
|
|
|
|
@cvar select: theme rgba var.
|
|
|
|
|
@cvar active: theme rgba var.
|
|
|
|
|
@cvar transform: theme rgba var.
|
|
|
|
|
@cvar vertex: theme rgba var.
|
|
|
|
|
@cvar vertex_select: theme rgba var.
|
|
|
|
|
@cvar edge: theme rgba var.
|
|
|
|
|
@cvar edge_select: theme rgba var.
|
|
|
|
|
@cvar edge_seam: theme rgba var.
|
|
|
|
|
@cvar edge_facesel: theme rgba var.
|
|
|
|
|
@cvar face: theme rgba var.
|
|
|
|
|
@cvar face_select: theme rgba var.
|
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.
2005-05-08 21:20:34 +00:00
|
|
|
@cvar face_dot: theme rgba var.
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
@cvar normal: theme rgba var.
|
|
|
|
|
@type vertex_size: int
|
|
|
|
|
@cvar vertex_size: size of the vertices dots on screen in the range [1, 10].
|
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.
2005-05-08 21:20:34 +00:00
|
|
|
@type facedot_size: int
|
|
|
|
|
@cvar facedot_size: size of the face dots on screen in the range [1, 10].
|
BPython:
- Blender.Window: added function GetPerspMatrix() (Tom Musgrave's patch, thanks);
- added Chris Want's patch to tell argc, argv to the Python interpreter (thanks, Hos);
- Blender.Image: added image.glFree() to free textures bound by the recently added
image.glLoad() (both suggested by Campbell Barton -- thanks, with these Blender can
be used to load textures for scripts);
- Blender.Sound: removed for now at least a few get/set methods of vars that can't be
accessed via interface;
- renamed Get/makeActive to Get/setCurrent in Blender.World (actually added alias for
now), same in Blender.Sound: renamed makeActive to setCurrent. Stephen Swaney
pointed this some weeks ago, we should stick to one naming convention.
- added documentation for Sound and Window.Theme modules and the other added
functions, made other small updates.
- Blender.Object: made 'worldspace' become the default output of .getMatrix and .mat/.matrix:
after reading a discussion on blender.org's Python forum where eeshlo mentioned the
pre 2.34 default was worldspace, I took a better look at Blender's relevant code,
confirmed, talked to Theeth about this and as he suggested am changing the default
back to 'worldspace'.
2004-10-20 05:51:24 +00:00
|
|
|
"""
|
|
|
|
|
|