Reverted r43219 "Improved auto-hiding of unused sockets for collapsed nodes."
authorLukas Toenne <lukas.toenne@googlemail.com>
Mon, 16 Apr 2012 10:50:57 +0000 (10:50 +0000)
committerLukas Toenne <lukas.toenne@googlemail.com>
Mon, 16 Apr 2012 10:50:57 +0000 (10:50 +0000)
This feature did have a number of flaws and caused some controversy, so removal is the better option. Hiding nodes without prior connections would just hide all the sockets, leaving an unusable node. Better way is to use the ctrl+h shortcut to explicitly hide unused sockets when necessary.

source/blender/blenkernel/intern/node.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/makesdna/DNA_node_types.h

index cbdbf03..b50969d 100644 (file)
@@ -1367,7 +1367,7 @@ void nodeSetActive(bNodeTree *ntree, bNode *node)
 
 int nodeSocketIsHidden(bNodeSocket *sock)
 {
-       return ((sock->flag & (SOCK_HIDDEN | SOCK_AUTO_HIDDEN | SOCK_UNAVAIL)) != 0);
+       return ((sock->flag & (SOCK_HIDDEN | SOCK_UNAVAIL)) != 0);
 }
 
 void nodeSocketSetType(bNodeSocket *sock, int type)
index 6a40e1e..4242b89 100644 (file)
@@ -7672,32 +7672,6 @@ static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
        }
 }
 
-/* set the SOCK_AUTO_HIDDEN flag on collapsed nodes */
-static void do_versions_nodetree_socket_auto_hidden_flags_2_62(bNodeTree *ntree)
-{
-       bNode *node;
-       bNodeSocket *sock;
-       
-       for (node=ntree->nodes.first; node; node=node->next) {
-               if (node->flag & NODE_HIDDEN) {
-                       for (sock=node->inputs.first; sock; sock=sock->next) {
-                               if (sock->link==NULL)
-                                       sock->flag |= SOCK_AUTO_HIDDEN;
-                       }
-                       for (sock=node->outputs.first; sock; sock= sock->next) {
-                               if (nodeCountSocketLinks(ntree, sock)==0)
-                                       sock->flag |= SOCK_AUTO_HIDDEN;
-                       }
-               }
-               else {
-                       for (sock=node->inputs.first; sock; sock= sock->next)
-                               sock->flag &= ~SOCK_AUTO_HIDDEN;
-                       for (sock=node->outputs.first; sock; sock= sock->next)
-                               sock->flag &= ~SOCK_AUTO_HIDDEN;
-               }
-       }
-}
-
 static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNodeTree *ntree)
 {
        bNode *node;
@@ -13120,38 +13094,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                }
                        }
                }
-               {
-                       /* set the SOCK_AUTO_HIDDEN flag on collapsed nodes */
-                       Scene *sce;
-                       Material *mat;
-                       Tex *tex;
-                       Lamp *lamp;
-                       World *world;
-                       bNodeTree *ntree;
-
-                       for (sce=main->scene.first; sce; sce=sce->id.next)
-                               if (sce->nodetree)
-                                       do_versions_nodetree_socket_auto_hidden_flags_2_62(sce->nodetree);
-
-                       for (mat=main->mat.first; mat; mat=mat->id.next)
-                               if (mat->nodetree)
-                                       do_versions_nodetree_socket_auto_hidden_flags_2_62(mat->nodetree);
-
-                       for (tex=main->tex.first; tex; tex=tex->id.next)
-                               if (tex->nodetree)
-                                       do_versions_nodetree_socket_auto_hidden_flags_2_62(tex->nodetree);
-
-                       for (lamp=main->lamp.first; lamp; lamp=lamp->id.next)
-                               if (lamp->nodetree)
-                                       do_versions_nodetree_socket_auto_hidden_flags_2_62(lamp->nodetree);
-
-                       for (world=main->world.first; world; world=world->id.next)
-                               if (world->nodetree)
-                                       do_versions_nodetree_socket_auto_hidden_flags_2_62(world->nodetree);
-
-                       for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
-                               do_versions_nodetree_socket_auto_hidden_flags_2_62(ntree);
-               }
        }
 
        if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 2))
index f73a897..c41cb2b 100644 (file)
@@ -1605,38 +1605,38 @@ void NODE_OT_resize(wmOperatorType *ot)
 
 /* ********************** hidden sockets ******************** */
 
