make node select_all consistent with other select operators, also add Ctrl+I, select...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 1 Aug 2012 13:28:19 +0000 (13:28 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 1 Aug 2012 13:28:19 +0000 (13:28 +0000)
release/scripts/startup/bl_ui/space_node.py
source/blender/editors/include/ED_node.h
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/transform/transform_snap.c
source/blender/windowmanager/intern/wm_init_exit.c

index ccdf44a7dc2c1be6a9efb99d7e65c9cb5b019526..e66d8f70c81886e52795871419a715c364958928 100644 (file)
@@ -135,7 +135,8 @@ class NODE_MT_select(Menu):
         layout.operator("node.select_border")
 
         layout.separator()
-        layout.operator("node.select_all")
+        layout.operator("node.select_all").action = 'TOGGLE'
+        layout.operator("node.select_all", text="Inverse").action = 'INVERT'
         layout.operator("node.select_linked_from")
         layout.operator("node.select_linked_to")
         layout.operator("node.select_same_type")
index 6f86d01fb98a8e7eb265b3e7a50eecbc3922a668..8c79ad8f3e8f13ae106e4060ad3bc87e06475401 100644 (file)
@@ -51,9 +51,9 @@ typedef enum {
 } NodeBorder;
 
 /* drawnode.c */
-void ED_init_node_butfuncs(void);
-
-void drawnodesnap(struct View2D *v2d, const float cent[2], float size, NodeBorder border);
+void ED_node_init_butfuncs(void);
+void ED_node_sample_set(const float col[4]);
+void ED_node_draw_snap(struct View2D *v2d, const float cent[2], float size, NodeBorder border);
 
 /* node_draw.c */
 void ED_node_tree_update(struct SpaceNode *snode, struct Scene *scene);
@@ -67,13 +67,10 @@ void ED_node_composit_default(struct Scene *sce);
 void ED_node_texture_default(struct Tex *tex);
 void ED_node_link_intersect_test(struct ScrArea *sa, int test);
 void ED_node_link_insert(struct ScrArea *sa);
-
+int  ED_node_select_check(ListBase *lb);
 void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree);
-
 void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
 
-void ED_node_sample_set(const float col[4]);
-
 /* node ops.c */
 void ED_operatormacros_node(void);
 
index 8688bee0a732605d4bd7a1ed378a356f8fec0342..c3d9336ae64927dcc8756a6e483a71f68521969a 100644 (file)
@@ -2950,7 +2950,7 @@ static void node_texture_set_butfunc(bNodeType *ntype)
 
 /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
 
-void ED_init_node_butfuncs(void)
+void ED_node_init_butfuncs(void)
 {
        bNodeTreeType *treetype;
        bNodeType *ntype;
@@ -3498,7 +3498,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
 //     node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
 }
 
-void drawnodesnap(View2D *v2d, const float cent[2], float size, NodeBorder border)
+void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border)
 {
        glBegin(GL_LINES);
        
index b3ef4561b729d69a10e7eea52b61187f124962b1..f020b306db39ca101ef5f76ec9b3de80c3b18423 100644 (file)
@@ -3505,6 +3505,18 @@ void ED_node_link_intersect_test(ScrArea *sa, int test)
                selink->flag |= NODE_LINKFLAG_HILITE;
 }
 
+int ED_node_select_check(ListBase *lb)
+{
+       bNode *node;
+
+       for (node = lb->first; node; node = node->next) {
+               if (node->flag & NODE_SELECT) {
+                       return TRUE;
+               }
+       }
+
+       return FALSE;
+}
 
 /* ******************************** */
 // XXX some code needing updating to operators...
index ff1661f03271f0ee7708bb88e77661f600681920..0ce72848c568968544cf67ac9dfa4ce21033f8b4 100644 (file)
@@ -261,7 +261,11 @@ void node_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "NODE_OT_delete", DELKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", XKEY, KM_PRESS, KM_CTRL, 0);
 
-       WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0);
+       kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
+       kmi = WM_keymap_add_item(keymap, "NODE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
+       RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
+
        WM_keymap_add_item(keymap, "NODE_OT_select_linked_to", LKEY, KM_PRESS, KM_SHIFT, 0);
        WM_keymap_add_item(keymap, "NODE_OT_select_linked_from", LKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NODE_OT_select_same_type", GKEY, KM_PRESS, KM_SHIFT, 0);
index 1ea763a413dd45d03e69c72ddd67fea0c3e80768..603603b9f07c233bca573f71fddef96471d9a4ca 100644 (file)
@@ -537,26 +537,34 @@ void NODE_OT_select_border(wmOperatorType *ot)
 
 /* ****** Select/Deselect All ****** */
 
-static int node_select_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_select_all_exec(bContext *C, wmOperator *op)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
-       bNode *first = snode->edittree->nodes.first;
+       ListBase *node_lb = &snode->edittree->nodes;
        bNode *node;
-       int count= 0;
+       int action = RNA_enum_get(op->ptr, "action");
 
-       for (node=first; node; node=node->next)
-               if (node->flag & NODE_SELECT)
-                       count++;
-
-       if (count) {
-               for (node=first; node; node=node->next)
-                       node_deselect(node);
+       if (action == SEL_TOGGLE) {
+               if (ED_node_select_check(node_lb))
+                       action = SEL_DESELECT;
+               else
+                       action = SEL_SELECT;
        }
-       else {
-               for (node=first; node; node=node->next)
-                       node_select(node);
+
+       for (node = node_lb->first; node; node = node->next) {
+               switch (action) {
+                       case SEL_SELECT:
+                               node_select(node);
+                               break;
+                       case SEL_DESELECT:
+                               node_deselect(node);
+                               break;
+                       case SEL_INVERT:
+                               ((node->flag & SELECT) ? node_deselect : node_select)(node);
+                               break;
+               }
        }
-       
+
        ED_node_sort(snode->edittree);
        
        WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
@@ -576,6 +584,8 @@ void NODE_OT_select_all(wmOperatorType *ot)
        
        /* flags */
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       WM_operator_properties_select_all(ot);
 }
 
 /* ****** Select Linked To ****** */
index 667365488755b5b3c602c7a439bec411a7de191d..278acb725110c430c79cda2e2c2fbdad0791fc7a 100644 (file)
@@ -246,13 +246,13 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
                                        glColor4ubv(col);
                                }
                                
-                               drawnodesnap(&ar->v2d, p->co, size, 0);
+                               ED_node_draw_snap(&ar->v2d, p->co, size, 0);
                        }
                        
                        if (t->tsnap.status & POINT_INIT) {
                                glColor4ubv(activeCol);
                                
-                               drawnodesnap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder);
+                               ED_node_draw_snap(&ar->v2d, t->tsnap.snapPoint, size, t->tsnap.snapNodeBorder);
                        }
                        
                        glDisable(GL_BLEND);
index 6297c3373356b16fbe933b3237aba24e16abe9ae..5bf6c34cfb3b33921d609e9551f1651f307835a8 100644 (file)
@@ -142,7 +142,7 @@ void WM_init(bContext *C, int argc, const char **argv)
        ED_spacetypes_init();   /* editors/space_api/spacetype.c */
        
        ED_file_init();         /* for fsmenu */
-       ED_init_node_butfuncs();        
+       ED_node_init_butfuncs();
        
        BLF_init(11, U.dpi); /* Please update source/gamengine/GamePlayer/GPG_ghost.cpp if you change this */
        BLF_lang_init();