Request: auto link to viewer node back. Used to be ctrl+click, is now
authorTon Roosendaal <ton@blender.org>
Mon, 5 Apr 2010 18:34:18 +0000 (18:34 +0000)
committerTon Roosendaal <ton@blender.org>
Mon, 5 Apr 2010 18:34:18 +0000 (18:34 +0000)
shift+ctrl+click, because the ctrl_click goes to knife cutting.

Implementation note: this is a macro, select + link.

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

index 69b2cb95a9d5f78bf8de504fb710be393810a826..246806ecec9def98329566dd892ba7b21e27c040 100644 (file)
@@ -910,13 +910,40 @@ static void node_link_viewer(SpaceNode *snode, bNode *tonode)
 }
 
 
-void node_active_link_viewer(SpaceNode *snode)
+static int node_active_link_viewer(bContext *C, wmOperator *op)
 {
-       bNode *node= editnode_get_active(snode->edittree);
-       if(node)
+       SpaceNode *snode= CTX_wm_space_node(C);
+       bNode *node;
+       
+       
+       node= editnode_get_active(snode->edittree);
+       
+       if(node) {
                node_link_viewer(snode, node);
+               snode_notify(C, snode);
+       }
+       return OPERATOR_FINISHED;
 }
 
+
+
+void NODE_OT_link_viewer(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Link to Viewer Node";
+       ot->description = "Link to Viewer Node";
+       ot->idname= "NODE_OT_link_viewer";
+       
+       /* api callbacks */
+       ot->exec= node_active_link_viewer;
+       ot->poll= ED_operator_node_active;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
+
 /* return 0, nothing done */
 /*static*/ int node_mouse_groupheader(SpaceNode *snode)
 {
index ade31ee525a7633b0058e89e18470b0f3a64f105..6f7638a1f14b291a06bd21f40c37a52e7c686dd2 100644 (file)
@@ -102,6 +102,8 @@ void NODE_OT_mute(struct wmOperatorType *ot);
 void NODE_OT_hide(struct wmOperatorType *ot);
 
 void NODE_OT_show_cyclic_dependencies(struct wmOperatorType *ot);
+void NODE_OT_link_viewer(struct wmOperatorType *ot);
+
 
 // XXXXXX
 
index 9994da909d3d66b4556a12ca041da61fae7c45ea..6566f2f184d714a1758731d72113c23a8631eb19 100644 (file)
@@ -69,6 +69,8 @@ void node_operatortypes(void)
        WM_operatortype_append(NODE_OT_group_make);
        WM_operatortype_append(NODE_OT_group_ungroup);
        WM_operatortype_append(NODE_OT_group_edit);
+       
+       WM_operatortype_append(NODE_OT_link_viewer);
 }
 
 void ED_operatormacros_node(void)
@@ -78,6 +80,11 @@ void ED_operatormacros_node(void)
        ot= WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
        WM_operatortype_macro_define(ot, "NODE_OT_duplicate");
        WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
+
+       ot= WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO);
+       WM_operatortype_macro_define(ot, "NODE_OT_select");
+       WM_operatortype_macro_define(ot, "NODE_OT_link_viewer");
+       
 }
 
 void node_keymap(struct wmKeyConfig *keyconf)
@@ -110,6 +117,8 @@ void node_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", LEFTMOUSE, KM_PRESS, 0, 0);
        
        WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+       
        WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "replace", 1);