blender/release/scripts/startup/bl_operators
Lukas Toenne 94931f9f45 Replacing the node Add menu and making the toolbar useful
As some people have already noticed, the "Add" menu for nodes is a bit messy since pynodes merge. The reason for this is that the order of nodes in submenus (categories) was previously defined by the order in which all nodes are registered (at the bottom of blenkernel/intern/node.c). For the dynamic registration of node types now possible this system of defining node order along with registration is no longer viable: while it would still sort of work for C nodes, it is completely meaningless for dynamic (python) nodes, which are basically registered automatically in whatever order modules and addons are loaded, with the added complexity of unloading and reloading.

To fix this problem and add a bunch of desirable features this commit replaces the C menu with a python implementation. The new menu does not rely on any particular order of types in the node registry, but instead uses a simple explicit list of all the available nodes, grouped by categories (in scripts/nodeitems_builtins.py).

There are a number of additional features that become possible with this implementation:

1) Node Toolbar can be populated!
The list of nodes is used to create 2 UI items for each node: 1 entry in a submenu of "Add" menu and 1 item in a node toolbar panel with basically the same functionality. Clicking a button in the toolbar will add a new node of this type, just like selecting an item in the menu. The toolbar has the advantage of having collapsible panels for each category, so users can decide if they don't need certain nodes categories and have the rest more easily accessible.

2) Each node item is a true operator call.
The old Add menu is a pretty old piece of C code which doesn't even use proper operator buttons. Now there is a generic node_add operator which can be used very flexibly for adding any of the available nodes.

3) Node Items support additional settings.
Each "NodeItem" consists of the basic node type plus an optional list of initial settings that shall be applied to a new instance. This gives additional flexibility for creating variants of the same node or for defining preferred initial settings. E.g. it has been requested to disable previews for all nodes except inputs, this would be simple change in the py code and much less intrusive than in C.

4) Node items can be generated with a function.
A callback can be used in any category instead of the fixed list, which generates a set of items based on the context (much like dynamic enum items in bpy.props). Originally this was implemented for group nodes, because these nodes only make sense when linked to a node tree from the library data. This principle could come in handy for a number of other nodes, e.g. Image nodes could provide a similar list of node variants based on images in the library - no need to first add node, then select an image.

WARNING: pynodes scripters will have to rework their "draw_add_menu" callback in node tree types, this has been removed now! It was already pretty redundant, since one can add draw functions to the Add menu just like for any other menu. In the future i'd like to improve the categories system further so scripters can use it for custom node systems too, for now just make a draw callback and attach it to the Add menu.
2013-04-13 15:38:02 +00:00
..
__init__.py Merged changes in the trunk up to revision 54110. 2013-01-26 23:49:13 +00:00
add_mesh_torus.py I18n: various fixing. 2013-03-28 15:41:43 +00:00
anim.py fix [#34805] Bake action ignores parent motion 2013-04-11 08:42:25 +00:00
clip.py Hide preview for nodes created with Setup Tracking Scene 2013-04-11 13:34:51 +00:00
console.py style cleanup: pep8 2012-10-08 08:28:05 +00:00
freestyle.py Usual typo fixes... ;) 2013-04-07 10:21:22 +00:00
image.py Fix for [#34898] Typo in error message of mathutils.Vector 2013-04-07 15:09:06 +00:00
mesh.py style cleanup: pep8 2012-10-08 08:28:05 +00:00
node.py Replacing the node Add menu and making the toolbar useful 2013-04-13 15:38:02 +00:00
object_align.py use more conventional names in rigid body script. 2013-01-28 12:15:50 +00:00
object_quick_effects.py code cleanup: dont use 'bpy.context' when 'context' is available 2013-01-23 07:52:31 +00:00
object_randomize_transform.py code cleanup: dont use 'bpy.context' when 'context' is available 2013-01-23 07:52:31 +00:00
object.py select-camera operator could select hidden cameras, also disable freestyle for make lite target. 2013-04-08 04:54:57 +00:00
presets.py Fix for [#34901] "Add SSS Preset" gives error. 2013-04-07 15:18:12 +00:00
rigidbody.py code cleanup: python/pep8 and double-promotion warnings. 2013-03-28 19:33:14 +00:00
screen_play_rendered_anim.py fix for 'Playanim' playing past the last frame of an animation. also print -s and -e in help message. 2012-11-17 01:15:28 +00:00
sequencer.py Style edit (mostly), use """ for docstrings (not '''). 2012-07-03 09:02:41 +00:00
uvcalc_follow_active.py style cleanup 2013-01-15 23:15:32 +00:00
uvcalc_lightmap.py code cleanup: dont use 'bpy.context' when 'context' is available 2013-01-23 07:52:31 +00:00
uvcalc_smart_project.py Fix for [#34898] Typo in error message of mathutils.Vector 2013-04-07 15:09:06 +00:00
vertexpaint_dirt.py fix [#33715] Dirty Vertex Colors display problem since 2.65a 2013-01-03 07:01:41 +00:00
view3d.py don't constrain single edge extrude, annoying for retopo 2012-04-14 05:09:23 +00:00
wm.py * Better tooltip for WM_OT_properties_context_change. 2013-04-10 20:36:22 +00:00