-int node_has_hidden_sockets(bNode *node, short flag)
+int node_has_hidden_sockets(bNode *node)
 {
        bNodeSocket *sock;
        
        for (sock= node->inputs.first; sock; sock= sock->next)
-               if (sock->flag & flag)
+               if (sock->flag & SOCK_HIDDEN)
                        return 1;
        for (sock= node->outputs.first; sock; sock= sock->next)
-               if (sock->flag & flag)
+               if (sock->flag & SOCK_HIDDEN)
                        return 1;
        return 0;
 }
 
-void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set)
+void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
 {      
        bNodeSocket *sock;
 
        if (set==0) {
                for (sock= node->inputs.first; sock; sock= sock->next)
-                       sock->flag &= ~flag;
+                       sock->flag &= ~SOCK_HIDDEN;
                for (sock= node->outputs.first; sock; sock= sock->next)
-                       sock->flag &= ~flag;
+                       sock->flag &= ~SOCK_HIDDEN;
        }
        else {
                /* hide unused sockets */
                for (sock= node->inputs.first; sock; sock= sock->next) {
                        if (sock->link==NULL)
-                               sock->flag |= flag;
+                               sock->flag |= SOCK_HIDDEN;
                }
                for (sock= node->outputs.first; sock; sock= sock->next) {
                        if (nodeCountSocketLinks(snode->edittree, sock)==0)
-                               sock->flag |= flag;
+                               sock->flag |= SOCK_HIDDEN;
                }
        }
 }
@@ -2281,7 +2281,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL
                                }
                                if (sock) {
                                        tlink->tosock= sock;
-                                       sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN);
+                                       sock->flag &= ~SOCK_HIDDEN;
                                }
                                else {
                                        nodeRemLink(snode->edittree, tlink);
@@ -2765,7 +2765,7 @@ static bNodeSocket *socket_best_match(ListBase *sockets)
        for (type=maxtype; type >= 0; --type) {
                for (sock= sockets->first; sock; sock= sock->next) {
                        if (type==sock->type) {
-                               sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN);
+                               sock->flag &= ~SOCK_HIDDEN;
                                return sock;
                        }
                }
@@ -3109,20 +3109,10 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag)
                        if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0)
                                continue;
                        
-                       if ( (tot_eq && tot_neq) || tot_eq==0) {
+                       if ( (tot_eq && tot_neq) || tot_eq==0)
                                node->flag |= toggle_flag;
-                               
-                               /* hide/unhide node also toggles unlinked socket display */
-                               if (toggle_flag== NODE_HIDDEN)
-                                       node_set_hidden_sockets(snode, node, SOCK_AUTO_HIDDEN, 1);
-                       }
-                       else {
+                       else
                                node->flag &= ~toggle_flag;
-                               
-                               /* hide/unhide node also toggles unlinked socket display */
-                               if (toggle_flag== NODE_HIDDEN)
-                                       node_set_hidden_sockets(snode, node, SOCK_AUTO_HIDDEN, 0);
-                       }
                }
        }
 }
@@ -3235,7 +3225,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        hidden = 0;
        for (node= snode->edittree->nodes.first; node; node= node->next) {
                if (node->flag & SELECT) {
-                       if (node_has_hidden_sockets(node, SOCK_HIDDEN)) {
+                       if (node_has_hidden_sockets(node)) {
                                hidden= 1;
                                break;
                        }
@@ -3244,7 +3234,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op))
        
        for (node= snode->edittree->nodes.first; node; node= node->next) {
                if (node->flag & SELECT) {
-                       node_set_hidden_sockets(snode, node, SOCK_HIDDEN, !hidden);
+                       node_set_hidden_sockets(snode, node, !hidden);
                }
        }
 
index ea8fdd8..aa80f72 100644 (file)
@@ -121,8 +121,8 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
 void snode_composite_job(const struct bContext *C, ScrArea *sa);
 bNode *node_tree_get_editgroup(bNodeTree *ntree);
 void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace);
-int node_has_hidden_sockets(bNode *node, short flag);
-void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set);
+int node_has_hidden_sockets(bNode *node);
+void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set);
 int node_render_changed_exec(bContext *, wmOperator *);
 int node_find_indicated_socket(struct SpaceNode *snode, struct bNode **nodep, struct bNodeSocket **sockp, int in_out);
 
index 6caf0a7..1abce52 100644 (file)
@@ -136,7 +136,8 @@ typedef struct bNodeSocket {
        /* hide socket value, if it gets auto default */
 #define SOCK_HIDE_VALUE                        128
        /* socket hidden automatically, to distinguish from manually hidden */
-#define SOCK_AUTO_HIDDEN               256
+       /* DEPRECATED, only kept here to avoid reusing the flag */
+#define SOCK_AUTO_HIDDEN__DEPRECATED   256
 
 typedef struct bNodePreview {
        unsigned char *rect;