2.5 / Nodes
authorNathan Letwory <nathan@letworyinteractive.com>
Sun, 28 Dec 2008 20:49:37 +0000 (20:49 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Sun, 28 Dec 2008 20:49:37 +0000 (20:49 +0000)
* shift-select operator, inheriting from normal select operator.

source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/node_select.c

index c5eb89f8270aaf4ffb62e3106aaee978d4ba360f..f817a8efdbf8573b215b0eeb96c1cbdd3b170bb0 100644 (file)
@@ -1365,6 +1365,7 @@ bNode *editnode_get_active(bNodeTree *ntree)
                return nodeGetActive(ntree);
 }
 
+#endif /* 0 */
 
 /* no undo here! */
 void node_deselectall(SpaceNode *snode, int swap)
@@ -1378,7 +1379,6 @@ void node_deselectall(SpaceNode *snode, int swap)
                if(node==NULL) {
                        for(node= snode->edittree->nodes.first; node; node= node->next)
                                node->flag |= SELECT;
-                       // allqueue(REDRAWNODE, 0);
                        return;
                }
                /* else pass on to deselect */
@@ -1386,10 +1386,10 @@ void node_deselectall(SpaceNode *snode, int swap)
        
        for(node= snode->edittree->nodes.first; node; node= node->next)
                node->flag &= ~SELECT;
-       
-       // allqueue(REDRAWNODE, 0);
 }
 
+#if 0
+
 int node_has_hidden_sockets(bNode *node)
 {
        bNodeSocket *sock;
index d5737f8699fd40da16318f75cef44f925a835c1f..05453c6d97b69e3a1fa99aca0faa88ef075a679a 100644 (file)
@@ -52,6 +52,7 @@ void node_keymap(wmWindowManager *wm);
 
 /* node_select.c */
 void NODE_OT_select(struct wmOperatorType *ot);
+void NODE_OT_extend_select(struct wmOperatorType *ot);
 
 /* drawnode.c */
 void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);
@@ -63,6 +64,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene);
 void scale_node(SpaceNode *snode, bNode *node);
 void snode_make_group_editable(SpaceNode *snode, bNode *gnode);
 void node_set_active(SpaceNode *snode, bNode *node);
+void node_deselectall(SpaceNode *snode, int swap);
 
 #endif /* ED_NODE_INTERN_H */
 
index 72bad52d7020b3f52e041904fd546dca5f97ec01..557c1bcc4fe93d2cc6b26313de25e2f946d1afd6 100644 (file)
@@ -47,6 +47,7 @@
 void node_operatortypes(void)
 {
        WM_operatortype_append(NODE_OT_select);
+       WM_operatortype_append(NODE_OT_extend_select);
 }
 
 void node_keymap(struct wmWindowManager *wm)
@@ -54,4 +55,5 @@ void node_keymap(struct wmWindowManager *wm)
        ListBase *keymap= WM_keymap_listbase(wm, "Node", SPACE_NODE, 0);
        
        RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
+       RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_extend_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
 }
index 7ab0f1d08750323811bd8fbcc0ace20499378e77..e4951e79562722f6933fee68acaa828059696aa4 100644 (file)
@@ -183,7 +183,7 @@ static int do_header_hidden_node(SpaceNode *snode, bNode *node, float mx, float
        return 0;
 }
 
-static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval)
+static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short modifier)
 {
        bNode *node;
        float mx, my;
@@ -210,28 +210,23 @@ static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval)
                        break;
        }
        if(node) {
-               // XXX if((G.qual & LR_SHIFTKEY)==0)
-               //      node_deselectall(snode, 0);
+               if((modifier & KM_SHIFT)==0)
+                       node_deselectall(snode, 0);
                
-               // XXX
-               /*
-               if(G.qual & LR_SHIFTKEY) {
+               if(modifier & KM_SHIFT) {
                        if(node->flag & SELECT)
                                node->flag &= ~SELECT;
                        else
                                node->flag |= SELECT;
                }
-               else */
+               else
                        node->flag |= SELECT;
                
                node_set_active(snode, node);
                
                /* viewer linking */
-               //if(G.qual & LR_CTRLKEY)
-               //      node_link_viewer(snode, node);
-               
-               /* not so nice (no event), but function below delays redraw otherwise */
-               //force_draw(0);
+               if(modifier & KM_CTRL)
+                       ;//     node_link_viewer(snode, node);
                
                //std_rmouse_transform(node_transform_ext);     /* does undo push for select */
                ED_region_tag_redraw(ar);
@@ -244,6 +239,7 @@ static int node_select_exec(bContext *C, wmOperator *op)
        ARegion *ar= CTX_wm_region(C);
        int select_type;
        short mval[2];
+       short modifier;
 
        select_type = RNA_enum_get(op->ptr, "select_type");
        
@@ -251,7 +247,8 @@ static int node_select_exec(bContext *C, wmOperator *op)
                case NODE_SELECT_MOUSE:
                        mval[0] = RNA_int_get(op->ptr, "mx");
                        mval[1] = RNA_int_get(op->ptr, "my");
-                       node_mouse_select(snode, ar, mval);
+                       modifier = RNA_int_get(op->ptr, "modifier");
+                       node_mouse_select(snode, ar, mval, modifier);
                        break;
        }
        return OPERATOR_FINISHED;
@@ -271,12 +268,39 @@ static int node_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
        return node_select_exec(C,op);
 }
 
+static int node_extend_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       RNA_int_set(op->ptr, "modifier", KM_SHIFT);
+
+       return node_select_invoke(C, op, event);
+}
+
 /* operators */
 
 static EnumPropertyItem prop_select_items[] = {
        {NODE_SELECT_MOUSE, "NORMAL", "Normal Select", "Select using the mouse"},
        {0, NULL, NULL, NULL}};
 
+void NODE_OT_extend_select(wmOperatorType *ot)
+{
+       PropertyRNA *prop;
+       
+       /* identifiers */
+       ot->name= "Activate/Select (Shift)";
+       ot->idname= "NODE_OT_extend_select";
+       
+       /* api callbacks */
+       ot->invoke= node_extend_select_invoke;
+       ot->poll= ED_operator_node_active;
+       
+       prop = RNA_def_property(ot->srna, "select_type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_select_items);
+       
+       prop = RNA_def_property(ot->srna, "mx", PROP_INT, PROP_NONE);
+       prop = RNA_def_property(ot->srna, "my", PROP_INT, PROP_NONE);
+       prop = RNA_def_property(ot->srna, "modifier", PROP_INT, PROP_NONE);
+}
+
 void NODE_OT_select(wmOperatorType *ot)
 {
        PropertyRNA *prop;
@@ -294,4 +318,5 @@ void NODE_OT_select(wmOperatorType *ot)
        
        prop = RNA_def_property(ot->srna, "mx", PROP_INT, PROP_NONE);
        prop = RNA_def_property(ot->srna, "my", PROP_INT, PROP_NONE);
+       prop = RNA_def_property(ot->srna, "modifier", PROP_INT, PROP_NONE);
 }