doxygen: prevent GPL license block from being parsed as doxygen comment.
[blender.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_scene_types.h"
31
32 #include "BKE_context.h"
33
34 #include "ED_node.h"
35 #include "ED_screen.h"
36 #include "ED_transform.h"
37
38 #include "RNA_access.h"
39
40 #include "WM_api.h"
41 #include "WM_types.h"
42
43 #include "node_intern.h"
44
45 void node_operatortypes(void)
46 {
47         WM_operatortype_append(NODE_OT_properties);
48         
49         WM_operatortype_append(NODE_OT_select);
50         WM_operatortype_append(NODE_OT_select_all);
51         WM_operatortype_append(NODE_OT_select_linked_to);
52         WM_operatortype_append(NODE_OT_select_linked_from);
53         WM_operatortype_append(NODE_OT_select_border);
54         WM_operatortype_append(NODE_OT_select_same_type);
55         WM_operatortype_append(NODE_OT_select_same_type_next);
56         WM_operatortype_append(NODE_OT_select_same_type_prev);
57
58         WM_operatortype_append(NODE_OT_view_all);
59         WM_operatortype_append(NODE_OT_visibility_toggle);
60         WM_operatortype_append(NODE_OT_mute_toggle);
61         WM_operatortype_append(NODE_OT_hide_toggle);
62         WM_operatortype_append(NODE_OT_preview_toggle);
63         WM_operatortype_append(NODE_OT_hide_socket_toggle);
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         WM_operatortype_append(NODE_OT_group_socket_add);
78         WM_operatortype_append(NODE_OT_group_socket_remove);
79         WM_operatortype_append(NODE_OT_group_socket_move_up);
80         WM_operatortype_append(NODE_OT_group_socket_move_down);
81         
82         WM_operatortype_append(NODE_OT_link_viewer);
83         
84         WM_operatortype_append(NODE_OT_read_renderlayers);
85         WM_operatortype_append(NODE_OT_read_fullsamplelayers);
86         WM_operatortype_append(NODE_OT_render_changed);
87         
88         WM_operatortype_append(NODE_OT_backimage_move);
89         WM_operatortype_append(NODE_OT_backimage_zoom);
90         WM_operatortype_append(NODE_OT_backimage_sample);
91         
92         WM_operatortype_append(NODE_OT_add_file);
93 }
94
95 void ED_operatormacros_node(void)
96 {
97         wmOperatorType *ot;
98         
99         ot= WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
100         WM_operatortype_macro_define(ot, "NODE_OT_duplicate");
101         WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
102
103         ot= WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO);
104         WM_operatortype_macro_define(ot, "NODE_OT_select");
105         WM_operatortype_macro_define(ot, "NODE_OT_link_viewer");
106         
107 }
108
109 void node_keymap(struct wmKeyConfig *keyconf)
110 {
111         wmKeyMap *keymap;
112         wmKeyMapItem *kmi;
113         
114         /* Entire Editor only ----------------- */
115         keymap= WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0);
116         
117         WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0);
118         
119         /* Main Area only ----------------- */
120         keymap= WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0);
121         
122         /* mouse select in nodes used to be both keys, but perhaps this should be reduced? 
123          * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize
124          */
125         WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0);
126         WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
127         kmi= WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
128                 RNA_boolean_set(kmi->ptr, "extend", 1);
129         kmi= WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
130                 RNA_boolean_set(kmi->ptr, "extend", 1);
131         RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0)->ptr, "tweak", 1);
132         
133         /* each of these falls through if not handled... */
134         WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0);
135         WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0);
136         WM_keymap_add_item(keymap, "NODE_OT_visibility_toggle", LEFTMOUSE, KM_PRESS, 0, 0);
137         
138         WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
139         WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
140         
141         WM_keymap_add_item(keymap, "NODE_OT_backimage_move", MIDDLEMOUSE, KM_PRESS, KM_ALT, 0);
142         kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, 0, 0);
143                 RNA_float_set(kmi->ptr, "factor", 0.83333f);
144         kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, KM_ALT, 0);
145                 RNA_float_set(kmi->ptr, "factor", 1.2f);
146         WM_keymap_add_item(keymap, "NODE_OT_backimage_sample", ACTIONMOUSE, KM_PRESS, KM_ALT, 0);
147         
148         WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0);
149         RNA_boolean_set(WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0)->ptr, "replace", 1);
150         
151         WM_keymap_add_menu(keymap, "NODE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
152         WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
153         
154         WM_keymap_add_item(keymap, "NODE_OT_hide_toggle", HKEY, KM_PRESS, 0, 0);
155         WM_keymap_add_item(keymap, "NODE_OT_mute_toggle", MKEY, KM_PRESS, 0, 0);
156         WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0);
157         WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
158         
159         WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0);
160         
161         WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
162         WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0);
163         WM_keymap_add_item(keymap, "NODE_OT_delete", XKEY, KM_PRESS, 0, 0);
164         WM_keymap_add_item(keymap, "NODE_OT_delete", DELKEY, KM_PRESS, 0, 0);
165
166         WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0);
167         WM_keymap_add_item(keymap, "NODE_OT_select_linked_to", LKEY, KM_PRESS, KM_SHIFT, 0);
168         WM_keymap_add_item(keymap, "NODE_OT_select_linked_from", LKEY, KM_PRESS, 0, 0);
169         WM_keymap_add_item(keymap, "NODE_OT_select_same_type", GKEY, KM_PRESS, KM_SHIFT, 0);
170         WM_keymap_add_item(keymap, "NODE_OT_select_same_type_next", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
171         WM_keymap_add_item(keymap, "NODE_OT_select_same_type_prev", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
172
173         WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0);
174         WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0);
175         WM_keymap_add_item(keymap, "NODE_OT_group_edit", TABKEY, KM_PRESS, 0, 0);
176         
177         WM_keymap_add_item(keymap, "NODE_OT_read_renderlayers", RKEY, KM_PRESS, KM_CTRL, 0);
178         WM_keymap_add_item(keymap, "NODE_OT_read_fullsamplelayers", RKEY, KM_PRESS, KM_SHIFT, 0);
179         WM_keymap_add_item(keymap, "NODE_OT_render_changed", ZKEY, KM_PRESS, 0, 0);
180         
181         
182         transform_keymap_for_space(keyconf, keymap, SPACE_NODE);
183 }