Fix syntax for ID keyword.
[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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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_properties);
53         
54         WM_operatortype_append(NODE_OT_select);
55         WM_operatortype_append(NODE_OT_select_all);
56         WM_operatortype_append(NODE_OT_select_linked_to);
57         WM_operatortype_append(NODE_OT_select_linked_from);
58         WM_operatortype_append(NODE_OT_select_border);
59         
60         WM_operatortype_append(NODE_OT_view_all);
61         WM_operatortype_append(NODE_OT_visibility_toggle);
62         WM_operatortype_append(NODE_OT_mute);
63         WM_operatortype_append(NODE_OT_hide);
64         WM_operatortype_append(NODE_OT_show_cyclic_dependencies);
65         
66         WM_operatortype_append(NODE_OT_duplicate);
67         WM_operatortype_append(NODE_OT_delete);
68         WM_operatortype_append(NODE_OT_resize);
69         
70         WM_operatortype_append(NODE_OT_link);
71         WM_operatortype_append(NODE_OT_link_make);
72         WM_operatortype_append(NODE_OT_links_cut);
73         
74         WM_operatortype_append(NODE_OT_group_make);
75         WM_operatortype_append(NODE_OT_group_ungroup);
76         WM_operatortype_append(NODE_OT_group_edit);
77 }
78
79 void ED_operatormacros_node(void)
80 {
81         wmOperatorType *ot;
82         wmOperatorTypeMacro *otmacro;
83         
84         ot= WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
85         WM_operatortype_macro_define(ot, "NODE_OT_duplicate");
86         otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
87         RNA_enum_set(otmacro->ptr, "proportional", 0);
88 }
89
90 void node_keymap(struct wmKeyConfig *keyconf)
91 {
92         wmKeyMap *keymap;
93         wmKeyMapItem *kmi;
94         
95         /* Entire Editor only ----------------- */
96         keymap= WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0);
97         
98         WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0);
99         
100         /* Main Area only ----------------- */
101         keymap= WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0);
102         
103         /* mouse select in nodes used to be both keys, but perhaps this should be reduced? 
104          * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize
105          */
106         WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0);
107         WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
108         kmi= WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
109                 RNA_boolean_set(kmi->ptr, "extend", 1);
110         kmi= WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
111                 RNA_boolean_set(kmi->ptr, "extend", 1);
112         RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0)->ptr, "tweak", 1);
113         
114         /* each of these falls through if not handled... */
115         WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
116         WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0);
117         WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", LEFTMOUSE, KM_PRESS, 0, 0);
118         
119         WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
120         WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
121         RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "replace", 1);
122         
123         WM_keymap_add_menu(keymap, "NODE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
124         WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
125         
126         WM_keymap_add_item(keymap, "NODE_OT_hide", HKEY, KM_PRESS, 0, 0);
127         WM_keymap_add_item(keymap, "NODE_OT_mute", MKEY, KM_PRESS, 0, 0);
128         
129         WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0);
130         
131         WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
132         WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
133         WM_keymap_add_item(keymap, "NODE_OT_delete", XKEY, KM_PRESS, 0, 0);
134         WM_keymap_add_item(keymap, "NODE_OT_delete", DELKEY, KM_PRESS, 0, 0);
135
136         WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0);
137         WM_keymap_add_item(keymap, "NODE_OT_select_linked_to", LKEY, KM_PRESS, KM_SHIFT, 0);
138         WM_keymap_add_item(keymap, "NODE_OT_select_linked_from", LKEY, KM_PRESS, 0, 0);
139
140         WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0);
141         WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
142         WM_keymap_add_item(keymap, "NODE_OT_group_edit", TABKEY, KM_PRESS, 0, 0);
143         
144         transform_keymap_for_space(keyconf, keymap, SPACE_NODE);
145 }