Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 * 00018 * The Original Code is Copyright (C) 2008 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Blender Foundation, Nathan Letwory 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include "DNA_node_types.h" 00033 #include "DNA_scene_types.h" 00034 00035 #include "BKE_context.h" 00036 00037 #include "BLI_utildefines.h" 00038 00039 #include "ED_node.h" 00040 #include "ED_screen.h" 00041 #include "ED_transform.h" 00042 00043 #include "RNA_access.h" 00044 00045 #include "WM_api.h" 00046 #include "WM_types.h" 00047 00048 #include "node_intern.h" 00049 00050 void node_operatortypes(void) 00051 { 00052 WM_operatortype_append(NODE_OT_properties); 00053 00054 WM_operatortype_append(NODE_OT_select); 00055 WM_operatortype_append(NODE_OT_select_all); 00056 WM_operatortype_append(NODE_OT_select_linked_to); 00057 WM_operatortype_append(NODE_OT_select_linked_from); 00058 WM_operatortype_append(NODE_OT_select_border); 00059 WM_operatortype_append(NODE_OT_select_same_type); 00060 WM_operatortype_append(NODE_OT_select_same_type_next); 00061 WM_operatortype_append(NODE_OT_select_same_type_prev); 00062 00063 WM_operatortype_append(NODE_OT_view_all); 00064 00065 WM_operatortype_append(NODE_OT_mute_toggle); 00066 WM_operatortype_append(NODE_OT_hide_toggle); 00067 WM_operatortype_append(NODE_OT_preview_toggle); 00068 WM_operatortype_append(NODE_OT_options_toggle); 00069 WM_operatortype_append(NODE_OT_hide_socket_toggle); 00070 WM_operatortype_append(NODE_OT_show_cyclic_dependencies); 00071 00072 WM_operatortype_append(NODE_OT_duplicate); 00073 WM_operatortype_append(NODE_OT_delete); 00074 WM_operatortype_append(NODE_OT_delete_reconnect); 00075 WM_operatortype_append(NODE_OT_resize); 00076 00077 WM_operatortype_append(NODE_OT_link); 00078 WM_operatortype_append(NODE_OT_link_make); 00079 WM_operatortype_append(NODE_OT_links_cut); 00080 00081 WM_operatortype_append(NODE_OT_group_make); 00082 WM_operatortype_append(NODE_OT_group_ungroup); 00083 WM_operatortype_append(NODE_OT_group_edit); 00084 WM_operatortype_append(NODE_OT_group_socket_add); 00085 WM_operatortype_append(NODE_OT_group_socket_remove); 00086 WM_operatortype_append(NODE_OT_group_socket_move_up); 00087 WM_operatortype_append(NODE_OT_group_socket_move_down); 00088 00089 WM_operatortype_append(NODE_OT_link_viewer); 00090 00091 WM_operatortype_append(NODE_OT_read_renderlayers); 00092 WM_operatortype_append(NODE_OT_read_fullsamplelayers); 00093 WM_operatortype_append(NODE_OT_render_changed); 00094 00095 WM_operatortype_append(NODE_OT_backimage_move); 00096 WM_operatortype_append(NODE_OT_backimage_zoom); 00097 WM_operatortype_append(NODE_OT_backimage_sample); 00098 00099 WM_operatortype_append(NODE_OT_add_file); 00100 00101 WM_operatortype_append(NODE_OT_new_node_tree); 00102 } 00103 00104 void ED_operatormacros_node(void) 00105 { 00106 wmOperatorType *ot; 00107 wmOperatorTypeMacro *mot; 00108 00109 ot= WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); 00110 ot->description = "Duplicate selected nodes and move them"; 00111 WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); 00112 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00113 00114 /* modified operator call for duplicating with input links */ 00115 ot= WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); 00116 ot->description = "Duplicate selected nodes keeping input links and move them"; 00117 00118 mot = WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); 00119 RNA_boolean_set(mot->ptr, "keep_inputs", TRUE); 00120 00121 WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); 00122 00123 ot= WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO); 00124 ot->description = "Select node and link it to a viewer node"; 00125 WM_operatortype_macro_define(ot, "NODE_OT_select"); 00126 WM_operatortype_macro_define(ot, "NODE_OT_link_viewer"); 00127 } 00128 00129 void node_keymap(struct wmKeyConfig *keyconf) 00130 { 00131 wmKeyMap *keymap; 00132 wmKeyMapItem *kmi; 00133 00134 /* Entire Editor only ----------------- */ 00135 keymap= WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0); 00136 00137 WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0); 00138 00139 /* Main Area only ----------------- */ 00140 keymap= WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0); 00141 00142 /* mouse select in nodes used to be both keys, but perhaps this should be reduced? 00143 * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize 00144 */ 00145 kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, 0, 0); 00146 RNA_boolean_set(kmi->ptr, "extend", FALSE); 00147 kmi = WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); 00148 RNA_boolean_set(kmi->ptr, "extend", FALSE); 00149 kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); 00150 RNA_boolean_set(kmi->ptr, "extend", TRUE); 00151 kmi = WM_keymap_add_item(keymap, "NODE_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); 00152 RNA_boolean_set(kmi->ptr, "extend", TRUE); 00153 kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0); 00154 RNA_boolean_set(kmi->ptr, "tweak", TRUE); 00155 00156 /* each of these falls through if not handled... */ 00157 WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, 0, 0); 00158 WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0); 00159 00160 WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); 00161 WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); 00162 00163 WM_keymap_add_item(keymap, "NODE_OT_backimage_move", MIDDLEMOUSE, KM_PRESS, KM_ALT, 0); 00164 kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, 0, 0); 00165 RNA_float_set(kmi->ptr, "factor", 0.83333f); 00166 kmi= WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, KM_ALT, 0); 00167 RNA_float_set(kmi->ptr, "factor", 1.2f); 00168 WM_keymap_add_item(keymap, "NODE_OT_backimage_sample", ACTIONMOUSE, KM_PRESS, KM_ALT, 0); 00169 00170 kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, 0, 0); 00171 RNA_boolean_set(kmi->ptr, "replace", FALSE); 00172 kmi = WM_keymap_add_item(keymap, "NODE_OT_link_make", FKEY, KM_PRESS, KM_CTRL, 0); 00173 RNA_boolean_set(kmi->ptr, "replace", TRUE); 00174 00175 WM_keymap_add_menu(keymap, "NODE_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); 00176 WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); 00177 /* modified operator call for duplicating with input links */ 00178 WM_keymap_add_item(keymap, "NODE_OT_duplicate_move_keep_inputs", DKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); 00179 00180 WM_keymap_add_item(keymap, "NODE_OT_hide_toggle", HKEY, KM_PRESS, 0, 0); 00181 WM_keymap_add_item(keymap, "NODE_OT_mute_toggle", MKEY, KM_PRESS, 0, 0); 00182 WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0); 00183 WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0); 00184 00185 WM_keymap_add_item(keymap, "NODE_OT_show_cyclic_dependencies", CKEY, KM_PRESS, 0, 0); 00186 00187 WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); 00188 00189 kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", BKEY, KM_PRESS, 0, 0); 00190 RNA_boolean_set(kmi->ptr, "tweak", FALSE); 00191 00192 WM_keymap_add_item(keymap, "NODE_OT_delete", XKEY, KM_PRESS, 0, 0); 00193 WM_keymap_add_item(keymap, "NODE_OT_delete", DELKEY, KM_PRESS, 0, 0); 00194 WM_keymap_add_item(keymap, "NODE_OT_delete_reconnect", XKEY, KM_PRESS, KM_CTRL, 0); 00195 00196 WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0); 00197 WM_keymap_add_item(keymap, "NODE_OT_select_linked_to", LKEY, KM_PRESS, KM_SHIFT, 0); 00198 WM_keymap_add_item(keymap, "NODE_OT_select_linked_from", LKEY, KM_PRESS, 0, 0); 00199 WM_keymap_add_item(keymap, "NODE_OT_select_same_type", GKEY, KM_PRESS, KM_SHIFT, 0); 00200 WM_keymap_add_item(keymap, "NODE_OT_select_same_type_next", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); 00201 WM_keymap_add_item(keymap, "NODE_OT_select_same_type_prev", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); 00202 00203 WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0); 00204 WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0); 00205 WM_keymap_add_item(keymap, "NODE_OT_group_edit", TABKEY, KM_PRESS, 0, 0); 00206 00207 WM_keymap_add_item(keymap, "NODE_OT_read_renderlayers", RKEY, KM_PRESS, KM_CTRL, 0); 00208 WM_keymap_add_item(keymap, "NODE_OT_read_fullsamplelayers", RKEY, KM_PRESS, KM_SHIFT, 0); 00209 WM_keymap_add_item(keymap, "NODE_OT_render_changed", ZKEY, KM_PRESS, 0, 0); 00210 00211 transform_keymap_for_space(keyconf, keymap, SPACE_NODE); 00212 }