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 int rna_Window_display_device_get(struct PointerRNA *ptr)
577 wmWindow *win = (wmWindow *) ptr->data;
579 return IMB_colormanagement_display_get_named_index(win->display_device);
582 static void rna_Window_display_device_set(struct PointerRNA *ptr, int value)
584 wmWindow *win = (wmWindow *) ptr->data;
585 const char *name = IMB_colormanagement_display_get_indexed_name(value);
588 BLI_strncpy(win->display_device, name, sizeof(win->display_device));
592 static EnumPropertyItem *rna_Window_display_device_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
594 EnumPropertyItem *items = NULL;
597 IMB_colormanagement_display_items_add(&items, &totitem);
598 RNA_enum_item_end(&items, &totitem);
605 static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
607 wmKeyMapItem *kmi = ptr->data;
612 /*return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); */
613 return PointerRNA_NULL;
616 static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
618 wmKeyMapItem *kmi = ptr->data;
620 if (ISTIMER(kmi->type)) return KMI_TYPE_TIMER;
621 if (ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD;
622 if (ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK;
623 if (ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE;
624 if (ISNDOF(kmi->type)) return KMI_TYPE_NDOF;
625 if (kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT;
626 return KMI_TYPE_KEYBOARD;
629 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
631 wmKeyMapItem *kmi = ptr->data;
632 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
634 if (value != map_type) {
636 case KMI_TYPE_KEYBOARD:
641 kmi->type = EVT_TWEAK_L;
645 kmi->type = LEFTMOUSE;
648 case KMI_TYPE_TEXTINPUT:
649 kmi->type = KM_TEXTINPUT;
650 kmi->val = KM_NOTHING;
654 kmi->val = KM_NOTHING;
657 kmi->type = NDOF_BUTTON_MENU;
664 static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
667 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
669 if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
670 if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
671 if (map_type == KMI_TYPE_TIMER) return event_timer_type_items;
672 if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items;
673 else return event_type_items;
676 static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
679 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
681 if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF)
682 return event_keymouse_value_items;
683 if (map_type == KMI_TYPE_TWEAK)
684 return event_tweak_value_items;
686 return event_value_items;
689 static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop),
692 wmWindowManager *wm = CTX_wm_manager(C);
696 for (kc = wm->keyconfigs.first; kc; kc = kc->next) {
697 for (km = kc->keymaps.first; km; km = km->next) {
698 /* only check if it's a modal keymap */
699 if (km->modal_items) {
701 for (kmi = km->items.first; kmi; kmi = kmi->next) {
702 if (kmi == ptr->data) {
703 return km->modal_items;
711 return keymap_propvalue_items; /* ERROR */
714 static int rna_KeyMapItem_any_getf(PointerRNA *ptr)
716 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
718 if (kmi->shift == KM_ANY &&
719 kmi->ctrl == KM_ANY &&
720 kmi->alt == KM_ANY &&
721 kmi->oskey == KM_ANY)
730 static void rna_KeyMapItem_any_setf(PointerRNA *ptr, int value)
732 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
735 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
738 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = 0;
743 static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
745 wmWindowManager *wm = ptr->data;
748 for (kc = wm->keyconfigs.first; kc; kc = kc->next)
749 if (strcmp(kc->idname, U.keyconfigstr) == 0)
753 kc = wm->defaultconf;
755 return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
758 static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
760 wmWindowManager *wm = ptr->data;
761 wmKeyConfig *kc = value.data;
764 WM_keyconfig_set_active(wm, kc->idname);
767 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
769 wmKeyMapItem *kmi = ptr->data;
770 WM_operator_py_idname(value, kmi->idname);
773 static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
775 wmKeyMapItem *kmi = ptr->data;
776 char pyname[OP_MAX_TYPENAME];
778 WM_operator_py_idname(pyname, kmi->idname);
779 return strlen(pyname);
782 static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
784 wmKeyMapItem *kmi = ptr->data;
785 char idname[OP_MAX_TYPENAME];
787 WM_operator_bl_idname(idname, value);
789 if (strcmp(idname, kmi->idname) != 0) {
790 BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
792 WM_keymap_properties_reset(kmi, NULL);
796 static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
798 wmKeyMapItem *kmi = ptr->data;
799 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
800 strcpy(value, ot ? ot->name : kmi->idname);
803 static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
805 wmKeyMapItem *kmi = ptr->data;
806 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
807 return strlen(ot ? ot->name : kmi->idname);
810 static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
812 wmKeyMapItem *kmi = ptr->data;
816 static void rna_wmClipboard_get(PointerRNA *UNUSED(ptr), char *value)
820 pbuf = WM_clipboard_text_get(FALSE);
830 static int rna_wmClipboard_length(PointerRNA *UNUSED(ptr))
835 pbuf = WM_clipboard_text_get(FALSE);
837 length = strlen(pbuf);
848 static void rna_wmClipboard_set(PointerRNA *UNUSED(ptr), const char *value)
850 WM_clipboard_text_set((void *) value, FALSE);
854 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
857 wmOperatorType *ot = RNA_struct_blender_type_get(type);
863 /* update while blender is running */
864 wm = bmain->wm.first;
866 WM_operator_stack_clear(wm);
867 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
869 RNA_struct_free_extension(type, &ot->ext);
872 WM_operatortype_remove(ot->idname);
873 MEM_freeN((void *)idname);
875 /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
876 RNA_struct_free(&BLENDER_RNA, type);
879 static int operator_poll(bContext *C, wmOperatorType *ot)
881 extern FunctionRNA rna_Operator_poll_func;
889 RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */
890 func = &rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
892 RNA_parameter_list_create(&list, &ptr, func);
893 RNA_parameter_set_lookup(&list, "context", &C);
894 ot->ext.call(C, &ptr, func, &list);
896 RNA_parameter_get_lookup(&list, "visible", &ret);
897 visible = *(int *)ret;
899 RNA_parameter_list_free(&list);
904 static int operator_execute(bContext *C, wmOperator *op)
906 extern FunctionRNA rna_Operator_execute_func;
914 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
915 func = &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
917 RNA_parameter_list_create(&list, &opr, func);
918 RNA_parameter_set_lookup(&list, "context", &C);
919 op->type->ext.call(C, &opr, func, &list);
921 RNA_parameter_get_lookup(&list, "result", &ret);
922 result = *(int *)ret;
924 RNA_parameter_list_free(&list);
929 /* same as execute() but no return value */
930 static int operator_check(bContext *C, wmOperator *op)
932 extern FunctionRNA rna_Operator_check_func;
940 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
941 func = &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
943 RNA_parameter_list_create(&list, &opr, func);
944 RNA_parameter_set_lookup(&list, "context", &C);
945 op->type->ext.call(C, &opr, func, &list);
947 RNA_parameter_get_lookup(&list, "result", &ret);
948 result = *(int *)ret;
950 RNA_parameter_list_free(&list);
955 static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event)
957 extern FunctionRNA rna_Operator_invoke_func;
965 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
966 func = &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
968 RNA_parameter_list_create(&list, &opr, func);
969 RNA_parameter_set_lookup(&list, "context", &C);
970 RNA_parameter_set_lookup(&list, "event", &event);
971 op->type->ext.call(C, &opr, func, &list);
973 RNA_parameter_get_lookup(&list, "result", &ret);
974 result = *(int *)ret;
976 RNA_parameter_list_free(&list);
982 static int operator_modal(bContext *C, wmOperator *op, wmEvent *event)
984 extern FunctionRNA rna_Operator_modal_func;
992 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
993 func = &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
995 RNA_parameter_list_create(&list, &opr, func);
996 RNA_parameter_set_lookup(&list, "context", &C);
997 RNA_parameter_set_lookup(&list, "event", &event);
998 op->type->ext.call(C, &opr, func, &list);
1000 RNA_parameter_get_lookup(&list, "result", &ret);
1001 result = *(int *)ret;
1003 RNA_parameter_list_free(&list);
1008 static void operator_draw(bContext *C, wmOperator *op)
1010 extern FunctionRNA rna_Operator_draw_func;
1016 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1017 func = &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
1019 RNA_parameter_list_create(&list, &opr, func);
1020 RNA_parameter_set_lookup(&list, "context", &C);
1021 op->type->ext.call(C, &opr, func, &list);
1023 RNA_parameter_list_free(&list);
1026 /* same as exec(), but call cancel */
1027 static int operator_cancel(bContext *C, wmOperator *op)
1029 extern FunctionRNA rna_Operator_cancel_func;
1037 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1038 func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
1040 RNA_parameter_list_create(&list, &opr, func);
1041 RNA_parameter_set_lookup(&list, "context", &C);
1042 op->type->ext.call(C, &opr, func, &list);
1044 RNA_parameter_get_lookup(&list, "result", &ret);
1045 result = *(int *)ret;
1047 RNA_parameter_list_free(&list);
1052 void operator_wrapper(wmOperatorType *ot, void *userdata);
1053 void macro_wrapper(wmOperatorType *ot, void *userdata);
1055 static char _operator_idname[OP_MAX_TYPENAME];
1056 static char _operator_name[OP_MAX_TYPENAME];
1057 static char _operator_descr[RNA_DYN_DESCR_MAX];
1058 static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
1059 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1061 wmOperatorType dummyot = {NULL};
1062 wmOperator dummyop = {NULL};
1063 PointerRNA dummyotr;
1064 int have_function[7];
1066 /* setup dummy operator & operator type to store static properties in */
1067 dummyop.type = &dummyot;
1068 dummyot.idname = _operator_idname; /* only assigne the pointer, string is NULL'd */
1069 dummyot.name = _operator_name; /* only assigne the pointer, string is NULL'd */
1070 dummyot.description = _operator_descr; /* only assigne the pointer, string is NULL'd */
1071 RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
1073 /* clear in case they are left unset */
1074 _operator_idname[0] = _operator_name[0] = _operator_descr[0] = '\0';
1076 /* validate the python class */
1077 if (validate(&dummyotr, data, have_function) != 0)
1080 { /* convert foo.bar to FOO_OT_bar
1081 * allocate the description and the idname in 1 go */
1083 /* inconveniently long name sanity check */
1085 char *ch = _operator_idname;
1088 for (i = 0; *ch; i++) {
1089 if ((*ch >= 'a' && *ch <= 'z') || (*ch >= '0' && *ch <= '9') || *ch == '_') {
1092 else if (*ch == '.') {
1096 BKE_reportf(reports, RPT_ERROR,
1097 "registering operator class: '%s', invalid bl_idname '%s', at position %d",
1098 identifier, _operator_idname, i);
1105 if (i > ((int)sizeof(dummyop.idname)) - 3) {
1106 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', "
1107 "is too long, maximum length is %d", identifier, _operator_idname,
1108 (int)sizeof(dummyop.idname) - 3);
1113 BKE_reportf(reports, RPT_ERROR,
1114 "registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character",
1115 identifier, _operator_idname);
1119 /* end sanity check */
1122 int idlen = strlen(_operator_idname) + 4;
1123 int namelen = strlen(_operator_name) + 1;
1124 int desclen = strlen(_operator_descr) + 1;
1126 /* 2 terminators and 3 to convert a.b -> A_OT_b */
1127 ch = MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname");
1128 WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
1129 dummyot.idname = ch;
1131 strcpy(ch, _operator_name);
1134 strcpy(ch, _operator_descr);
1135 dummyot.description = ch;
1139 /* check if we have registered this operator type before, and remove it */
1141 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, TRUE);
1142 if (ot && ot->ext.srna)
1143 rna_Operator_unregister(bmain, ot->ext.srna);
1146 /* XXX, this doubles up with the operator name [#29666]
1147 * for now just remove from dir(bpy.types) */
1149 /* create a new operator type */
1150 dummyot.ext.srna = RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
1151 RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
1152 dummyot.ext.data = data;
1153 dummyot.ext.call = call;
1154 dummyot.ext.free = free;
1156 dummyot.pyop_poll = (have_function[0]) ? operator_poll : NULL;
1157 dummyot.exec = (have_function[1]) ? operator_execute : NULL;
1158 dummyot.check = (have_function[2]) ? operator_check : NULL;
1159 dummyot.invoke = (have_function[3]) ? operator_invoke : NULL;
1160 dummyot.modal = (have_function[4]) ? operator_modal : NULL;
1161 dummyot.ui = (have_function[5]) ? operator_draw : NULL;
1162 dummyot.cancel = (have_function[6]) ? operator_cancel : NULL;
1163 WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
1165 /* update while blender is running */
1166 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1168 return dummyot.ext.srna;
1171 void **rna_Operator_instance(PointerRNA *ptr)
1173 wmOperator *op = ptr->data;
1174 return &op->py_instance;
1177 static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier,
1178 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1180 wmOperatorType dummyot = {NULL};
1181 wmOperator dummyop = {NULL};
1182 PointerRNA dummyotr;
1183 int have_function[4];
1185 /* setup dummy operator & operator type to store static properties in */
1186 dummyop.type = &dummyot;
1187 dummyot.idname = _operator_idname; /* only assigne the pointer, string is NULL'd */
1188 dummyot.name = _operator_name; /* only assigne the pointer, string is NULL'd */
1189 dummyot.description = _operator_descr; /* only assigne the pointer, string is NULL'd */
1190 RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr);
1192 /* validate the python class */
1193 if (validate(&dummyotr, data, have_function) != 0)
1196 { /* convert foo.bar to FOO_OT_bar
1197 * allocate the description and the idname in 1 go */
1198 int idlen = strlen(_operator_idname) + 4;
1199 int namelen = strlen(_operator_name) + 1;
1200 int desclen = strlen(_operator_descr) + 1;
1202 /* 2 terminators and 3 to convert a.b -> A_OT_b */
1203 ch = MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname");
1204 WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
1205 dummyot.idname = ch;
1207 strcpy(ch, _operator_name);
1210 strcpy(ch, _operator_descr);
1211 dummyot.description = ch;
1214 if (strlen(identifier) >= sizeof(dummyop.idname)) {
1215 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d",
1216 identifier, (int)sizeof(dummyop.idname));
1220 /* check if we have registered this operator type before, and remove it */
1222 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, TRUE);
1223 if (ot && ot->ext.srna)
1224 rna_Operator_unregister(bmain, ot->ext.srna);
1227 /* XXX, this doubles up with the operator name [#29666]
1228 * for now just remove from dir(bpy.types) */
1230 /* create a new operator type */
1231 dummyot.ext.srna = RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
1232 dummyot.ext.data = data;
1233 dummyot.ext.call = call;
1234 dummyot.ext.free = free;
1236 dummyot.pyop_poll = (have_function[0]) ? operator_poll : NULL;
1237 dummyot.ui = (have_function[3]) ? operator_draw : NULL;
1239 WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot);
1241 /* update while blender is running */
1242 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1244 return dummyot.ext.srna;
1246 #endif /* WITH_PYTHON */
1248 static StructRNA *rna_Operator_refine(PointerRNA *opr)
1250 wmOperator *op = (wmOperator *)opr->data;
1251 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Operator;
1254 static StructRNA *rna_MacroOperator_refine(PointerRNA *opr)
1256 wmOperator *op = (wmOperator *)opr->data;
1257 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Macro;
1260 /* just to work around 'const char *' warning and to ensure this is a python op */
1261 static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
1263 wmOperator *data = (wmOperator *)(ptr->data);
1264 char *str = (char *)data->type->idname;
1265 if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1266 else assert(!"setting the bl_idname on a non-builtin operator");
1269 static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
1271 wmOperator *data = (wmOperator *)(ptr->data);
1272 char *str = (char *)data->type->name;
1273 if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1274 else assert(!"setting the bl_label on a non-builtin operator");
1277 static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
1279 wmOperator *data = (wmOperator *)(ptr->data);
1280 char *str = (char *)data->type->description;
1281 if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1282 else assert(!"setting the bl_description on a non-builtin operator");
1285 static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
1287 wmKeyMapItem *kmi = ptr->data;
1288 WM_keyconfig_update_tag(NULL, kmi);
1291 #else /* RNA_RUNTIME */
1293 static void rna_def_operator(BlenderRNA *brna)
1298 srna = RNA_def_struct(brna, "Operator", NULL);
1299 RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution");
1300 RNA_def_struct_sdna(srna, "wmOperator");
1301 RNA_def_struct_refine_func(srna, "rna_Operator_refine");
1303 RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
1306 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1307 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1308 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1309 RNA_def_property_ui_text(prop, "Name", "");
1311 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1312 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1313 RNA_def_property_struct_type(prop, "OperatorProperties");
1314 RNA_def_property_ui_text(prop, "Properties", "");
1315 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1317 prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
1318 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
1319 RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", NULL);
1320 RNA_def_property_ui_text(prop, "Has Reports",
1321 "Operator has a set of reports (warnings and errors) from last execution");
1323 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1324 RNA_def_property_struct_type(prop, "UILayout");
1327 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1328 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1329 /* else it uses the pointer size!. -3 because '.' -> '_OT_' */
1330 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME - 3);
1331 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1332 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1333 RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
1334 RNA_def_struct_name_property(srna, prop);
1336 /* operator's label indeed doesn't need PROP_TRANSLATE flag: translation of label happens in runtime
1337 * when drawing panel and having this flag set will make runtime switching of language much more tricky
1338 * because label will be stored translated */
1339 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1340 RNA_def_property_string_sdna(prop, NULL, "type->name");
1341 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1342 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1343 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1344 RNA_def_property_flag(prop, PROP_REGISTER);
1346 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
1347 RNA_def_property_string_sdna(prop, NULL, "type->description");
1348 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1349 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1350 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1351 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1352 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1354 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1355 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1356 RNA_def_property_enum_items(prop, operator_flag_items);
1357 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1358 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1360 RNA_api_operator(srna);
1362 srna = RNA_def_struct(brna, "OperatorProperties", NULL);
1363 RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator");
1364 RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
1365 RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops");
1368 static void rna_def_macro_operator(BlenderRNA *brna)
1373 srna = RNA_def_struct(brna, "Macro", NULL);
1374 RNA_def_struct_ui_text(srna, "Macro Operator",
1375 "Storage of a macro operator being executed, or registered after execution");
1376 RNA_def_struct_sdna(srna, "wmOperator");
1377 RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
1379 RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister",
1380 "rna_Operator_instance");
1383 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1384 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1385 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1386 RNA_def_property_ui_text(prop, "Name", "");
1388 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1389 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1390 RNA_def_property_struct_type(prop, "OperatorProperties");
1391 RNA_def_property_ui_text(prop, "Properties", "");
1392 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1395 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1396 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1397 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1398 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1399 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1400 RNA_def_property_flag(prop, PROP_REGISTER | PROP_NEVER_CLAMP);
1401 RNA_def_struct_name_property(srna, prop);
1403 /* menu's label indeed doesn't need PROP_TRANSLATE flag: translation of label happens in runtime
1404 * when drawing panel and having this flag set will make runtime switching of language much more tricky
1405 * because label will be stored translated */
1406 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1407 RNA_def_property_string_sdna(prop, NULL, "type->name");
1408 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1409 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1410 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1411 RNA_def_property_flag(prop, PROP_REGISTER);
1413 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE);
1414 RNA_def_property_string_sdna(prop, NULL, "type->description");
1415 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1416 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1417 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1418 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1419 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1421 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1422 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1423 RNA_def_property_enum_items(prop, operator_flag_items);
1424 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1425 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1427 RNA_api_macro(srna);
1430 static void rna_def_operator_type_macro(BlenderRNA *brna)
1435 srna = RNA_def_struct(brna, "OperatorMacro", NULL);
1436 RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added");
1437 RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
1439 /* prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */
1440 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1441 /* RNA_def_property_string_sdna(prop, NULL, "idname"); */
1442 /* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */
1443 /* RNA_def_struct_name_property(srna, prop); */
1445 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1446 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1447 RNA_def_property_struct_type(prop, "OperatorProperties");
1448 RNA_def_property_ui_text(prop, "Properties", "");
1449 RNA_def_property_pointer_funcs(prop, "rna_OperatorMacro_properties_get", NULL, NULL, NULL);
1452 static void rna_def_operator_utils(BlenderRNA *brna)
1457 srna = RNA_def_struct(brna, "OperatorMousePath", "PropertyGroup");
1458 RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths");
1460 prop = RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
1461 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1462 RNA_def_property_array(prop, 2);
1463 RNA_def_property_ui_text(prop, "Location", "Mouse location");
1465 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
1466 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1467 RNA_def_property_ui_text(prop, "Time", "Time of mouse location");
1470 static void rna_def_operator_filelist_element(BlenderRNA *brna)
1475 srna = RNA_def_struct(brna, "OperatorFileListElement", "PropertyGroup");
1476 RNA_def_struct_ui_text(srna, "Operator File List Element", "");
1479 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
1480 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1481 RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list");
1484 static void rna_def_event(BlenderRNA *brna)
1489 srna = RNA_def_struct(brna, "Event", NULL);
1490 RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
1491 RNA_def_struct_sdna(srna, "wmEvent");
1493 RNA_define_verify_sdna(0); /* not in sdna */
1496 prop = RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
1497 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1498 RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
1499 RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
1502 prop = RNA_def_property(srna, "unicode", PROP_STRING, PROP_NONE);
1503 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1504 RNA_def_property_string_funcs(prop, "rna_Event_unicode_get", "rna_Event_unicode_length", NULL);
1505 RNA_def_property_ui_text(prop, "Unicode", "Single unicode character for this event");
1508 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1509 RNA_def_property_enum_sdna(prop, NULL, "val");
1510 RNA_def_property_enum_items(prop, event_value_items);
1511 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1512 RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
1514 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1515 RNA_def_property_enum_sdna(prop, NULL, "type");
1516 RNA_def_property_enum_items(prop, event_type_items);
1517 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1518 RNA_def_property_ui_text(prop, "Type", "");
1522 prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
1523 RNA_def_property_int_sdna(prop, NULL, "x");
1524 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1525 RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse");
1527 prop = RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
1528 RNA_def_property_int_sdna(prop, NULL, "y");
1529 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1530 RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse");
1532 prop = RNA_def_property(srna, "mouse_region_x", PROP_INT, PROP_NONE);
1533 RNA_def_property_int_sdna(prop, NULL, "mval[0]");
1534 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1535 RNA_def_property_ui_text(prop, "Mouse X Position", "The region relative vertical location of the mouse");
1537 prop = RNA_def_property(srna, "mouse_region_y", PROP_INT, PROP_NONE);
1538 RNA_def_property_int_sdna(prop, NULL, "mval[1]");
1539 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1540 RNA_def_property_ui_text(prop, "Mouse Y Position", "The region relative horizontal location of the mouse");
1542 prop = RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
1543 RNA_def_property_int_sdna(prop, NULL, "prevx");
1544 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1545 RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse");
1547 prop = RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
1548 RNA_def_property_int_sdna(prop, NULL, "prevy");
1549 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1550 RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse");
1554 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1555 RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
1556 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1557 RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
1559 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1560 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
1561 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1562 RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
1564 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1565 RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
1566 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1567 RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
1569 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1570 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
1571 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1572 RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held");
1574 RNA_define_verify_sdna(1); /* not in sdna */
1577 static void rna_def_timer(BlenderRNA *brna)
1582 srna = RNA_def_struct(brna, "Timer", NULL);
1583 RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
1584 RNA_def_struct_sdna(srna, "wmTimer");
1586 RNA_define_verify_sdna(0); /* not in sdna */
1588 /* could wrap more, for now this is enough */
1589 prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
1590 RNA_def_property_float_sdna(prop, NULL, "timestep");
1591 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1592 RNA_def_property_ui_text(prop, "Time Step", "");
1594 prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
1595 RNA_def_property_float_sdna(prop, NULL, "delta");
1596 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1597 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1599 prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
1600 RNA_def_property_float_sdna(prop, NULL, "duration");
1601 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1602 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1604 RNA_define_verify_sdna(1); /* not in sdna */
1607 static void rna_def_window(BlenderRNA *brna)
1612 static EnumPropertyItem display_device_items[] = {
1613 {0, "DEFAULT", 0, "Default", ""},
1614 {0, NULL, 0, NULL, NULL}
1617 srna = RNA_def_struct(brna, "Window", NULL);
1618 RNA_def_struct_ui_text(srna, "Window", "Open window");
1619 RNA_def_struct_sdna(srna, "wmWindow");
1621 prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
1622 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1623 RNA_def_property_struct_type(prop, "Screen");
1624 RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window");
1625 RNA_def_property_flag(prop, PROP_EDITABLE);
1626 RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, NULL);
1627 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1628 RNA_def_property_update(prop, 0, "rna_Window_screen_update");
1630 /* Color Management Display */
1631 prop= RNA_def_property(srna, "display_device", PROP_ENUM, PROP_NONE);
1632 RNA_def_property_enum_items(prop, display_device_items);
1633 RNA_def_property_enum_funcs(prop, "rna_Window_display_device_get", "rna_Window_display_device_set",
1634 "rna_Window_display_device_itemf");
1635 RNA_def_property_ui_text(prop, "Display Device", "Display device name used for this window");
1636 RNA_def_property_update(prop, NC_WINDOW, NULL);
1638 prop = RNA_def_property(srna, "view_settings", PROP_POINTER, PROP_NONE);
1639 RNA_def_property_pointer_sdna(prop, NULL, "view_settings");
1640 RNA_def_property_struct_type(prop, "ColorManagedViewSettings");
1641 RNA_def_property_ui_text(prop, "View Settings", "Global color management settings used for displaying images on the display");
1645 static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
1650 RNA_def_property_srna(cprop, "KeyConfigurations");
1651 srna = RNA_def_struct(brna, "KeyConfigurations", NULL);
1652 RNA_def_struct_sdna(srna, "wmWindowManager");
1653 RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs");
1655 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1656 RNA_def_property_struct_type(prop, "KeyConfig");
1657 RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get",
1658 "rna_WindowManager_active_keyconfig_set", NULL, NULL);
1659 RNA_def_property_flag(prop, PROP_EDITABLE);
1660 RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
1662 prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
1663 RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
1664 RNA_def_property_struct_type(prop, "KeyConfig");
1665 RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
1667 prop = RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
1668 RNA_def_property_pointer_sdna(prop, NULL, "addonconf");
1669 RNA_def_property_struct_type(prop, "KeyConfig");
1670 RNA_def_property_ui_text(prop, "Addon Key Configuration",
1671 "Key configuration that can be extended by addons, and is added to the active "
1672 "configuration when handling events");
1674 prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
1675 RNA_def_property_pointer_sdna(prop, NULL, "userconf");
1676 RNA_def_property_struct_type(prop, "KeyConfig");
1677 RNA_def_property_ui_text(prop, "User Key Configuration",
1678 "Final key configuration that combines keymaps from the active and addon configurations, "
1679 "and can be edited by the user");
1681 RNA_api_keyconfigs(srna);
1684 static void rna_def_windowmanager(BlenderRNA *brna)
1689 srna = RNA_def_struct(brna, "WindowManager", "ID");
1690 RNA_def_struct_ui_text(srna, "Window Manager",
1691 "Window manager datablock defining open windows and other user interface data");
1692 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1693 RNA_def_struct_sdna(srna, "wmWindowManager");
1695 prop = RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
1696 RNA_def_property_struct_type(prop, "Operator");
1697 RNA_def_property_ui_text(prop, "Operators", "Operator registry");
1699 prop = RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
1700 RNA_def_property_struct_type(prop, "Window");
1701 RNA_def_property_ui_text(prop, "Windows", "Open windows");
1703 prop = RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
1704 RNA_def_property_struct_type(prop, "KeyConfig");
1705 RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations");
1706 rna_def_wm_keyconfigs(brna, prop);
1708 prop = RNA_def_property(srna, "clipboard", PROP_STRING, PROP_NONE);
1709 RNA_def_property_string_funcs(prop, "rna_wmClipboard_get", "rna_wmClipboard_length", "rna_wmClipboard_set");
1710 RNA_def_property_ui_text(prop, "Text Clipboard", "");
1715 /* keyconfig.items */
1716 static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
1720 RNA_def_property_srna(cprop, "KeyMapItems");
1721 srna = RNA_def_struct(brna, "KeyMapItems", NULL);
1722 RNA_def_struct_sdna(srna, "wmKeyMap");
1723 RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
1725 RNA_api_keymapitems(srna);
1728 static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
1732 RNA_def_property_srna(cprop, "KeyMaps");
1733 srna = RNA_def_struct(brna, "KeyMaps", NULL);
1734 RNA_def_struct_sdna(srna, "wmKeyConfig");
1735 RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
1737 RNA_api_keymaps(srna);
1740 static void rna_def_keyconfig(BlenderRNA *brna)
1745 static EnumPropertyItem map_type_items[] = {
1746 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
1747 {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
1748 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
1749 {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
1750 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
1751 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
1752 {0, NULL, 0, NULL, NULL}
1756 srna = RNA_def_struct(brna, "KeyConfig", NULL);
1757 RNA_def_struct_sdna(srna, "wmKeyConfig");
1758 RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps");
1760 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1761 RNA_def_property_string_sdna(prop, NULL, "idname");
1762 RNA_def_property_ui_text(prop, "Name", "Name of the key configuration");
1763 RNA_def_struct_name_property(srna, prop);
1765 prop = RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
1766 RNA_def_property_struct_type(prop, "KeyMap");
1767 RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration");
1768 rna_def_wm_keymaps(brna, prop);
1770 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
1771 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYCONF_USER);
1772 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1773 RNA_def_property_ui_text(prop, "User Defined", "Indicates that a keyconfig was defined by the user");
1775 RNA_api_keyconfig(srna);
1778 srna = RNA_def_struct(brna, "KeyMap", NULL);
1779 RNA_def_struct_sdna(srna, "wmKeyMap");
1780 RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps");
1782 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1783 RNA_def_property_string_sdna(prop, NULL, "idname");
1784 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1785 RNA_def_property_ui_text(prop, "Name", "Name of the key map");
1786 RNA_def_struct_name_property(srna, prop);
1788 prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
1789 RNA_def_property_enum_sdna(prop, NULL, "spaceid");
1790 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1791 RNA_def_property_enum_items(prop, space_type_items);
1792 RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with");
1794 prop = RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
1795 RNA_def_property_enum_sdna(prop, NULL, "regionid");
1796 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1797 RNA_def_property_enum_items(prop, region_type_items);
1798 RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with");
1800 prop = RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE);
1801 RNA_def_property_collection_sdna(prop, NULL, "items", NULL);
1802 RNA_def_property_struct_type(prop, "KeyMapItem");
1803 RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event");
1804 rna_def_keymap_items(brna, prop);
1806 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
1807 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER_MODIFIED);
1808 RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
1810 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1811 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_MODAL);
1812 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1813 RNA_def_property_ui_text(prop, "Modal Keymap",
1814 "Indicates that a keymap is used for translate modal events for an operator");
1816 prop = RNA_def_property(srna, "show_expanded_items", PROP_BOOLEAN, PROP_NONE);
1817 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_EXPANDED);
1818 RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
1819 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1821 prop = RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
1822 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_CHILDREN_EXPANDED);
1823 RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
1824 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1827 RNA_api_keymap(srna);
1830 srna = RNA_def_struct(brna, "KeyMapItem", NULL);
1831 RNA_def_struct_sdna(srna, "wmKeyMapItem");
1832 RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map");
1834 prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
1835 RNA_def_property_string_sdna(prop, NULL, "idname");
1836 RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
1837 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length",
1838 "rna_wmKeyMapItem_idname_set");
1839 RNA_def_struct_name_property(srna, prop);
1840 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1842 /* this is in fact the operator name, but if the operator can't be found we
1843 * fallback on the operator ID */
1844 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1845 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1846 RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event");
1847 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
1849 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1850 RNA_def_property_struct_type(prop, "OperatorProperties");
1851 RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
1852 RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
1853 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1855 prop = RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
1856 RNA_def_property_enum_sdna(prop, NULL, "maptype");
1857 RNA_def_property_enum_items(prop, map_type_items);
1858 RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
1859 RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
1860 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1862 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1863 RNA_def_property_enum_sdna(prop, NULL, "type");
1864 RNA_def_property_enum_items(prop, event_type_items);
1865 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
1866 RNA_def_property_ui_text(prop, "Type", "Type of event");
1867 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1869 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1870 RNA_def_property_enum_sdna(prop, NULL, "val");
1871 RNA_def_property_enum_items(prop, event_value_items);
1872 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
1873 RNA_def_property_ui_text(prop, "Value", "");
1874 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1876 prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
1877 RNA_def_property_int_sdna(prop, NULL, "id");
1878 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1879 RNA_def_property_ui_text(prop, "ID", "ID of the item");
1880 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1882 prop = RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
1883 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_getf", "rna_KeyMapItem_any_setf");
1884 RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
1885 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1887 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1888 RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
1889 /* RNA_def_property_enum_sdna(prop, NULL, "shift"); */
1890 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1891 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
1892 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1894 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1895 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
1896 /* RNA_def_property_enum_sdna(prop, NULL, "ctrl"); */
1897 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1898 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
1899 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1901 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1902 RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
1903 /* RNA_def_property_enum_sdna(prop, NULL, "alt"); */
1904 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1905 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
1906 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1908 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1909 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
1910 /* RNA_def_property_enum_sdna(prop, NULL, "oskey"); */
1911 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
1912 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
1913 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1915 prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
1916 RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
1917 RNA_def_property_enum_items(prop, event_type_items);
1918 RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
1919 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1921 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1922 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
1923 RNA_def_property_ui_text(prop, "Expanded", "Show key map event and property details in the user interface");
1924 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1925 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1927 prop = RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
1928 RNA_def_property_enum_sdna(prop, NULL, "propvalue");
1929 RNA_def_property_enum_items(prop, keymap_propvalue_items);
1930 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
1931 RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap");
1932 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1934 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1935 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
1936 RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
1937 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
1938 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
1940 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
1941 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_USER_MODIFIED);
1942 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1943 RNA_def_property_ui_text(prop, "User Modified", "Is this keymap item modified by the user");
1945 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
1946 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1947 RNA_def_property_ui_text(prop, "User Defined",
1948 "Is this keymap item user defined (doesn't just replace a builtin item)");
1949 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", NULL);
1951 RNA_api_keymapitem(srna);
1954 void RNA_def_wm(BlenderRNA *brna)
1956 rna_def_operator(brna);
1957 rna_def_operator_utils(brna);
1958 rna_def_operator_filelist_element(brna);
1959 rna_def_macro_operator(brna);
1960 rna_def_operator_type_macro(brna);
1961 rna_def_event(brna);
1962 rna_def_timer(brna);
1963 rna_def_window(brna);
1964 rna_def_windowmanager(brna);
1965 rna_def_keyconfig(brna);
1968 #endif /* RNA_RUNTIME */