Cycles: svn merge -r41157:41182 ^/trunk/blender
[blender.git] / source / blender / editors / space_node / node_header.c
index b64685e39845990af0b7e879b3257b1aa6738a44..f10730f7dcd008b209b357bfa885eddb36de2f3c 100644 (file)
 
 #include "BKE_context.h"
 #include "BKE_global.h"
-#include "BKE_screen.h"
-#include "BKE_node.h"
 #include "BKE_main.h"
+#include "BKE_node.h"
+#include "BKE_scene.h"
+#include "BKE_screen.h"
 
 #include "RNA_access.h"
 
@@ -170,10 +171,11 @@ static int node_tree_has_type(int treetype, int nodetype)
 static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
 {
        Main *bmain= CTX_data_main(C);
+       Scene *scene= CTX_data_scene(C);
        SpaceNode *snode= CTX_wm_space_node(C);
        bNodeTree *ntree;
        int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass);
-       int event;
+       int event, compatibility= 0;
        
        ntree = snode->nodetree;
        
@@ -181,6 +183,13 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
                uiItemS(layout);
                return;
        }
+
+       if(ntree->type == NTREE_SHADER) {
+               if(scene_use_new_shading_nodes(scene))
+                       compatibility= NODE_NEW_SHADING;
+               else
+                       compatibility= NODE_OLD_SHADING;
+       }
        
        if (nodeclass==NODE_CLASS_GROUP) {
                bNodeTree *ngroup;
@@ -212,14 +221,16 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass)
                uiLayoutSetFunc(layout, do_node_add_static, NULL);
                
                for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) {
-                       if(ntype->nclass==nodeclass && ntype->name)
-                               uiItemV(layout, ntype->name, 0, ntype->type);
+                       if (ntype->nclass==nodeclass && ntype->name)
+                               if (!compatibility || (ntype->compatibility & compatibility))
+                                       uiItemV(layout, ntype->name, 0, ntype->type);
                }
        }
 }
 
 static void node_menu_add(const bContext *C, Menu *menu)
 {
+       Scene *scene= CTX_data_scene(C);
        SpaceNode *snode= CTX_wm_space_node(C);
        uiLayout *layout= menu->layout;
 
@@ -229,11 +240,15 @@ static void node_menu_add(const bContext *C, Menu *menu)
        if(snode->treetype==NTREE_SHADER) {
                uiItemMenuF(layout, IFACE_("Input"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_INPUT));
                uiItemMenuF(layout, IFACE_("Output"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OUTPUT));
+               if(scene_use_new_shading_nodes(scene)) {
+                       uiItemMenuF(layout, IFACE_("Shader"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_SHADER));
+                       uiItemMenuF(layout, IFACE_("Texture"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_TEXTURE));
+               }
                uiItemMenuF(layout, IFACE_("Color"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_COLOR));
                uiItemMenuF(layout, IFACE_("Vector"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_VECTOR));
                uiItemMenuF(layout, IFACE_("Convertor"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_CONVERTOR));
                uiItemMenuF(layout, IFACE_("Group"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_GROUP));
-               uiItemMenuF(layout, IFACE_("Dynamic"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC));
+               //uiItemMenuF(layout, IFACE_("Dynamic"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_OP_DYNAMIC));
                uiItemMenuF(layout, IFACE_("Layout"), 0, node_add_menu, SET_INT_IN_POINTER(NODE_CLASS_LAYOUT));
        }
        else if(snode->treetype==NTREE_COMPOSIT) {