Workspace: Move engines to workspace and Properties Editor cleanup
[blender.git] / source / blender / editors / space_node / node_templates.c
index 9d1cf65b8acd7b51308f940bec55f338122efd1b..c791b9f6eae40d2c69b61b09849bc4db8b35c2de 100644 (file)
@@ -423,11 +423,25 @@ static int ui_compatible_sockets(int typeA, int typeB)
 
 static int ui_node_item_name_compare(const void *a, const void *b)
 {
-       const bNodeType* type_a = *(const bNodeType**)a;
-       const bNodeType* type_b = *(const bNodeType**)b;
+       const bNodeType *type_a = *(const bNodeType **)a;
+       const bNodeType *type_b = *(const bNodeType **)b;
        return BLI_natstrcmp(type_a->ui_name, type_b->ui_name);
 }
 
+static bool ui_node_item_special_poll(const bNodeTree *UNUSED(ntree),
+                                      const bNodeType *ntype)
+{
+       if (STREQ(ntype->idname, "ShaderNodeUVAlongStroke")) {
+               /* TODO(sergey): Currently we don't have Freestyle nodes edited from
+                * the buttons context, so can ignore it's nodes completely.
+                *
+                * However, we might want to do some extra checks here later.
+                */
+               return false;
+       }
+       return true;
+}
+
 static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
 {
        bNodeTree *ntree = arg->ntree;
@@ -452,17 +466,23 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
        BLI_array_declare(sorted_ntypes);
 
        NODE_TYPES_BEGIN(ntype) {
-               if (compatibility && !(ntype->compatibility & compatibility))
+               if (compatibility && !(ntype->compatibility & compatibility)) {
+                       continue;
+               }
+
+               if (ntype->nclass != nclass) {
                        continue;
+               }
 
-               if (ntype->nclass != nclass)
+               if (!ui_node_item_special_poll(ntree, ntype)) {
                        continue;
+               }
 
                BLI_array_append(sorted_ntypes, ntype);
        }
        NODE_TYPES_END
 
-       qsort(sorted_ntypes, BLI_array_count(sorted_ntypes), sizeof(bNodeType*), ui_node_item_name_compare);
+       qsort(sorted_ntypes, BLI_array_count(sorted_ntypes), sizeof(bNodeType *), ui_node_item_name_compare);
 
        /* generate UI */
        for (int j = 0; j < BLI_array_count(sorted_ntypes); j++) {
@@ -539,6 +559,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
 {
        Main *bmain = CTX_data_main(C);
        Scene *scene = CTX_data_scene(C);
+       ViewRender *view_render = CTX_data_view_render(C);
        uiBlock *block = uiLayoutGetBlock(layout);
        uiBut *but = (uiBut *)but_p;
        uiLayout *split, *column;
@@ -555,7 +576,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
        arg->layout = split;
 
        if (ntreetype && ntreetype->foreach_nodeclass)
-               ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);
+               ntreetype->foreach_nodeclass(view_render, arg, node_menu_column_foreach_cb);
 
        column = uiLayoutColumn(split, false);
        UI_block_layout_set_current(block, column);
@@ -663,10 +684,11 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
        RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
 
        /* indented label */
-       for (i = 0; i < indent; i++)
+       for (i = 0; i < indent; i++) {
                label[i] = ' ';
+       }
        label[indent] = '\0';
-       BLI_snprintf(label, UI_MAX_NAME_STR, "%s%s:", label, IFACE_(input->name));
+       BLI_snprintf(label + indent, UI_MAX_NAME_STR - indent, "%s:", IFACE_(input->name));
 
        /* split in label and value */
        split = uiLayoutSplit(layout, 0.35f, false);