2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008).
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_wm.c
30 #include "RNA_access.h"
31 #include "RNA_define.h"
32 #include "RNA_enum_types.h"
34 #include "rna_internal.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_space_types.h"
38 #include "DNA_userdef_types.h"
39 #include "DNA_windowmanager_types.h"
43 EnumPropertyItem event_keymouse_value_items[] = {
44 {KM_ANY, "ANY", 0, "Any", ""},
45 {KM_PRESS, "PRESS", 0, "Press", ""},
46 {KM_RELEASE, "RELEASE", 0, "Release", ""},
47 {KM_CLICK, "CLICK", 0, "Click", ""},
48 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
49 {0, NULL, 0, NULL, NULL}
52 EnumPropertyItem event_tweak_value_items[] = {
53 {KM_ANY, "ANY", 0, "Any", ""},
54 {EVT_GESTURE_N, "NORTH", 0, "North", ""},
55 {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
56 {EVT_GESTURE_E, "EAST", 0, "East", ""},
57 {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
58 {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
59 {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
60 {EVT_GESTURE_W, "WEST", 0, "West", ""},
61 {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
62 {0, NULL, 0, NULL, NULL}
65 EnumPropertyItem event_value_items[] = {
66 {KM_ANY, "ANY", 0, "Any", ""},
67 {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
68 {KM_PRESS, "PRESS", 0, "Press", ""},
69 {KM_RELEASE, "RELEASE", 0, "Release", ""},
70 {KM_CLICK, "CLICK", 0, "Click", ""},
71 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
72 {EVT_GESTURE_N, "NORTH", 0, "North", ""},
73 {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
74 {EVT_GESTURE_E, "EAST", 0, "East", ""},
75 {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
76 {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
77 {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
78 {EVT_GESTURE_W, "WEST", 0, "West", ""},
79 {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
80 {0, NULL, 0, NULL, NULL}
83 EnumPropertyItem event_tweak_type_items[] = {
84 {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""},
85 {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""},
86 {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""},
87 {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Action", ""},
88 {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Select", ""},
89 {0, NULL, 0, NULL, NULL}
92 EnumPropertyItem event_mouse_type_items[] = {
93 {LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""},
94 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""},
95 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right", ""},
96 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4", ""},
97 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5", ""},
98 {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action", ""},
99 {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""},
100 {0, "", 0, NULL, NULL},
101 {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""},
102 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""},
103 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""},
104 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""},
105 {0, "", 0, NULL, NULL},
106 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
107 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
108 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
109 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
110 {0, NULL, 0, NULL, NULL}
113 EnumPropertyItem event_timer_type_items[] = {
114 {TIMER, "TIMER", 0, "Timer", ""},
115 {TIMER0, "TIMER0", 0, "Timer 0", ""},
116 {TIMER1, "TIMER1", 0, "Timer 1", ""},
117 {TIMER2, "TIMER2", 0, "Timer 2", ""},
118 {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", ""},
119 {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", ""},
120 {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", ""},
121 {0, NULL, 0, NULL, NULL}
124 EnumPropertyItem event_ndof_type_items[] = {
125 /* buttons on all 3dconnexion devices */
126 {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "Menu", ""},
127 {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "Fit", ""},
129 {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "Top", ""},
130 {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "Bottom", ""},
131 {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "Left", ""},
132 {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "Right", ""},
133 {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "Front", ""},
134 {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "Back", ""},
136 {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "Isometric 1", ""},
137 {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "Isometric 2", ""},
138 /* 90 degree rotations */
139 {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "Roll CW", ""},
140 {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "Roll CCW", ""},
141 {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "Spin CW", ""},
142 {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "Spin CCW", ""},
143 {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "Tilt CW", ""},
144 {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "Tilt CCW", ""},
146 {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "Rotate", ""},
147 {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "Pan/Zoom", ""},
148 {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "Dominant", ""},
149 {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "Plus", ""},
150 {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "Minus", ""},
151 /* keyboard emulation */
152 {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "Esc"},
153 {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "Alt"},
154 {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "Shift"},
155 {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "Ctrl"},
156 /* general-purpose buttons */
157 {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "Button 1", ""},
158 {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "Button 2", ""},
159 {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "Button 3", ""},
160 {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "Button 4", ""},
161 {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "Button 5", ""},
162 {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "Button 6", ""},
163 {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "Button 7", ""},
164 {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "Button 8", ""},
165 {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "Button 9", ""},
166 {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "Button 10", ""},
167 {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "Button A", ""},
168 {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "Button B", ""},
169 {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "Button C", ""},
170 {0, NULL, 0, NULL, NULL}
173 /* not returned: CAPSLOCKKEY, UNKNOWNKEY */
174 EnumPropertyItem event_type_items[] = {
176 {0, "NONE", 0, "", ""},
177 {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", ""},
178 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", ""},
179 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", ""},
180 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", ""},
181 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", ""},
182 {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", ""},
183 {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""},
184 {0, "", 0, NULL, NULL},
185 {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""},
186 {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "Inbetween Move", ""},
187 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""},
188 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""},
189 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""},
190 {0, "", 0, NULL, NULL},
191 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
192 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
193 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
194 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
195 {0, "", 0, NULL, NULL},
196 {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", ""},
197 {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", ""},
198 {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", ""},
199 {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", ""},
200 {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", ""},
201 {0, "", 0, NULL, NULL},
202 {AKEY, "A", 0, "A", ""},
203 {BKEY, "B", 0, "B", ""},
204 {CKEY, "C", 0, "C", ""},
205 {DKEY, "D", 0, "D", ""},
206 {EKEY, "E", 0, "E", ""},
207 {FKEY, "F", 0, "F", ""},
208 {GKEY, "G", 0, "G", ""},
209 {HKEY, "H", 0, "H", ""},
210 {IKEY, "I", 0, "I", ""},
211 {JKEY, "J", 0, "J", ""},
212 {KKEY, "K", 0, "K", ""},
213 {LKEY, "L", 0, "L", ""},
214 {MKEY, "M", 0, "M", ""},
215 {NKEY, "N", 0, "N", ""},
216 {OKEY, "O", 0, "O", ""},
217 {PKEY, "P", 0, "P", ""},
218 {QKEY, "Q", 0, "Q", ""},
219 {RKEY, "R", 0, "R", ""},
220 {SKEY, "S", 0, "S", ""},
221 {TKEY, "T", 0, "T", ""},
222 {UKEY, "U", 0, "U", ""},
223 {VKEY, "V", 0, "V", ""},
224 {WKEY, "W", 0, "W", ""},
225 {XKEY, "X", 0, "X", ""},
226 {YKEY, "Y", 0, "Y", ""},
227 {ZKEY, "Z", 0, "Z", ""},
228 {0, "", 0, NULL, NULL},
229 {ZEROKEY, "ZERO", 0, "0", ""},
230 {ONEKEY, "ONE", 0, "1", ""},
231 {TWOKEY, "TWO", 0, "2", ""},
232 {THREEKEY, "THREE", 0, "3", ""},
233 {FOURKEY, "FOUR", 0, "4", ""},
234 {FIVEKEY, "FIVE", 0, "5", ""},
235 {SIXKEY, "SIX", 0, "6", ""},
236 {SEVENKEY, "SEVEN", 0, "7", ""},
237 {EIGHTKEY, "EIGHT", 0, "8", ""},
238 {NINEKEY, "NINE", 0, "9", ""},
239 {0, "", 0, NULL, NULL},
240 {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""},
241 {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""},
242 {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", ""},
243 {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""},
244 {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", ""},
245 {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", ""},
246 {0, "", 0, NULL, NULL},
247 {OSKEY, "OSKEY", 0, "OS Key", ""},
248 {GRLESSKEY, "GRLESS", 0, "Grless", ""},
249 {ESCKEY, "ESC", 0, "Esc", ""},
250 {TABKEY, "TAB", 0, "Tab", ""},
251 {RETKEY, "RET", 0, "Return", ""},
252 {SPACEKEY, "SPACE", 0, "Spacebar", ""},
253 {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
254 {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""},
255 {DELKEY, "DEL", 0, "Delete", ""},
256 {SEMICOLONKEY, "SEMI_COLON", 0, ";", ""},
257 {PERIODKEY, "PERIOD", 0, ".", ""},
258 {COMMAKEY, "COMMA", 0, ",", ""},
259 {QUOTEKEY, "QUOTE", 0, "\"", ""},
260 {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "`", ""},
261 {MINUSKEY, "MINUS", 0, "-", ""},
262 {SLASHKEY, "SLASH", 0, "/", ""},
263 {BACKSLASHKEY, "BACK_SLASH", 0, "\\", ""},
264 {EQUALKEY, "EQUAL", 0, "=", ""},
265 {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""},
266 {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""},
267 {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""},
268 {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""},
269 {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""},
270 {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", ""},
271 {PAD2, "NUMPAD_2", 0, "Numpad 2", ""},
272 {PAD4, "NUMPAD_4", 0, "Numpad 4", ""},
273 {PAD6, "NUMPAD_6", 0, "Numpad 6", ""},
274 {PAD8, "NUMPAD_8", 0, "Numpad 8", ""},
275 {PAD1, "NUMPAD_1", 0, "Numpad 1", ""},
276 {PAD3, "NUMPAD_3", 0, "Numpad 3", ""},
277 {PAD5, "NUMPAD_5", 0, "Numpad 5", ""},
278 {PAD7, "NUMPAD_7", 0, "Numpad 7", ""},
279 {PAD9, "NUMPAD_9", 0, "Numpad 9", ""},
280 {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", ""},
281 {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", ""},
282 {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", ""},
283 {PAD0, "NUMPAD_0", 0, "Numpad 0", ""},
284 {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", ""},
285 {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", ""},
286 {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", ""},
287 {F1KEY, "F1", 0, "F1", ""},
288 {F2KEY, "F2", 0, "F2", ""},
289 {F3KEY, "F3", 0, "F3", ""},
290 {F4KEY, "F4", 0, "F4", ""},
291 {F5KEY, "F5", 0, "F5", ""},
292 {F6KEY, "F6", 0, "F6", ""},
293 {F7KEY, "F7", 0, "F7", ""},
294 {F8KEY, "F8", 0, "F8", ""},
295 {F9KEY, "F9", 0, "F9", ""},
296 {F10KEY, "F10", 0, "F10", ""},
297 {F11KEY, "F11", 0, "F11", ""},
298 {F12KEY, "F12", 0, "F12", ""},
299 {F13KEY, "F13", 0, "F13", ""},
300 {F14KEY, "F14", 0, "F14", ""},
301 {F15KEY, "F15", 0, "F15", ""},
302 {F16KEY, "F16", 0, "F16", ""},
303 {F17KEY, "F17", 0, "F17", ""},
304 {F18KEY, "F18", 0, "F18", ""},
305 {F19KEY, "F19", 0, "F19", ""},
306 {PAUSEKEY, "PAUSE", 0, "Pause", ""},
307 {INSERTKEY, "INSERT", 0, "Insert", ""},
308 {HOMEKEY, "HOME", 0, "Home", ""},
309 {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""},
310 {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
311 {ENDKEY, "END", 0, "End", ""},
312 {0, "", 0, NULL, NULL},
313 {MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ""},
314 {MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", ""},
315 {MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", ""},
316 {MEDIALAST, "MEDIA_LAST", 0, "Media Last", ""},
317 {0, "", 0, NULL, NULL},
318 {WINDEACTIVATE, "WINDOW_DEACTIVATE", 0, "Window Deactivate", ""},
319 {TIMER, "TIMER", 0, "Timer", ""},
320 {TIMER0, "TIMER0", 0, "Timer 0", ""},
321 {TIMER1, "TIMER1", 0, "Timer 1", ""},
322 {TIMER2, "TIMER2", 0, "Timer 2", ""},
323 {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", ""},
324 {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", ""},
325 {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", ""},
326 {0, "", 0, NULL, NULL},
327 {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", ""},
328 /* buttons on all 3dconnexion devices */
329 {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", ""},
330 {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", ""},
332 {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", ""},
333 {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "NDOF Bottom", ""},
334 {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", ""},
335 {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "NDOF Right", ""},
336 {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", ""},
337 {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", ""},
339 {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "NDOF Isometric 1", ""},
340 {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "NDOF Isometric 2", ""},
341 /* 90 degree rotations */
342 {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "NDOF Roll CW", ""},
343 {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "NDOF Roll CCW", ""},
344 {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "NDOF Spin CW", ""},
345 {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "NDOF Spin CCW", ""},
346 {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "NDOF Tilt CW", ""},
347 {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "NDOF Tilt CCW", ""},
349 {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "NDOF Rotate", ""},
350 {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "NDOF Pan/Zoom", ""},
351 {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "NDOF Dominant", ""},
352 {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "NDOF Plus", ""},
353 {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "NDOF Minus", ""},
354 /* keyboard emulation */
355 {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "NDOF Esc"},
356 {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "NDOF Alt"},
357 {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "NDOF Shift"},
358 {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "NDOF Ctrl"},
359 /* general-purpose buttons */
360 {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "NDOF Button 1", ""},
361 {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "NDOF Button 2", ""},
362 {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "NDOF Button 3", ""},
363 {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "NDOF Button 4", ""},
364 {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "NDOF Button 5", ""},
365 {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "NDOF Button 6", ""},
366 {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "NDOF Button 7", ""},
367 {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "NDOF Button 8", ""},
368 {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "NDOF Button 9", ""},
369 {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "NDOF Button 10", ""},
370 {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "NDOF Button A", ""},
371 {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", ""},
372 {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", ""},
373 {0, NULL, 0, NULL, NULL}
376 EnumPropertyItem keymap_propvalue_items[] = {
377 {0, "NONE", 0, "", ""},
378 {0, NULL, 0, NULL, NULL}
382 static EnumPropertyItem keymap_modifiers_items[] = {
383 {KM_ANY, "ANY", 0, "Any", ""},
384 {0, "NONE", 0, "None", ""},
385 {1, "FIRST", 0, "First", ""},
386 {2, "SECOND", 0, "Second", ""},
387 {0, NULL, 0, NULL, NULL}
391 EnumPropertyItem operator_flag_items[] = {
392 {OPTYPE_REGISTER, "REGISTER", 0, "Register", "Display in the info window and support the redo toolbar panel"},
393 {OPTYPE_UNDO, "UNDO", 0, "Undo", "Push an undo event (needed for operator redo)"},
394 {OPTYPE_BLOCKING, "BLOCKING", 0, "Blocking", "Block anything else from using the cursor"},
395 {OPTYPE_MACRO, "MACRO", 0, "Macro", "Use to check if an operator is a macro"},
396 {OPTYPE_GRAB_POINTER, "GRAB_POINTER", 0, "Grab Pointer",
397 "Use so the operator grabs the mouse focus, enables wrapping when continuous grab "
399 {OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"},
400 {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"},
401 {0, NULL, 0, NULL, NULL}
404 EnumPropertyItem operator_return_items[] = {
405 {OPERATOR_RUNNING_MODAL, "RUNNING_MODAL", 0, "Running Modal", "Keep the operator running with blender"},
406 {OPERATOR_CANCELLED, "CANCELLED", 0, "Cancelled", "When no action has been taken, operator exits"},
407 {OPERATOR_FINISHED, "FINISHED", 0, "Finished", "When the operator is complete, operator exits"},
409 {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"},
410 {0, NULL, 0, NULL, NULL}
414 EnumPropertyItem wm_report_items[] = {
415 {RPT_DEBUG, "DEBUG", 0, "Debug", ""},
416 {RPT_INFO, "INFO", 0, "Info", ""},
417 {RPT_OPERATOR, "OPERATOR", 0, "Operator", ""},
418 {RPT_WARNING, "WARNING", 0, "Warning", ""},
419 {RPT_ERROR, "ERROR", 0, "Error", ""},
420 {RPT_ERROR_INVALID_INPUT, "ERROR_INVALID_INPUT", 0, "Invalid Input", ""},
421 {RPT_ERROR_INVALID_CONTEXT, "ERROR_INVALID_CONTEXT", 0, "Invalid Context", ""},
422 {RPT_ERROR_OUT_OF_MEMORY, "ERROR_OUT_OF_MEMORY", 0, "Out of Memory", ""},
423 {0, NULL, 0, NULL, NULL}
426 #define KMI_TYPE_KEYBOARD 0
427 #define KMI_TYPE_MOUSE 1
428 #define KMI_TYPE_TWEAK 2
429 #define KMI_TYPE_TEXTINPUT 3
430 #define KMI_TYPE_TIMER 4
431 #define KMI_TYPE_NDOF 5
439 #include "BKE_idprop.h"
441 #include "MEM_guardedalloc.h"
443 #include "IMB_colormanagement.h"
445 static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
447 wmWindowManager *wm = ptr->id.data;
448 IDProperty *properties = (IDProperty *)ptr->data;
452 for (op = wm->operators.first; op; op = op->next)
453 if (op->properties == properties)
459 static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr)
461 wmOperator *op = rna_OperatorProperties_find_operator(ptr);
464 return op->type->srna;
469 static IDProperty *rna_OperatorProperties_idprops(PointerRNA *ptr, int create)
471 if (create && !ptr->data) {
472 IDPropertyTemplate val = {0};
473 ptr->data = IDP_New(IDP_GROUP, &val, "RNA_OperatorProperties group");
479 static void rna_Operator_name_get(PointerRNA *ptr, char *value)
481 wmOperator *op = (wmOperator *)ptr->data;
482 strcpy(value, op->type->name);
485 static int rna_Operator_name_length(PointerRNA *ptr)
487 wmOperator *op = (wmOperator *)ptr->data;
488 return strlen(op->type->name);
491 static int rna_Operator_has_reports_get(PointerRNA *ptr)
493 wmOperator *op = (wmOperator *)ptr->data;
494 return (op->reports && op->reports->list.first);
497 static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
499 wmOperator *op = (wmOperator *)ptr->data;
500 return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties);
503 static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
505 wmOperatorTypeMacro *otmacro = (wmOperatorTypeMacro *)ptr->data;
506 wmOperatorType *ot = WM_operatortype_find(otmacro->idname, TRUE);
507 return rna_pointer_inherit_refine(ptr, ot->srna, otmacro->properties);
510 static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
512 wmEvent *event = (wmEvent *)ptr->data;
513 value[0] = event->ascii;
517 static int rna_Event_ascii_length(PointerRNA *ptr)
519 wmEvent *event = (wmEvent *)ptr->data;
520 return (event->ascii) ? 1 : 0;
523 static void rna_Event_unicode_get(PointerRNA *ptr, char *value)
525 /* utf8 buf isn't \0 terminated */
526 wmEvent *event = (wmEvent *)ptr->data;
529 if (event->utf8_buf[0]) {
530 BLI_str_utf8_as_unicode_and_size(event->utf8_buf, &len);
532 memcpy(value, event->utf8_buf, len);
539 static int rna_Event_unicode_length(PointerRNA *ptr)
542 wmEvent *event = (wmEvent *)ptr->data;
543 if (event->utf8_buf[0]) {
544 /* invalid value is checked on assignment so we don't need to account for this */
545 return BLI_str_utf8_size(event->utf8_buf);
552 static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
554 wmWindow *win = (wmWindow *)ptr->data;
556 if (value.data == NULL)
559 /* exception: can't set screens inside of area/region handers */
560 win->newscreen = value.data;
563 static void rna_Window_screen_update(bContext *C, PointerRNA *ptr)
565 wmWindow *win = (wmWindow *)ptr->data;
567 /* exception: can't set screens inside of area/region handers, and must
568 * use context so notifier gets to the right window */
569 if (win->newscreen) {
570 WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, win->newscreen);
571 win->newscreen = NULL;
575 static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
577 wmKeyMapItem *kmi = ptr->data;
582 /*return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); */
583 return PointerRNA_NULL;
586 static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
588 wmKeyMapItem *kmi = ptr->data;
590 if (ISTIMER(kmi->type)) return KMI_TYPE_TIMER;
591 if (ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD;
592 if (ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK;
593 if (ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE;
594 if (ISNDOF(kmi->type)) return KMI_TYPE_NDOF;
595 if (kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT;
596 return KMI_TYPE_KEYBOARD;
599 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
601 wmKeyMapItem *kmi = ptr->data;
602 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
604 if (value != map_type) {
606 case KMI_TYPE_KEYBOARD:
611 kmi->type = EVT_TWEAK_L;
615 kmi->type = LEFTMOUSE;
618 case KMI_TYPE_TEXTINPUT:
619 kmi->type = KM_TEXTINPUT;
620 kmi->val = KM_NOTHING;
624 kmi->val = KM_NOTHING;
627 kmi->type = NDOF_BUTTON_MENU;
634 static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
637 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
639 if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
640 if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
641 if (map_type == KMI_TYPE_TIMER) return event_timer_type_items;
642 if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items;
643 else return event_type_items;
646 static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
649 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
651 if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF)
652 return event_keymouse_value_items;
653 if (map_type == KMI_TYPE_TWEAK)
654 return event_tweak_value_items;
656 return event_value_items;
659 static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop),
662 wmWindowManager *wm = CTX_wm_manager(C);
666 for (kc = wm->keyconfigs.first; kc; kc = kc->next) {
667 for (km = kc->keymaps.first; km; km = km->next) {
668 /* only check if it's a modal keymap */
669 if (km->modal_items) {
671 for (kmi = km->items.first; kmi; kmi = kmi->next) {
672 if (kmi == ptr->data) {
673 return km->modal_items;
681 return keymap_propvalue_items; /* ERROR */
684 static int rna_KeyMapItem_any_getf(PointerRNA *ptr)
686 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
688 if (kmi->shift == KM_ANY &&
689 kmi->ctrl == KM_ANY &&
690 kmi->alt == KM_ANY &&
691 kmi->oskey == KM_ANY)
700 static void rna_KeyMapItem_any_setf(PointerRNA *ptr, int value)
702 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
705 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
708 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = 0;
713 static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
715 wmWindowManager *wm = ptr->data;
718 for (kc = wm->keyconfigs.first; kc; kc = kc->next)
719 if (strcmp(kc->idname, U.keyconfigstr) == 0)
723 kc = wm->defaultconf;
725 return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
728 static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
730 wmWindowManager *wm = ptr->data;
731 wmKeyConfig *kc = value.data;
734 WM_keyconfig_set_active(wm, kc->idname);
737 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
739 wmKeyMapItem *kmi = ptr->data;
740 WM_operator_py_idname(value, kmi->idname);
743 static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
745 wmKeyMapItem *kmi = ptr->data;
746 char pyname[OP_MAX_TYPENAME];
748 WM_operator_py_idname(pyname, kmi->idname);
749 return strlen(pyname);
752 static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
754 wmKeyMapItem *kmi = ptr->data;
755 char idname[OP_MAX_TYPENAME];
757 WM_operator_bl_idname(idname, value);
759 if (strcmp(idname, kmi->idname) != 0) {
760 BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
762 WM_keymap_properties_reset(kmi, NULL);
766 static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
768 wmKeyMapItem *kmi = ptr->data;
769 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
770 strcpy(value, ot ? ot->name : kmi->idname);
773 static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
775 wmKeyMapItem *kmi = ptr->data;
776 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
777 return strlen(ot ? ot->name : kmi->idname);
780 static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
782 wmKeyMapItem *kmi = ptr->data;
786 static void rna_wmClipboard_get(PointerRNA *UNUSED(ptr), char *value)
790 pbuf = WM_clipboard_text_get(FALSE);
800 static int rna_wmClipboard_length(PointerRNA *UNUSED(ptr))
805 pbuf = WM_clipboard_text_get(FALSE);
807 length = strlen(pbuf);
818 static void rna_wmClipboard_set(PointerRNA *UNUSED(ptr), const char *value)
820 WM_clipboard_text_set((void *) value, FALSE);
824 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
827 wmOperatorType *ot = RNA_struct_blender_type_get(type);
833 /* update while blender is running */
834 wm = bmain->wm.first;
836 WM_operator_stack_clear(wm);
837 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
839 RNA_struct_free_extension(type, &ot->ext);
842 WM_operatortype_remove(ot->idname);
843 MEM_freeN((void *)idname);
845 /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
846 RNA_struct_free(&BLENDER_RNA, type);
849 static int operator_poll(bContext *C, wmOperatorType *ot)
851 extern FunctionRNA rna_Operator_poll_func;
859 RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */
860 func = &rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
862 RNA_parameter_list_create(&list, &ptr, func);
863 RNA_parameter_set_lookup(&list, "context", &C);
864 ot->ext.call(C, &ptr, func, &list);
866 RNA_parameter_get_lookup(&list, "visible", &ret);
867 visible = *(int *)ret;
869 RNA_parameter_list_free(&list);
874 static int operator_execute(bContext *C, wmOperator *op)
876 extern FunctionRNA rna_Operator_execute_func;
884 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
885 func = &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
887 RNA_parameter_list_create(&list, &opr, func);
888 RNA_parameter_set_lookup(&list, "context", &C);
889 op->type->ext.call(C, &opr, func, &list);
891 RNA_parameter_get_lookup(&list, "result", &ret);
892 result = *(int *)ret;
894 RNA_parameter_list_free(&list);
899 /* same as execute() but no return value */
900 static int operator_check(bContext *C, wmOperator *op)
902 extern FunctionRNA rna_Operator_check_func;
910 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
911 func = &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
913 RNA_parameter_list_create(&list, &opr, func);
914 RNA_parameter_set_lookup(&list, "context", &C);
915 op->type->ext.call(C, &opr, func, &list);
917 RNA_parameter_get_lookup(&list, "result", &ret);
918 result = *(int *)ret;
920 RNA_parameter_list_free(&list);
925 static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event)
927 extern FunctionRNA rna_Operator_invoke_func;
935 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
936 func = &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
938 RNA_parameter_list_create(&list, &opr, func);
939 RNA_parameter_set_lookup(&list, "context", &C);
940 RNA_parameter_set_lookup(&list, "event", &event);
941 op->type->ext.call(C, &opr, func, &list);
943 RNA_parameter_get_lookup(&list, "result", &ret);
944 result = *(int *)ret;
946 RNA_parameter_list_free(&list);
952 static int operator_modal(bContext *C, wmOperator *op, wmEvent *event)
954 extern FunctionRNA rna_Operator_modal_func;
962 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
963 func = &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
965 RNA_parameter_list_create(&list, &opr, func);
966 RNA_parameter_set_lookup(&list, "context", &C);
967 RNA_parameter_set_lookup(&list, "event", &event);
968 op->type->ext.call(C, &opr, func, &list);
970 RNA_parameter_get_lookup(&list, "result", &ret);
971 result = *(int *)ret;
973 RNA_parameter_list_free(&list);
978 static void operator_draw(bContext *C, wmOperator *op)
980 extern FunctionRNA rna_Operator_draw_func;
986 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
987 func = &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
989 RNA_parameter_list_create(&list, &opr, func);
990 RNA_parameter_set_lookup(&list, "context", &C);
991 op->type->ext.call(C, &opr, func, &list);
993 RNA_parameter_list_free(&list);
996 /* same as exec(), but call cancel */
997 static int operator_cancel(bContext *C, wmOperator *op)
999 extern FunctionRNA rna_Operator_cancel_func;
1007 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1008 func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
1010 RNA_parameter_list_create(&list, &opr, func);
1011 RNA_parameter_set_lookup(&list, "context", &C);
1012 op->type->ext.call(C, &opr, func, &list);
1014 RNA_parameter_get_lookup(&list, "result", &ret);
1015 result = *(int *)ret;
1017 RNA_parameter_list_free(&list);
1022 void operator_wrapper(wmOperatorType *ot, void *userdata);
1023 void macro_wrapper(wmOperatorType *ot, void *userdata);
1025 static char _operator_idname[OP_MAX_TYPENAME];
1026 static char _operator_name[OP_MAX_TYPENAME];
1027 static char _operator_descr[RNA_DYN_DESCR_MAX];
1028 static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
1029 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1031 wmOperatorType dummyot = {NULL};
1032 wmOperator dummyop = {NULL};
1033 PointerRNA dummyotr;
1034 int have_function[7];
1036 /* setup dummy operator & operator type to store static properties in */
1037 dummyop.type = &dummyot;
1038 dummyot.idname = _operator_idname; /* only assigne the pointer, string is NULL'd */
1039 dummyot.name = _operator_name; /* only assigne the pointer, string is NULL'd */
1040 dummyot.description = _operator_descr; /* only assigne the pointer, string is NULL'd */
1041 RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
1043 /* clear in case they are left unset */
1044 _operator_idname[0] = _operator_name[0] = _operator_descr[0] = '\0';
1046 /* validate the python class */
1047 if (validate(&dummyotr, data, have_function) != 0)
1050 { /* convert foo.bar to FOO_OT_bar
1051 * allocate the description and the idname in 1 go */
1053 /* inconveniently long name sanity check */
1055 char *ch = _operator_idname;
1058 for (i = 0; *ch; i++) {
1059 if ((*ch >= 'a' && *ch <= 'z') || (*ch >= '0' && *ch <= '9') || *ch == '_') {
1062 else if (*ch == '.') {
1066 BKE_reportf(reports, RPT_ERROR,
1067 "registering operator class: '%s', invalid bl_idname '%s', at position %d",
1068 identifier, _operator_idname, i);
1075 if (i > ((int)sizeof(dummyop.idname)) - 3) {
1076 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', "
1077 "is too long, maximum length is %d", identifier, _operator_idname,
1078 (int)sizeof(dummyop.idname) - 3);
1083 BKE_reportf(reports, RPT_ERROR,
1084 "registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
1085 identifier, _operator_idname);
1089 /* end sanity check */
1092 int idlen = strlen(_operator_idname) + 4;
1093 int namelen = strlen(_operator_name) + 1;
1094 int desclen = strlen(_operator_descr) + 1;
1096 /* 2 terminators and 3 to convert a.b -> A_OT_b */
1097 ch = MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname");
1098 WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
1099 dummyot.idname = ch;
1101 strcpy(ch, _operator_name);
1104 strcpy(ch, _operator_descr);
1105 dummyot.description = ch;
1109 /* check if we have registered this operator type before, and remove it */
1111 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, TRUE);
1112 if (ot && ot->ext.srna)
1113 rna_Operator_unregister(bmain, ot->ext.srna);
1116 /* XXX, this doubles up with the operator name [#29666]
1117 * for now just remove from dir(bpy.types) */
1119 /* create a new operator type */
1120 dummyot.ext.srna = RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
1121 RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
1122 dummyot.ext.data = data;
1123 dummyot.ext.call = call;
1124 dummyot.ext.free = free;
1126 dummyot.pyop_poll = (have_function[0]) ? operator_poll : NULL;
1127 dummyot.exec = (have_function[1]) ? operator_execute : NULL;
1128 dummyot.check = (have_function[2]) ? operator_check : NULL;
1129 dummyot.invoke = (have_function[3]) ? operator_invoke : NULL;
1130 dummyot.modal = (have_function[4]) ? operator_modal : NULL;
1131 dummyot.ui = (have_function[5]) ? operator_draw : NULL;
1132 dummyot.cancel = (have_function[6]) ? operator_cancel : NULL;
1133 WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
1135 /* update while blender is running */
1136 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1138 return dummyot.ext.srna;
1141 void **rna_Operator_instance(PointerRNA *ptr)
1143 wmOperator *op = ptr->data;
1144 return &op->py_instance;
1147 static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
1148 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1150 wmOperatorType dummyot = {NULL};
1151 wmOperator dummyop = {NULL};
1152 PointerRNA dummyotr;
1153 int have_function[4];
1155 /* setup dummy operator & operator type to store static properties in */
1156 dummyop.type = &dummyot;
1157 dummyot.idname = _operator_idname; /* only assigne the pointer, string is NULL'd */
1158 dummyot.name = _operator_name; /* only assigne the pointer, string is NULL'd */
1159 dummyot.description = _operator_descr; /* only assigne the pointer, string is NULL'd */
1160 RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr);
1162 /* validate the python class */
1163 if (validate(&dummyotr, data, have_function) != 0)
1166 { /* convert foo.bar to FOO_OT_bar
1167 * allocate the description and the idname in 1 go */
1168 int idlen = strlen(_operator_idname) + 4;
1169 int namelen = strlen(_operator_name) + 1;
1170 int desclen = strlen(_operator_descr) + 1;
1172 /* 2 terminators and 3 to convert a.b -> A_OT_b */
1173 ch = MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname");
1174 WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
1175 dummyot.idname = ch;
1177 strcpy(ch, _operator_name);
1180 strcpy(ch, _operator_descr);
1181 dummyot.description = ch;
1184 if (strlen(identifier) >= sizeof(dummyop.idname)) {
1185 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d",
1186 identifier, (int)sizeof(dummyop.idname));
1190 /* check if we have registered this operator type before, and remove it */
1192 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, TRUE);
1193 if (ot && ot->ext.srna)
1194 rna_Operator_unregister(bmain, ot->ext.srna);
1197 /* XXX, this doubles up with the operator name [#29666]
1198 * for now just remove from dir(bpy.types) */
1200 /* create a new operator type */
1201 dummyot.ext.srna = RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
1202 dummyot.ext.data = data;
1203 dummyot.ext.call = call;
1204 dummyot.ext.free = free;
1206 dummyot.pyop_poll = (have_function[0]) ? operator_poll : NULL;
1207 dummyot.ui = (have_function[3]) ? operator_draw : NULL;
1209 WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot);
1211 /* update while blender is running */
1212 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1214 return dummyot.ext.srna;
1216 #endif /* WITH_PYTHON */
1218 static StructRNA *rna_Operator_refine(PointerRNA *opr)
1220 wmOperator *op = (wmOperator *)opr->data;
1221 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Operator;
1224 static StructRNA *rna_MacroOperator_refine(PointerRNA *opr)
1226 wmOperator *op = (wmOperator *)opr->data;
1227 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Macro;
1230 /* just to work around 'const char *' warning and to ensure this is a python op */
1231 static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
1233 wmOperator *data = (wmOperator *)(ptr->data);
1234 char *str = (char *)data->type->idname;
1235 if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1236 else assert(!"setting the bl_idname on a non-builtin operator");
1239 static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
1241 wmOperator *data = (wmOperator *)(ptr->data);
1242 char *str = (char *)data->type->name;
1243 if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1244 else assert(!"setting the bl_label on a non-builtin operator");
1247 static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
1249 wmOperator *data = (wmOperator *)(ptr->data);
1250 char *str = (char *)data->type->description;
1251 if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1252 else assert(!"setting the bl_description on a non-builtin operator");
1255 static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
1257 wmKeyMapItem *kmi = ptr->data;
1258 WM_keyconfig_update_tag(NULL, kmi);
1261 #else /* RNA_RUNTIME */
1263 static void rna_def_operator(BlenderRNA *brna)
1268 srna = RNA_def_struct(brna, "Operator", NULL);
1269 RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution");
1270 RNA_def_struct_sdna(srna, "wmOperator");
1271 RNA_def_struct_refine_func(srna, "rna_Operator_refine");
1273 RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
1276 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1277 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1278 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1279 RNA_def_property_ui_text(prop, "Name", "");
1281 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1282 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1283 RNA_def_property_struct_type(prop, "OperatorProperties");
1284 RNA_def_property_ui_text(prop, "Properties", "");
1285 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1287 prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
1288 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
1289 RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", NULL);
1290 RNA_def_property_ui_text(prop, "Has Reports",
1291 "Operator has a set of reports (warnings and errors) from last execution");
1293 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1294 RNA_def_property_struct_type(prop, "UILayout");
1297 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1298 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1299 /* else it uses the pointer size!. -3 because '.' -> '_OT_' */
1300 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME - 3);
1301 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1302 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1303 RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
1304 RNA_def_struct_name_property(srna, prop);
1306 /* operator's label indeed doesn't need PROP_TRANSLATE flag: translation of label happens in runtime
1307 * when drawing panel and having this flag set will make runtime switching of language much more tricky
1308 * because label will be stored translated */
1309 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1310 RNA_def_property_string_sdna(prop, NULL, "type->name");
1311 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1312 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1313 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1314 RNA_def_property_flag(prop, PROP_REGISTER);
1316 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
1317 RNA_def_property_string_sdna(prop, NULL, "type->description");
1318 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1319 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1320 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1321 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1322 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1324 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1325 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1326 RNA_def_property_enum_items(prop, operator_flag_items);
1327 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1328 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1330 RNA_api_operator(srna);
1332 srna = RNA_def_struct(brna, "OperatorProperties", NULL);
1333 RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator");
1334 RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
1335 RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops");
1338 static void rna_def_macro_operator(BlenderRNA *brna)
1343 srna = RNA_def_struct(brna, "Macro", NULL);
1344 RNA_def_struct_ui_text(srna, "Macro Operator",
1345 "Storage of a macro operator being executed, or registered after execution");
1346 RNA_def_struct_sdna(srna, "wmOperator");
1347 RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
1349 RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister",
1350 "rna_Operator_instance");
1353 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1354 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1355 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1356 RNA_def_property_ui_text(prop, "Name", "");
1358 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1359 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1360 RNA_def_property_struct_type(prop, "OperatorProperties");
1361 RNA_def_property_ui_text(prop, "Properties", "");
1362 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1365 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1366 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1367 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1368 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1369 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1370 RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
1371 RNA_def_struct_name_property(srna, prop);
1373 /* menu's label indeed doesn't need PROP_TRANSLATE flag: translation of label happens in runtime
1374 * when drawing panel and having this flag set will make runtime switching of language much more tricky
1375 * because label will be stored translated */
1376 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1377 RNA_def_property_string_sdna(prop, NULL, "type->name");
1378 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1379 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1380 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1381 RNA_def_property_flag(prop, PROP_REGISTER);
1383 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
1384 RNA_def_property_string_sdna(prop, NULL, "type->description");
1385 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1386 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1387 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1388 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1389 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1391 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1392 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1393 RNA_def_property_enum_items(prop, operator_flag_items);
1394 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1395 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1397 RNA_api_macro(srna);
1400 static void rna_def_operator_type_macro(BlenderRNA *brna)
1405 srna = RNA_def_struct(brna, "OperatorMacro", NULL);
1406 RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added");
1407 RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
1409 /* prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */
1410 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1411 /* RNA_def_property_string_sdna(prop, NULL, "idname"); */
1412 /* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */
1413 /* RNA_def_struct_name_property(srna, prop); */
1415 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1416 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1417 RNA_def_property_struct_type(prop, "OperatorProperties");
1418 RNA_def_property_ui_text(prop, "Properties", "");
1419 RNA_def_property_pointer_funcs(prop, "rna_OperatorMacro_properties_get", NULL, NULL, NULL);
1422 static void rna_def_operator_utils(BlenderRNA *brna)
1427 srna = RNA_def_struct(brna, "OperatorMousePath", "PropertyGroup");
1428 RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths");
1430 prop = RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
1431 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1432 RNA_def_property_array(prop, 2);
1433 RNA_def_property_ui_text(prop, "Location", "Mouse location");
1435 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
1436 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1437 RNA_def_property_ui_text(prop, "Time", "Time of mouse location");
1440 static void rna_def_operator_filelist_element(BlenderRNA *brna)
1445 srna = RNA_def_struct(brna, "OperatorFileListElement", "PropertyGroup");
1446 RNA_def_struct_ui_text(srna, "Operator File List Element", "");
1449 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
1450 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1451 RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list");
1454 static void rna_def_event(BlenderRNA *brna)
1459 srna = RNA_def_struct(brna, "Event", NULL);
1460 RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
1461 RNA_def_struct_sdna(srna, "wmEvent");
1463 RNA_define_verify_sdna(0); /* not in sdna */
1466 prop = RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
1467 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1468 RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
1469 RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
1472 prop = RNA_def_property(srna, "unicode", PROP_STRING, PROP_NONE);
1473 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1474 RNA_def_property_string_funcs(prop, "rna_Event_unicode_get", "rna_Event_unicode_length", NULL);
1475 RNA_def_property_ui_text(prop, "Unicode", "Single unicode character for this event");
1478 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1479 RNA_def_property_enum_sdna(prop, NULL, "val");
1480 RNA_def_property_enum_items(prop, event_value_items);
1481 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1482 RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
1484 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1485 RNA_def_property_enum_sdna(prop, NULL, "type");
1486 RNA_def_property_enum_items(prop, event_type_items);
1487 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1488 RNA_def_property_ui_text(prop, "Type", "");
1492 prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
1493 RNA_def_property_int_sdna(prop, NULL, "x");
1494 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1495 RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse");
1497 prop = RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
1498 RNA_def_property_int_sdna(prop, NULL, "y");
1499 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1500 RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse");
1502 prop = RNA_def_property(srna, "mouse_region_x", PROP_INT, PROP_NONE);
1503 RNA_def_property_int_sdna(prop, NULL, "mval[0]");
1504 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1505 RNA_def_property_ui_text(prop, "Mouse X Position", "The region relative vertical location of the mouse");
1507 prop = RNA_def_property(srna, "mouse_region_y", PROP_INT, PROP_NONE);
1508 RNA_def_property_int_sdna(prop, NULL, "mval[1]");
1509 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1510 RNA_def_property_ui_text(prop, "Mouse Y Position", "The region relative horizontal location of the mouse");
1512 prop = RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
1513 RNA_def_property_int_sdna(prop, NULL, "prevx");
1514 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1515 RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse");
1517 prop = RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
1518 RNA_def_property_int_sdna(prop, NULL, "prevy");
1519 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1520 RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse");
1524 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1525 RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
1526 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1527 RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
1529 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1530 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
1531 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1532 RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
1534 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1535 RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
1536 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1537 RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
1539 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1540 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
1541 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1542 RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held");
1544 RNA_define_verify_sdna(1); /* not in sdna */
1547 static void rna_def_timer(BlenderRNA *brna)
1552 srna = RNA_def_struct(brna, "Timer", NULL);
1553 RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
1554 RNA_def_struct_sdna(srna, "wmTimer");
1556 RNA_define_verify_sdna(0); /* not in sdna */
1558 /* could wrap more, for now this is enough */
1559 prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
1560 RNA_def_property_float_sdna(prop, NULL, "timestep");
1561 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1562 RNA_def_property_ui_text(prop, "Time Step", "");
1564 prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
1565 RNA_def_property_float_sdna(prop, NULL, "delta");
1566 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1567 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1569 prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
1570 RNA_def_property_float_sdna(prop, NULL, "duration");
1571 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1572 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1574 RNA_define_verify_sdna(1); /* not in sdna */
1577 static void rna_def_window(BlenderRNA *brna)
1582 srna = RNA_def_struct(brna, "Window", NULL);
1583 RNA_def_struct_ui_text(srna, "Window", "Open window");
1584 RNA_def_struct_sdna(srna, "wmWindow");
1586 prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
1587 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1588 RNA_def_property_struct_type(prop, "Screen");
1589 RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window");
1590 RNA_def_property_flag(prop, PROP_EDITABLE);
1591 RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, NULL);
1592 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1593 RNA_def_property_update(prop, 0, "rna_Window_screen_update");
1595 /* Color Management Display */
1596 prop = RNA_def_property(srna, "display_settings", PROP_POINTER, PROP_NONE);
1597 RNA_def_property_pointer_sdna(prop, NULL, "display_settings");
1598 RNA_def_property_struct_type(prop, "ColorManagedDisplaySettings");
1599 RNA_def_property_ui_text(prop, "Display Settings", "Display device settings used by this window");
1601 prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
1602 RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
1603 RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
1604 RNA_def_property_ui_text(prop, "View Settings", "Global color management settings used for displaying images on the display");
1608 static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
1613 RNA_def_property_srna(cprop, "KeyConfigurations");
1614 srna = RNA_def_struct(brna, "KeyConfigurations", NULL);
1615 RNA_def_struct_sdna(srna, "wmWindowManager");
1616 RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs");
1618 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1619 RNA_def_property_struct_type(prop, "KeyConfig");
1620 RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get",
1621 "rna_WindowManager_active_keyconfig_set", NULL, NULL);
1622 RNA_def_property_flag(prop, PROP_EDITABLE);
1623 RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
1625 prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
1626 RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
1627 RNA_def_property_struct_type(prop, "KeyConfig");
1628 RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
1630 prop = RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
1631 RNA_def_property_pointer_sdna(prop, NULL, "addonconf");
1632 RNA_def_property_struct_type(prop, "KeyConfig");
1633 RNA_def_property_ui_text(prop, "Addon Key Configuration",
1634 "Key configuration that can be extended by addons, and is added to the active "
1635 "configuration when handling events");
1637 prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
1638 RNA_def_property_pointer_sdna(prop, NULL, "userconf");
1639 RNA_def_property_struct_type(prop, "KeyConfig");
1640 RNA_def_property_ui_text(prop, "User Key Configuration",
1641 "Final key configuration that combines keymaps from the active and addon configurations, "
1642 "and can be edited by the user");
1644 RNA_api_keyconfigs(srna);
1647 static void rna_def_windowmanager(BlenderRNA *brna)
1652 srna = RNA_def_struct(brna, "WindowManager", "ID");
1653 RNA_def_struct_ui_text(srna, "Window Manager",
1654 "Window manager datablock defining open windows and other user interface data");
1655 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1656 RNA_def_struct_sdna(srna, "wmWindowManager");
1658 prop = RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
1659 RNA_def_property_struct_type(prop, "Operator");
1660 RNA_def_property_ui_text(prop, "Operators", "Operator registry");
1662 prop = RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
1663 RNA_def_property_struct_type(prop, "Window");
1664 RNA_def_property_ui_text(prop, "Windows", "Open windows");
1666 prop = RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
1667 RNA_def_property_struct_type(prop, "KeyConfig");
1668 RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations");
1669 rna_def_wm_keyconfigs(brna, prop);
1671 prop = RNA_def_property(srna, "clipboard", PROP_STRING, PROP_NONE);
1672 RNA_def_property_string_funcs(prop, "rna_wmClipboard_get", "rna_wmClipboard_length", "rna_wmClipboard_set");
1673 RNA_def_property_ui_text(prop, "Text Clipboard", "");
1678 /* keyconfig.items */
1679 static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
1683 RNA_def_property_srna(cprop, "KeyMapItems");
1684 srna = RNA_def_struct(brna, "KeyMapItems", NULL);
1685 RNA_def_struct_sdna(srna, "wmKeyMap");
1686 RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
1688 RNA_api_keymapitems(srna);
1691 static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
1695 RNA_def_property_srna(cprop, "KeyMaps");
1696 srna = RNA_def_struct(brna, "KeyMaps", NULL);
1697 RNA_def_struct_sdna(srna, "wmKeyConfig");
1698 RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
1700 RNA_api_keymaps(srna);
1703 static void rna_def_keyconfig(BlenderRNA *brna)
1708 static EnumPropertyItem map_type_items[] = {
1709 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
1710 {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
1711 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
1712 {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
1713 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
1714 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
1715 {0, NULL, 0, NULL, NULL}
1719 srna = RNA_def_struct(brna, "KeyConfig", NULL);
1720 RNA_def_struct_sdna(srna, "wmKeyConfig");
1721 RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps");
1723 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1724 RNA_def_property_string_sdna(prop, NULL, "idname");
1725 RNA_def_property_ui_text(prop, "Name", "Name of the key configuration");
1726 RNA_def_struct_name_property(srna, prop);
1728 prop = RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
1729 RNA_def_property_struct_type(prop, "KeyMap");
1730 RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration");
1731 rna_def_wm_keymaps(brna, prop);
1733 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
1734 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYCONF_USER);
1735 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1736 RNA_def_property_ui_text(prop, "User Defined", "Indicates that a keyconfig was defined by the user");
1738 RNA_api_keyconfig(srna);
1741 srna = RNA_def_struct(brna, "KeyMap", NULL);
1742 RNA_def_struct_sdna(srna, "wmKeyMap");
1743 RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps");
1745 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1746 RNA_def_property_string_sdna(prop, NULL, "idname");
1747 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1748 RNA_def_property_ui_text(prop, "Name", "Name of the key map");
1749 RNA_def_struct_name_property(srna, prop);
1751 prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
1752 RNA_def_property_enum_sdna(prop, NULL, "spaceid");
1753 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1754 RNA_def_property_enum_items(prop, space_type_items);
1755 RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with");
1757 prop = RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
1758 RNA_def_property_enum_sdna(prop, NULL, "regionid");
1759 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1760 RNA_def_property_enum_items(prop, region_type_items);
1761 RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with");
1763 prop = RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE);
1764 RNA_def_property_collection_sdna(prop, NULL, "items", NULL);
1765 RNA_def_property_struct_type(prop, "KeyMapItem");
1766 RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event");
1767 rna_def_keymap_items(brna, prop);
1769 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
1770 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER_MODIFIED);
1771 RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
1773 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1774 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_MODAL);
1775 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1776 RNA_def_property_ui_text(prop, "Modal Keymap",
1777 "Indicates that a keymap is used for translate modal events for an operator");
1779 prop = RNA_def_property(srna, "show_expanded_items", PROP_BOOLEAN, PROP_NONE);
1780 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_EXPANDED);
1781 RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
1782 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1784 prop = RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
1785 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_CHILDREN_EXPANDED);
1786 RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
1787 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1790 RNA_api_keymap(srna);
1793 srna = RNA_def_struct(brna, "KeyMapItem", NULL);
1794 RNA_def_struct_sdna(srna, "wmKeyMapItem");
1795 RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map");
1797 prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
1798 RNA_def_property_string_sdna(prop, NULL, "idname");
1799 RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
1800 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length",
1801 "rna_wmKeyMapItem_idname_set");
1802 RNA_def_struct_name_property(srna, prop);
1803 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1805 /* this is in fact the operator name, but if the operator can't be found we
1806 * fallback on the operator ID */
1807 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1808 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1809 RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event");
1810 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
1812 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1813 RNA_def_property_struct_type(prop, "OperatorProperties");
1814 RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
1815 RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
1816 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1818 prop = RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
1819 RNA_def_property_enum_sdna(prop, NULL, "maptype");
1820 RNA_def_property_enum_items(prop, map_type_items);
1821 RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
1822 RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
1823 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1825 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1826 RNA_def_property_enum_sdna(prop, NULL, "type");
1827 RNA_def_property_enum_items(prop, event_type_items);
1828 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
1829 RNA_def_property_ui_text(prop, "Type", "Type of event");
1830 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1832 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1833 RNA_def_property_enum_sdna(prop, NULL, "val");
1834 RNA_def_property_enum_items(prop, event_value_items);
1835 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
1836 RNA_def_property_ui_text(prop, "Value", "");
1837 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1839 prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
1840 RNA_def_property_int_sdna(prop, NULL, "id");
1841 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1842 RNA_def_property_ui_text(prop, "ID", "ID of the item");
1843 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1845 prop = RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
1846 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_getf", "rna_KeyMapItem_any_setf");
1847 RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
1848 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1850 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1851 RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
1852 /* RNA_def_property_enum_sdna(prop, NULL, "shift"); */
1853 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1854 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
1855 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1857 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1858 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
1859 /* RNA_def_property_enum_sdna(prop, NULL, "ctrl"); */
1860 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1861 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
1862 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1864 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1865 RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
1866 /* RNA_def_property_enum_sdna(prop, NULL, "alt"); */
1867 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1868 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
1869 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1871 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1872 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
1873 /* RNA_def_property_enum_sdna(prop, NULL, "oskey"); */
1874 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1875 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
1876 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1878 prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
1879 RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
1880 RNA_def_property_enum_items(prop, event_type_items);
1881 RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
1882 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1884 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1885 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
1886 RNA_def_property_ui_text(prop, "Expanded", "Show key map event and property details in the user interface");
1887 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1888 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1890 prop = RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
1891 RNA_def_property_enum_sdna(prop, NULL, "propvalue");
1892 RNA_def_property_enum_items(prop, keymap_propvalue_items);
1893 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
1894 RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap");
1895 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1897 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1898 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
1899 RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
1900 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
1901 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1903 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
1904 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_USER_MODIFIED);
1905 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1906 RNA_def_property_ui_text(prop, "User Modified", "Is this keymap item modified by the user");
1908 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
1909 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1910 RNA_def_property_ui_text(prop, "User Defined",
1911 "Is this keymap item user defined (doesn't just replace a builtin item)");
1912 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", NULL);
1914 RNA_api_keymapitem(srna);
1917 void RNA_def_wm(BlenderRNA *brna)
1919 rna_def_operator(brna);
1920 rna_def_operator_utils(brna);
1921 rna_def_operator_filelist_element(brna);
1922 rna_def_macro_operator(brna);
1923 rna_def_operator_type_macro(brna);
1924 rna_def_event(brna);
1925 rna_def_timer(brna);
1926 rna_def_window(brna);
1927 rna_def_windowmanager(brna);
1928 rna_def_keyconfig(brna);
1931 #endif /* RNA_RUNTIME */