diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-04-22 20:25:35 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-04-22 20:25:35 +0400 |
commit | d56ceaab4c13f827042b74905635a07873422056 (patch) | |
tree | ba5de0f6ce19d1b542cf19a6f9767ca777c2fbaa /release/scripts/startup/nodeitems_builtins.py | |
parent | 8be5f035f468135771d5e8dd2d180ff8170b401e (diff) |
Nicer registration mechanism for node categories. The lists of node categories and items are now stored in a dictionary with an identifier key, so they can be registered and unregistered individually. The Add menu is now persistent and gets extended with a draw function for each of the registered node category lists.
This allows pynodes to define their own list of node categories and items and register it at runtime without interfering with the standard nodes.
Diffstat (limited to 'release/scripts/startup/nodeitems_builtins.py')
-rw-r--r-- | release/scripts/startup/nodeitems_builtins.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py index 68928bdf2fb..f5945252c11 100644 --- a/release/scripts/startup/nodeitems_builtins.py +++ b/release/scripts/startup/nodeitems_builtins.py @@ -63,7 +63,7 @@ def texture_node_group_items(self): # All standard node categories currently used in nodes. -std_node_categories = [ +shader_node_categories = [ # Shader Nodes ShaderOldNodeCategory("SH_INPUT", "Input", items=[ NodeItem("ShaderNodeMaterial"), @@ -184,7 +184,9 @@ std_node_categories = [ ShaderNewNodeCategory("SH_NEW_GROUP", "Group", items=shader_node_group_items), ShaderNewNodeCategory("SH_NEW_LAYOUT", "Layout", items=[ ]), + ] +compositor_node_categories = [ # Compositor Nodes CompositorNodeCategory("CMP_INPUT", "Input", items = [ NodeItem("CompositorNodeRLayers"), @@ -287,7 +289,9 @@ std_node_categories = [ CompositorNodeCategory("CMP_LAYOUT", "Layout", items = [ NodeItem("CompositorNodeSwitch"), ]), + ] +texture_node_categories = [ # Texture Nodes TextureNodeCategory("TEX_INPUT", "Input", items = [ NodeItem("TextureNodeCurveTime"), @@ -342,14 +346,15 @@ std_node_categories = [ def register(): - # XXX can be made a lot nicer, just get it working for now - nodeitems_utils.node_categories = std_node_categories - nodeitems_utils.register_node_ui() + nodeitems_utils.register_node_categories("SHADER", shader_node_categories) + nodeitems_utils.register_node_categories("COMPOSITING", compositor_node_categories) + nodeitems_utils.register_node_categories("TEXTURE", texture_node_categories) def unregister(): - nodeitems_utils.unregister_node_ui() - nodeitems_utils.node_categories = [] + nodeitems_utils.unregister_node_categories("SHADER") + nodeitems_utils.unregister_node_categories("COMPOSITING") + nodeitems_utils.unregister_node_categories("TEXTURE") if __name__ == "__main__": |