Three node selection operators added, patch by Michał Ziułek, thanks!
[blender-staging.git] / source / blender / editors / space_node / node_ops.c
1 /**
2  * $Id:
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation, Nathan Letwory
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include "DNA_node_types.h"
30 #include "DNA_material_types.h"
31 #include "DNA_texture_types.h"
32 #include "DNA_scene_types.h"
33 #include "DNA_space_types.h"
34
35 #include "BKE_context.h"
36 #include "BKE_node.h"
37
38 #include "ED_space_api.h"
39 #include "ED_screen.h"
40 #include "ED_transform.h"
41
42 #include "RNA_access.h"
43 #include "RNA_define.h"
44
45 #include "WM_api.h"
46 #include "WM_types.h"
47
48 #include "node_intern.h"
49
50 void node_operatortypes(void)
51 {
52         WM_operatortype_append(NODE_OT_select);
53         WM_operatortype_append(NODE_OT_select_extend);
54         WM_operatortype_append(NODE_OT_select_all);
55         WM_operatortype_append(NODE_OT_select_linked_to);
56         WM_operatortype_append(NODE_OT_select_linked_from);
57         WM_operatortype_append(NODE_OT_visibility_toggle);
58         WM_operatortype_append(NODE_OT_view_all);
59         WM_operatortype_append(NODE_OT_select_border);
60         WM_operatortype_append(NODE_OT_delete);
61         WM_operatortype_append(NODE_OT_link);
62         WM_operatortype_append(NODE_OT_resize);
63         WM_operatortype_append(NODE_OT_links_cut);
64         WM_operatortype_append(NODE_OT_duplicate);
65 }
66
67 void node_keymap(struct wmWindowManager *wm)
68 {
69         ListBase *keymap= WM_keymap_listbase(wm, "Node", SPACE_NODE, 0);
70         
71         /* mouse select in nodes used to be both keys, it's UI elements... */
72         RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
73         RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
74         RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select_extend", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
75         RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_select_extend", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
76         
77         WM_keymap_add_item(keymap, "NODE_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
78         
79         WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
80         WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0);
81         WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", LEFTMOUSE, KM_PRESS, 0, 0);
82         WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_ALT, 0);
83         
84         WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
85         WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
86         WM_keymap_add_item(keymap, "NODE_OT_delete", XKEY, KM_PRESS, 0, 0);
87
88         WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0);
89         WM_keymap_add_item(keymap, "NODE_OT_select_linked_to", LKEY, KM_PRESS, KM_SHIFT, 0);
90         WM_keymap_add_item(keymap, "NODE_OT_select_linked_from", LKEY, KM_PRESS, 0, 0);
91         
92         transform_keymap_for_space(wm, keymap, SPACE_NODE);
93 }