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
29 #include "DNA_screen_types.h"
30 #include "DNA_space_types.h"
31 #include "DNA_userdef_types.h"
32 #include "DNA_windowmanager_types.h"
34 #include "BLI_utildefines.h"
35 #include "BLI_string_utils.h"
37 #include "BLT_translation.h"
39 #include "RNA_access.h"
40 #include "RNA_define.h"
41 #include "RNA_enum_types.h"
43 #include "rna_internal.h"
48 static const EnumPropertyItem event_keymouse_value_items[] = {
49 {KM_ANY, "ANY", 0, "Any", ""},
50 {KM_PRESS, "PRESS", 0, "Press", ""},
51 {KM_RELEASE, "RELEASE", 0, "Release", ""},
52 {KM_CLICK, "CLICK", 0, "Click", ""},
53 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
54 {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
55 {0, NULL, 0, NULL, NULL}
58 static const EnumPropertyItem event_tweak_value_items[] = {
59 {KM_ANY, "ANY", 0, "Any", ""},
60 {EVT_GESTURE_N, "NORTH", 0, "North", ""},
61 {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
62 {EVT_GESTURE_E, "EAST", 0, "East", ""},
63 {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
64 {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
65 {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
66 {EVT_GESTURE_W, "WEST", 0, "West", ""},
67 {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
68 {0, NULL, 0, NULL, NULL}
71 static const EnumPropertyItem event_tweak_type_items[] = {
72 {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""},
73 {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""},
74 {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""},
75 {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Action", ""},
76 {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Select", ""},
77 {0, NULL, 0, NULL, NULL}
80 static const EnumPropertyItem event_mouse_type_items[] = {
81 {LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""},
82 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""},
83 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right", ""},
84 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4", ""},
85 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5", ""},
86 {BUTTON6MOUSE, "BUTTON6MOUSE", 0, "Button6", ""},
87 {BUTTON7MOUSE, "BUTTON7MOUSE", 0, "Button7", ""},
88 {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action", ""},
89 {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""},
90 {0, "", 0, NULL, NULL},
91 {TABLET_STYLUS, "PEN", 0, "Pen", ""},
92 {TABLET_ERASER, "ERASER", 0, "Eraser", ""},
93 {0, "", 0, NULL, NULL},
94 {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""},
95 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""},
96 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""},
97 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""},
98 {0, "", 0, NULL, NULL},
99 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
100 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
101 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
102 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
103 {0, NULL, 0, NULL, NULL}
106 static const EnumPropertyItem event_timer_type_items[] = {
107 {TIMER, "TIMER", 0, "Timer", ""},
108 {TIMER0, "TIMER0", 0, "Timer 0", ""},
109 {TIMER1, "TIMER1", 0, "Timer 1", ""},
110 {TIMER2, "TIMER2", 0, "Timer 2", ""},
111 {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", ""},
112 {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", ""},
113 {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", ""},
114 {TIMERREGION, "TIMERREGION", 0, "Timer Region", ""},
115 {0, NULL, 0, NULL, NULL}
118 static const EnumPropertyItem event_textinput_type_items[] = {
119 {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
120 {0, NULL, 0, NULL, NULL}
123 static const EnumPropertyItem event_ndof_type_items[] = {
124 {NDOF_MOTION, "NDOF_MOTION", 0, "Motion", ""},
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}
172 #endif /* RNA_RUNTIME */
174 /* not returned: CAPSLOCKKEY, UNKNOWNKEY */
175 const EnumPropertyItem rna_enum_event_type_items[] = {
176 /* Note we abuse 'tooltip' message here to store a 'compact' form of some (too) long names. */
177 {0, "NONE", 0, "", ""},
178 {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", "LMB"},
179 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", "MMB"},
180 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", "RMB"},
181 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", "MB4"},
182 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", "MB5"},
183 {BUTTON6MOUSE, "BUTTON6MOUSE", 0, "Button6 Mouse", "MB6"},
184 {BUTTON7MOUSE, "BUTTON7MOUSE", 0, "Button7 Mouse", "MB7"},
185 {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", "MBA"},
186 {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", "MBS"},
187 {0, "", 0, NULL, NULL},
188 {TABLET_STYLUS, "PEN", 0, "Pen", ""},
189 {TABLET_ERASER, "ERASER", 0, "Eraser", ""},
190 {0, "", 0, NULL, NULL},
191 {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", "MsMov"},
192 {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "In-between Move", "MsSubMov"},
193 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", "MsPan"},
194 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", "MsZoom"},
195 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", "MsRot"},
196 {0, "", 0, NULL, NULL},
197 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", "WhUp"},
198 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", "WhDown"},
199 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", "WhIn"},
200 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", "WhOut"},
201 {0, "", 0, NULL, NULL},
202 {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", "TwkL"},
203 {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", "TwkM"},
204 {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", "TwkR"},
205 {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", "TwkA"},
206 {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", "TwkS"},
207 {0, "", 0, NULL, NULL},
208 {AKEY, "A", 0, "A", ""},
209 {BKEY, "B", 0, "B", ""},
210 {CKEY, "C", 0, "C", ""},
211 {DKEY, "D", 0, "D", ""},
212 {EKEY, "E", 0, "E", ""},
213 {FKEY, "F", 0, "F", ""},
214 {GKEY, "G", 0, "G", ""},
215 {HKEY, "H", 0, "H", ""},
216 {IKEY, "I", 0, "I", ""},
217 {JKEY, "J", 0, "J", ""},
218 {KKEY, "K", 0, "K", ""},
219 {LKEY, "L", 0, "L", ""},
220 {MKEY, "M", 0, "M", ""},
221 {NKEY, "N", 0, "N", ""},
222 {OKEY, "O", 0, "O", ""},
223 {PKEY, "P", 0, "P", ""},
224 {QKEY, "Q", 0, "Q", ""},
225 {RKEY, "R", 0, "R", ""},
226 {SKEY, "S", 0, "S", ""},
227 {TKEY, "T", 0, "T", ""},
228 {UKEY, "U", 0, "U", ""},
229 {VKEY, "V", 0, "V", ""},
230 {WKEY, "W", 0, "W", ""},
231 {XKEY, "X", 0, "X", ""},
232 {YKEY, "Y", 0, "Y", ""},
233 {ZKEY, "Z", 0, "Z", ""},
234 {0, "", 0, NULL, NULL},
235 {ZEROKEY, "ZERO", 0, "0", ""},
236 {ONEKEY, "ONE", 0, "1", ""},
237 {TWOKEY, "TWO", 0, "2", ""},
238 {THREEKEY, "THREE", 0, "3", ""},
239 {FOURKEY, "FOUR", 0, "4", ""},
240 {FIVEKEY, "FIVE", 0, "5", ""},
241 {SIXKEY, "SIX", 0, "6", ""},
242 {SEVENKEY, "SEVEN", 0, "7", ""},
243 {EIGHTKEY, "EIGHT", 0, "8", ""},
244 {NINEKEY, "NINE", 0, "9", ""},
245 {0, "", 0, NULL, NULL},
246 {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", "CtrlL"},
247 {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", "AltL"},
248 {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", "ShiftL"},
249 {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", "AltR"},
250 {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", "CtrlR"},
251 {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", "ShiftR"},
252 {0, "", 0, NULL, NULL},
253 {OSKEY, "OSKEY", 0, "OS Key", "Cmd"},
254 {GRLESSKEY, "GRLESS", 0, "Grless", ""},
255 {ESCKEY, "ESC", 0, "Esc", ""},
256 {TABKEY, "TAB", 0, "Tab", ""},
257 {RETKEY, "RET", 0, "Return", "Enter"},
258 {SPACEKEY, "SPACE", 0, "Spacebar", "Space"},
259 {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
260 {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", "BkSpace"},
261 {DELKEY, "DEL", 0, "Delete", "Del"},
262 {SEMICOLONKEY, "SEMI_COLON", 0, ";", ""},
263 {PERIODKEY, "PERIOD", 0, ".", ""},
264 {COMMAKEY, "COMMA", 0, ",", ""},
265 {QUOTEKEY, "QUOTE", 0, "\"", ""},
266 {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "`", ""},
267 {MINUSKEY, "MINUS", 0, "-", ""},
268 {PLUSKEY, "PLUS", 0, "+", ""},
269 {SLASHKEY, "SLASH", 0, "/", ""},
270 {BACKSLASHKEY, "BACK_SLASH", 0, "\\", ""},
271 {EQUALKEY, "EQUAL", 0, "=", ""},
272 {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""},
273 {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""},
274 {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", "←"},
275 {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", "↓"},
276 {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", "→"},
277 {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", "↑"},
278 {PAD2, "NUMPAD_2", 0, "Numpad 2", "Pad2"},
279 {PAD4, "NUMPAD_4", 0, "Numpad 4", "Pad4"},
280 {PAD6, "NUMPAD_6", 0, "Numpad 6", "Pad6"},
281 {PAD8, "NUMPAD_8", 0, "Numpad 8", "Pad8"},
282 {PAD1, "NUMPAD_1", 0, "Numpad 1", "Pad1"},
283 {PAD3, "NUMPAD_3", 0, "Numpad 3", "Pad3"},
284 {PAD5, "NUMPAD_5", 0, "Numpad 5", "Pad5"},
285 {PAD7, "NUMPAD_7", 0, "Numpad 7", "Pad7"},
286 {PAD9, "NUMPAD_9", 0, "Numpad 9", "Pad9"},
287 {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", "Pad."},
288 {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", "Pad/"},
289 {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", "Pad*"},
290 {PAD0, "NUMPAD_0", 0, "Numpad 0", "Pad0"},
291 {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", "Pad-"},
292 {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", "PadEnter"},
293 {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", "Pad+"},
294 {F1KEY, "F1", 0, "F1", ""},
295 {F2KEY, "F2", 0, "F2", ""},
296 {F3KEY, "F3", 0, "F3", ""},
297 {F4KEY, "F4", 0, "F4", ""},
298 {F5KEY, "F5", 0, "F5", ""},
299 {F6KEY, "F6", 0, "F6", ""},
300 {F7KEY, "F7", 0, "F7", ""},
301 {F8KEY, "F8", 0, "F8", ""},
302 {F9KEY, "F9", 0, "F9", ""},
303 {F10KEY, "F10", 0, "F10", ""},
304 {F11KEY, "F11", 0, "F11", ""},
305 {F12KEY, "F12", 0, "F12", ""},
306 {F13KEY, "F13", 0, "F13", ""},
307 {F14KEY, "F14", 0, "F14", ""},
308 {F15KEY, "F15", 0, "F15", ""},
309 {F16KEY, "F16", 0, "F16", ""},
310 {F17KEY, "F17", 0, "F17", ""},
311 {F18KEY, "F18", 0, "F18", ""},
312 {F19KEY, "F19", 0, "F19", ""},
313 {PAUSEKEY, "PAUSE", 0, "Pause", ""},
314 {INSERTKEY, "INSERT", 0, "Insert", "Ins"},
315 {HOMEKEY, "HOME", 0, "Home", ""},
316 {PAGEUPKEY, "PAGE_UP", 0, "Page Up", "PgUp"},
317 {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", "PgDown"},
318 {ENDKEY, "END", 0, "End", ""},
319 {0, "", 0, NULL, NULL},
320 {MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ">/||"},
321 {MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", "Stop"},
322 {MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", "|<<"},
323 {MEDIALAST, "MEDIA_LAST", 0, "Media Last", ">>|"},
324 {0, "", 0, NULL, NULL},
325 {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", "TxtIn"},
326 {0, "", 0, NULL, NULL},
327 {WINDEACTIVATE, "WINDOW_DEACTIVATE", 0, "Window Deactivate", ""},
328 {TIMER, "TIMER", 0, "Timer", "Tmr"},
329 {TIMER0, "TIMER0", 0, "Timer 0", "Tmr0"},
330 {TIMER1, "TIMER1", 0, "Timer 1", "Tmr1"},
331 {TIMER2, "TIMER2", 0, "Timer 2", "Tmr2"},
332 {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", "TmrJob"},
333 {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", "TmrSave"},
334 {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", "TmrReport"},
335 {TIMERREGION, "TIMERREGION", 0, "Timer Region", "TmrReg"},
336 {0, "", 0, NULL, NULL},
337 {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", "NdofMov"},
338 /* buttons on all 3dconnexion devices */
339 {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"},
340 {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", "NdofFit"},
342 {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", "Ndof↑"},
343 {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "NDOF Bottom", "Ndof↓"},
344 {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", "Ndof←"},
345 {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "NDOF Right", "Ndof→"},
346 {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", "NdofFront"},
347 {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", "NdofBack"},
349 {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "NDOF Isometric 1", "NdofIso1"},
350 {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "NDOF Isometric 2", "NdofIso2"},
351 /* 90 degree rotations */
352 {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "NDOF Roll CW", "NdofRCW"},
353 {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "NDOF Roll CCW", "NdofRCCW"},
354 {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "NDOF Spin CW", "NdofSCW"},
355 {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "NDOF Spin CCW", "NdofSCCW"},
356 {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "NDOF Tilt CW", "NdofTCW"},
357 {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "NDOF Tilt CCW", "NdofTCCW"},
359 {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "NDOF Rotate", "NdofRot"},
360 {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "NDOF Pan/Zoom", "NdofPanZoom"},
361 {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "NDOF Dominant", "NdofDom"},
362 {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "NDOF Plus", "Ndof+"},
363 {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "NDOF Minus", "Ndof-"},
364 /* keyboard emulation */
365 {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "NDOF Esc", "NdofEsc"},
366 {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "NDOF Alt", "NdofAlt"},
367 {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "NDOF Shift", "NdofShift"},
368 {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "NDOF Ctrl", "NdofCtrl"},
369 /* general-purpose buttons */
370 {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "NDOF Button 1", "NdofB1"},
371 {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "NDOF Button 2", "NdofB2"},
372 {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "NDOF Button 3", "NdofB3"},
373 {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "NDOF Button 4", "NdofB4"},
374 {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "NDOF Button 5", "NdofB5"},
375 {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "NDOF Button 6", "NdofB6"},
376 {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "NDOF Button 7", "NdofB7"},
377 {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "NDOF Button 8", "NdofB8"},
378 {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "NDOF Button 9", "NdofB9"},
379 {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "NDOF Button 10", "NdofB10"},
380 {NDOF_BUTTON_A, "NDOF_BUTTON_A", 0, "NDOF Button A", "NdofBA"},
381 {NDOF_BUTTON_B, "NDOF_BUTTON_B", 0, "NDOF Button B", "NdofBB"},
382 {NDOF_BUTTON_C, "NDOF_BUTTON_C", 0, "NDOF Button C", "NdofBC"},
384 {EVT_ACTIONZONE_AREA, "ACTIONZONE_AREA", 0, "ActionZone Area", "AZone Area"},
385 {EVT_ACTIONZONE_REGION, "ACTIONZONE_REGION", 0, "ActionZone Region", "AZone Region"},
386 {EVT_ACTIONZONE_FULLSCREEN, "ACTIONZONE_FULLSCREEN", 0, "ActionZone Fullscreen", "AZone FullScr"},
387 {0, NULL, 0, NULL, NULL}
390 const EnumPropertyItem rna_enum_event_value_items[] = {
391 {KM_ANY, "ANY", 0, "Any", ""},
392 {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
393 {KM_PRESS, "PRESS", 0, "Press", ""},
394 {KM_RELEASE, "RELEASE", 0, "Release", ""},
395 {KM_CLICK, "CLICK", 0, "Click", ""},
396 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
397 {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
398 {EVT_GESTURE_N, "NORTH", 0, "North", ""},
399 {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
400 {EVT_GESTURE_E, "EAST", 0, "East", ""},
401 {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
402 {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
403 {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
404 {EVT_GESTURE_W, "WEST", 0, "West", ""},
405 {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
406 {0, NULL, 0, NULL, NULL}
409 const EnumPropertyItem rna_enum_keymap_propvalue_items[] = {
410 {0, "NONE", 0, "", ""},
411 {0, NULL, 0, NULL, NULL}
415 static const EnumPropertyItem keymap_modifiers_items[] = {
416 {KM_ANY, "ANY", 0, "Any", ""},
417 {0, "NONE", 0, "None", ""},
418 {1, "FIRST", 0, "First", ""},
419 {2, "SECOND", 0, "Second", ""},
420 {0, NULL, 0, NULL, NULL}
426 static const EnumPropertyItem operator_flag_items[] = {
427 {OPTYPE_REGISTER, "REGISTER", 0, "Register", "Display in the info window and support the redo toolbar panel"},
428 {OPTYPE_UNDO, "UNDO", 0, "Undo", "Push an undo event (needed for operator redo)"},
429 {OPTYPE_UNDO_GROUPED, "UNDO_GROUPED", 0, "Grouped Undo", "Push a single undo event for repetead instances of this operator"},
430 {OPTYPE_BLOCKING, "BLOCKING", 0, "Blocking", "Block anything else from using the cursor"},
431 {OPTYPE_MACRO, "MACRO", 0, "Macro", "Use to check if an operator is a macro"},
432 {OPTYPE_GRAB_CURSOR, "GRAB_CURSOR", 0, "Grab Pointer",
433 "Use so the operator grabs the mouse focus, enables wrapping when continuous grab "
435 {OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"},
436 {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"},
437 {0, NULL, 0, NULL, NULL}
441 const EnumPropertyItem rna_enum_operator_return_items[] = {
442 {OPERATOR_RUNNING_MODAL, "RUNNING_MODAL", 0, "Running Modal", "Keep the operator running with blender"},
443 {OPERATOR_CANCELLED, "CANCELLED", 0, "Cancelled", "When no action has been taken, operator exits"},
444 {OPERATOR_FINISHED, "FINISHED", 0, "Finished", "When the operator is complete, operator exits"},
446 {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"},
447 {OPERATOR_INTERFACE, "INTERFACE", 0, "Interface", "Handled but not executed (popup menus)"},
448 {0, NULL, 0, NULL, NULL}
452 const EnumPropertyItem rna_enum_wm_report_items[] = {
453 {RPT_DEBUG, "DEBUG", 0, "Debug", ""},
454 {RPT_INFO, "INFO", 0, "Info", ""},
455 {RPT_OPERATOR, "OPERATOR", 0, "Operator", ""},
456 {RPT_PROPERTY, "PROPERTY", 0, "Property", ""},
457 {RPT_WARNING, "WARNING", 0, "Warning", ""},
458 {RPT_ERROR, "ERROR", 0, "Error", ""},
459 {RPT_ERROR_INVALID_INPUT, "ERROR_INVALID_INPUT", 0, "Invalid Input", ""},
460 {RPT_ERROR_INVALID_CONTEXT, "ERROR_INVALID_CONTEXT", 0, "Invalid Context", ""},
461 {RPT_ERROR_OUT_OF_MEMORY, "ERROR_OUT_OF_MEMORY", 0, "Out of Memory", ""},
462 {0, NULL, 0, NULL, NULL}
471 #include "UI_interface.h"
473 #include "BKE_idprop.h"
475 #include "MEM_guardedalloc.h"
477 static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
479 wmWindowManager *wm = ptr->id.data;
482 IDProperty *properties = (IDProperty *)ptr->data;
483 for (wmOperator *op = wm->operators.last; op; op = op->prev) {
484 if (op->properties == properties) {
493 static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr)
495 wmOperator *op = rna_OperatorProperties_find_operator(ptr);
498 return op->type->srna;
503 static IDProperty *rna_OperatorProperties_idprops(PointerRNA *ptr, bool create)
505 if (create && !ptr->data) {
506 IDPropertyTemplate val = {0};
507 ptr->data = IDP_New(IDP_GROUP, &val, "RNA_OperatorProperties group");
513 static void rna_Operator_name_get(PointerRNA *ptr, char *value)
515 wmOperator *op = (wmOperator *)ptr->data;
516 strcpy(value, op->type->name);
519 static int rna_Operator_name_length(PointerRNA *ptr)
521 wmOperator *op = (wmOperator *)ptr->data;
522 return strlen(op->type->name);
525 static bool rna_Operator_has_reports_get(PointerRNA *ptr)
527 wmOperator *op = (wmOperator *)ptr->data;
528 return (op->reports && op->reports->list.first);
531 static PointerRNA rna_Operator_options_get(PointerRNA *ptr)
533 return rna_pointer_inherit_refine(ptr, &RNA_OperatorOptions, ptr->data);
536 static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
538 wmOperator *op = (wmOperator *)ptr->data;
539 return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties);
542 static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
544 wmOperatorTypeMacro *otmacro = (wmOperatorTypeMacro *)ptr->data;
545 wmOperatorType *ot = WM_operatortype_find(otmacro->idname, true);
546 return rna_pointer_inherit_refine(ptr, ot->srna, otmacro->properties);
549 static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
551 const wmEvent *event = ptr->data;
552 value[0] = event->ascii;
556 static int rna_Event_ascii_length(PointerRNA *ptr)
558 const wmEvent *event = ptr->data;
559 return (event->ascii) ? 1 : 0;
562 static void rna_Event_unicode_get(PointerRNA *ptr, char *value)
564 /* utf8 buf isn't \0 terminated */
565 const wmEvent *event = ptr->data;
568 if (event->utf8_buf[0]) {
569 BLI_str_utf8_as_unicode_and_size(event->utf8_buf, &len);
571 memcpy(value, event->utf8_buf, len);
578 static int rna_Event_unicode_length(PointerRNA *ptr)
581 const wmEvent *event = ptr->data;
582 if (event->utf8_buf[0]) {
583 /* invalid value is checked on assignment so we don't need to account for this */
584 return BLI_str_utf8_size(event->utf8_buf);
591 static float rna_Event_pressure_get(PointerRNA *ptr)
593 const wmEvent *event = ptr->data;
594 return WM_event_tablet_data(event, NULL, NULL);
597 static bool rna_Event_is_tablet_get(PointerRNA *ptr)
599 const wmEvent *event = ptr->data;
600 return WM_event_is_tablet(event);
603 static void rna_Event_tilt_get(PointerRNA *ptr, float *values)
605 wmEvent *event = ptr->data;
606 WM_event_tablet_data(event, NULL, values);
609 static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr)
611 struct uiPopupMenu *pup = ptr->data;
612 uiLayout *layout = UI_popup_menu_layout(pup);
615 RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr);
620 static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr)
622 struct uiPieMenu *pie = ptr->data;
623 uiLayout *layout = UI_pie_menu_layout(pie);
626 RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr);
631 static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
633 wmWindow *win = (wmWindow *)ptr->data;
635 /* disallow ID-browsing away from temp screens */
636 if (win->screen->temp) {
640 if (value.data == NULL)
643 /* exception: can't set screens inside of area/region handlers */
644 win->newscreen = value.data;
647 static bool rna_Window_screen_assign_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
649 bScreen *screen = (bScreen *)value.id.data;
651 return !screen->temp;
655 static void rna_Window_screen_update(bContext *C, PointerRNA *ptr)
657 wmWindow *win = (wmWindow *)ptr->data;
659 /* exception: can't set screens inside of area/region handlers,
660 * and must use context so notifier gets to the right window */
661 if (win->newscreen) {
662 WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, win->newscreen);
663 win->newscreen = NULL;
667 static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
669 wmKeyMapItem *kmi = ptr->data;
674 /*return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); */
675 return PointerRNA_NULL;
678 static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
680 wmKeyMapItem *kmi = ptr->data;
682 return WM_keymap_map_type_get(kmi);
685 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
687 wmKeyMapItem *kmi = ptr->data;
688 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
690 if (value != map_type) {
692 case KMI_TYPE_KEYBOARD:
697 kmi->type = EVT_TWEAK_L;
701 kmi->type = LEFTMOUSE;
704 case KMI_TYPE_TEXTINPUT:
705 kmi->type = KM_TEXTINPUT;
706 kmi->val = KM_NOTHING;
710 kmi->val = KM_NOTHING;
713 kmi->type = NDOF_MOTION;
714 kmi->val = KM_NOTHING;
720 /* assumes value to be an enum from rna_enum_event_type_items */
721 /* function makes sure keymodifiers are only valid keys, ESC keeps it unaltered */
722 static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value)
724 wmKeyMapItem *kmi = ptr->data;
726 /* XXX, this should really be managed in an _itemf function,
727 * giving a list of valid enums, then silently changing them when they are set is not
728 * a good precedent, don't do this unless you have a good reason! */
729 if (value == ESCKEY) {
732 else if (value >= AKEY) {
733 kmi->keymodifier = value;
736 kmi->keymodifier = 0;
741 static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
742 bool *UNUSED(r_free))
744 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
746 if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
747 if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
748 if (map_type == KMI_TYPE_TIMER) return event_timer_type_items;
749 if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items;
750 if (map_type == KMI_TYPE_TEXTINPUT) return event_textinput_type_items;
751 else return rna_enum_event_type_items;
754 static const EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
755 bool *UNUSED(r_free))
757 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
759 if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF)
760 return event_keymouse_value_items;
761 if (map_type == KMI_TYPE_TWEAK)
762 return event_tweak_value_items;
764 return rna_enum_event_value_items;
767 static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop),
768 bool *UNUSED(r_free))
770 wmWindowManager *wm = CTX_wm_manager(C);
774 for (kc = wm->keyconfigs.first; kc; kc = kc->next) {
775 for (km = kc->keymaps.first; km; km = km->next) {
776 /* only check if it's a modal keymap */
777 if (km->modal_items) {
779 for (kmi = km->items.first; kmi; kmi = kmi->next) {
780 if (kmi == ptr->data) {
781 return km->modal_items;
789 return rna_enum_keymap_propvalue_items; /* ERROR */
792 static bool rna_KeyMapItem_any_get(PointerRNA *ptr)
794 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
796 if (kmi->shift == KM_ANY &&
797 kmi->ctrl == KM_ANY &&
798 kmi->alt == KM_ANY &&
799 kmi->oskey == KM_ANY)
808 static void rna_KeyMapItem_any_set(PointerRNA *ptr, bool value)
810 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
813 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
816 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = 0;
820 static bool rna_KeyMapItem_shift_get(PointerRNA *ptr)
822 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
823 return kmi->shift != 0;
826 static bool rna_KeyMapItem_ctrl_get(PointerRNA *ptr)
828 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
829 return kmi->ctrl != 0;
832 static bool rna_KeyMapItem_alt_get(PointerRNA *ptr)
834 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
835 return kmi->alt != 0;
838 static bool rna_KeyMapItem_oskey_get(PointerRNA *ptr)
840 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
841 return kmi->oskey != 0;
844 static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
846 wmWindowManager *wm = ptr->data;
849 kc = BLI_findstring(&wm->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname));
852 kc = wm->defaultconf;
854 return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
857 static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
859 wmWindowManager *wm = ptr->data;
860 wmKeyConfig *kc = value.data;
863 WM_keyconfig_set_active(wm, kc->idname);
866 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
868 wmKeyMapItem *kmi = ptr->data;
869 WM_operator_py_idname(value, kmi->idname);
872 static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
874 wmKeyMapItem *kmi = ptr->data;
875 char pyname[OP_MAX_TYPENAME];
877 WM_operator_py_idname(pyname, kmi->idname);
878 return strlen(pyname);
881 static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
883 wmKeyMapItem *kmi = ptr->data;
884 char idname[OP_MAX_TYPENAME];
886 WM_operator_bl_idname(idname, value);
888 if (!STREQ(idname, kmi->idname)) {
889 BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
891 WM_keymap_properties_reset(kmi, NULL);
895 static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
897 wmKeyMapItem *kmi = ptr->data;
898 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
899 strcpy(value, ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
902 static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
904 wmKeyMapItem *kmi = ptr->data;
905 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
906 return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
909 static bool rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
911 wmKeyMapItem *kmi = ptr->data;
915 static void rna_wmClipboard_get(PointerRNA *UNUSED(ptr), char *value)
920 pbuf = WM_clipboard_text_get(false, &pbuf_len);
922 memcpy(value, pbuf, pbuf_len + 1);
930 static int rna_wmClipboard_length(PointerRNA *UNUSED(ptr))
935 pbuf = WM_clipboard_text_get(false, &pbuf_len);
943 static void rna_wmClipboard_set(PointerRNA *UNUSED(ptr), const char *value)
945 WM_clipboard_text_set((void *) value, false);
950 static bool rna_operator_poll_cb(bContext *C, wmOperatorType *ot)
952 extern FunctionRNA rna_Operator_poll_func;
960 RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */
961 func = &rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
963 RNA_parameter_list_create(&list, &ptr, func);
964 RNA_parameter_set_lookup(&list, "context", &C);
965 ot->ext.call(C, &ptr, func, &list);
967 RNA_parameter_get_lookup(&list, "visible", &ret);
968 visible = *(bool *)ret;
970 RNA_parameter_list_free(&list);
975 static int rna_operator_execute_cb(bContext *C, wmOperator *op)
977 extern FunctionRNA rna_Operator_execute_func;
985 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
986 func = &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
988 RNA_parameter_list_create(&list, &opr, func);
989 RNA_parameter_set_lookup(&list, "context", &C);
990 op->type->ext.call(C, &opr, func, &list);
992 RNA_parameter_get_lookup(&list, "result", &ret);
993 result = *(int *)ret;
995 RNA_parameter_list_free(&list);
1000 /* same as execute() but no return value */
1001 static bool rna_operator_check_cb(bContext *C, wmOperator *op)
1003 extern FunctionRNA rna_Operator_check_func;
1011 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1012 func = &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
1014 RNA_parameter_list_create(&list, &opr, func);
1015 RNA_parameter_set_lookup(&list, "context", &C);
1016 op->type->ext.call(C, &opr, func, &list);
1018 RNA_parameter_get_lookup(&list, "result", &ret);
1019 result = (*(bool *)ret) != 0;
1021 RNA_parameter_list_free(&list);
1026 static int rna_operator_invoke_cb(bContext *C, wmOperator *op, const wmEvent *event)
1028 extern FunctionRNA rna_Operator_invoke_func;
1036 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1037 func = &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
1039 RNA_parameter_list_create(&list, &opr, func);
1040 RNA_parameter_set_lookup(&list, "context", &C);
1041 RNA_parameter_set_lookup(&list, "event", &event);
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 /* same as invoke */
1053 static int rna_operator_modal_cb(bContext *C, wmOperator *op, const wmEvent *event)
1055 extern FunctionRNA rna_Operator_modal_func;
1063 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1064 func = &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
1066 RNA_parameter_list_create(&list, &opr, func);
1067 RNA_parameter_set_lookup(&list, "context", &C);
1068 RNA_parameter_set_lookup(&list, "event", &event);
1069 op->type->ext.call(C, &opr, func, &list);
1071 RNA_parameter_get_lookup(&list, "result", &ret);
1072 result = *(int *)ret;
1074 RNA_parameter_list_free(&list);
1079 static void rna_operator_draw_cb(bContext *C, wmOperator *op)
1081 extern FunctionRNA rna_Operator_draw_func;
1087 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1088 func = &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
1090 RNA_parameter_list_create(&list, &opr, func);
1091 RNA_parameter_set_lookup(&list, "context", &C);
1092 op->type->ext.call(C, &opr, func, &list);
1094 RNA_parameter_list_free(&list);
1097 /* same as exec(), but call cancel */
1098 static void rna_operator_cancel_cb(bContext *C, wmOperator *op)
1100 extern FunctionRNA rna_Operator_cancel_func;
1106 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1107 func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
1109 RNA_parameter_list_create(&list, &opr, func);
1110 RNA_parameter_set_lookup(&list, "context", &C);
1111 op->type->ext.call(C, &opr, func, &list);
1113 RNA_parameter_list_free(&list);
1116 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type);
1118 /* bpy_operator_wrap.c */
1119 extern void BPY_RNA_operator_wrapper(wmOperatorType *ot, void *userdata);
1120 extern void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata);
1122 static StructRNA *rna_Operator_register(
1123 Main *bmain, ReportList *reports, void *data, const char *identifier,
1124 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1126 wmOperatorType dummyot = {NULL};
1127 wmOperator dummyop = {NULL};
1128 PointerRNA dummyotr;
1129 int have_function[7];
1132 char idname[OP_MAX_TYPENAME];
1133 char name[OP_MAX_TYPENAME];
1134 char description[RNA_DYN_DESCR_MAX];
1135 char translation_context[RNA_DYN_DESCR_MAX];
1136 char undo_group[OP_MAX_TYPENAME];
1139 /* setup dummy operator & operator type to store static properties in */
1140 dummyop.type = &dummyot;
1141 dummyot.idname = temp_buffers.idname; /* only assigne the pointer, string is NULL'd */
1142 dummyot.name = temp_buffers.name; /* only assigne the pointer, string is NULL'd */
1143 dummyot.description = temp_buffers.description; /* only assigne the pointer, string is NULL'd */
1144 dummyot.translation_context = temp_buffers.translation_context; /* only assigne the pointer, string is NULL'd */
1145 dummyot.undo_group = temp_buffers.undo_group; /* only assigne the pointer, string is NULL'd */
1146 RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
1148 /* clear in case they are left unset */
1149 temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = temp_buffers.undo_group[0] = '\0';
1150 /* We have to set default op context! */
1151 strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1153 /* validate the python class */
1154 if (validate(&dummyotr, data, have_function) != 0)
1157 /* check if we have registered this operator type before, and remove it */
1159 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
1160 if (ot && ot->ext.srna)
1161 rna_Operator_unregister(bmain, ot->ext.srna);
1164 if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) {
1168 char idname_conv[sizeof(dummyop.idname)];
1169 WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */
1171 if (!RNA_struct_available_or_report(reports, idname_conv)) {
1175 /* Convert foo.bar to FOO_OT_bar
1176 * allocate all strings at once. */
1178 const char *strings[] = {
1181 temp_buffers.description,
1182 temp_buffers.translation_context,
1183 temp_buffers.undo_group,
1185 char *strings_table[ARRAY_SIZE(strings)];
1186 BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
1188 dummyot.idname = strings_table[0]; /* allocated string stored here */
1189 dummyot.name = strings_table[1];
1190 dummyot.description = strings_table[2];
1191 dummyot.translation_context = strings_table[3];
1192 dummyot.undo_group = strings_table[4];
1193 BLI_assert(ARRAY_SIZE(strings) == 5);
1196 /* XXX, this doubles up with the operator name [#29666]
1197 * for now just remove from dir(bpy.types) */
1199 /* create a new operator type */
1200 dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator);
1201 RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
1202 RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context);
1203 dummyot.ext.data = data;
1204 dummyot.ext.call = call;
1205 dummyot.ext.free = free;
1207 dummyot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : NULL;
1208 dummyot.exec = (have_function[1]) ? rna_operator_execute_cb : NULL;
1209 dummyot.check = (have_function[2]) ? rna_operator_check_cb : NULL;
1210 dummyot.invoke = (have_function[3]) ? rna_operator_invoke_cb : NULL;
1211 dummyot.modal = (have_function[4]) ? rna_operator_modal_cb : NULL;
1212 dummyot.ui = (have_function[5]) ? rna_operator_draw_cb : NULL;
1213 dummyot.cancel = (have_function[6]) ? rna_operator_cancel_cb : NULL;
1214 WM_operatortype_append_ptr(BPY_RNA_operator_wrapper, (void *)&dummyot);
1216 /* update while blender is running */
1217 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1219 return dummyot.ext.srna;
1222 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
1225 wmOperatorType *ot = RNA_struct_blender_type_get(type);
1226 wmWindowManager *wm;
1231 /* update while blender is running */
1232 wm = bmain->wm.first;
1234 WM_operator_stack_clear(wm);
1236 WM_operator_handlers_clear(wm, ot);
1238 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1240 RNA_struct_free_extension(type, &ot->ext);
1242 idname = ot->idname;
1243 WM_operatortype_remove_ptr(ot);
1245 /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
1246 RNA_struct_free(&BLENDER_RNA, type);
1248 MEM_freeN((void *)idname);
1251 static void **rna_Operator_instance(PointerRNA *ptr)
1253 wmOperator *op = ptr->data;
1254 return &op->py_instance;
1257 static StructRNA *rna_MacroOperator_register(
1258 Main *bmain, ReportList *reports, void *data, const char *identifier,
1259 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1261 wmOperatorType dummyot = {NULL};
1262 wmOperator dummyop = {NULL};
1263 PointerRNA dummyotr;
1264 int have_function[4];
1267 char idname[OP_MAX_TYPENAME];
1268 char name[OP_MAX_TYPENAME];
1269 char description[RNA_DYN_DESCR_MAX];
1270 char translation_context[RNA_DYN_DESCR_MAX];
1271 char undo_group[OP_MAX_TYPENAME];
1274 /* setup dummy operator & operator type to store static properties in */
1275 dummyop.type = &dummyot;
1276 dummyot.idname = temp_buffers.idname; /* only assigne the pointer, string is NULL'd */
1277 dummyot.name = temp_buffers.name; /* only assigne the pointer, string is NULL'd */
1278 dummyot.description = temp_buffers.description; /* only assigne the pointer, string is NULL'd */
1279 dummyot.translation_context = temp_buffers.translation_context; /* only assigne the pointer, string is NULL'd */
1280 dummyot.undo_group = temp_buffers.undo_group; /* only assigne the pointer, string is NULL'd */
1281 RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr);
1283 /* clear in case they are left unset */
1284 temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = temp_buffers.undo_group[0] = '\0';
1285 /* We have to set default op context! */
1286 strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1288 /* validate the python class */
1289 if (validate(&dummyotr, data, have_function) != 0)
1292 if (strlen(identifier) >= sizeof(dummyop.idname)) {
1293 BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s' is too long, maximum length is %d",
1294 identifier, (int)sizeof(dummyop.idname));
1298 /* check if we have registered this operator type before, and remove it */
1300 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
1301 if (ot && ot->ext.srna)
1302 rna_Operator_unregister(bmain, ot->ext.srna);
1305 if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) {
1309 char idname_conv[sizeof(dummyop.idname)];
1310 WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */
1312 if (!RNA_struct_available_or_report(reports, idname_conv)) {
1316 /* Convert foo.bar to FOO_OT_bar
1317 * allocate all strings at once. */
1319 const char *strings[] = {
1322 temp_buffers.description,
1323 temp_buffers.translation_context,
1324 temp_buffers.undo_group,
1326 char *strings_table[ARRAY_SIZE(strings)];
1327 BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
1329 dummyot.idname = strings_table[0]; /* allocated string stored here */
1330 dummyot.name = strings_table[1];
1331 dummyot.description = strings_table[2];
1332 dummyot.translation_context = strings_table[3];
1333 dummyot.undo_group = strings_table[4];
1334 BLI_assert(ARRAY_SIZE(strings) == 5);
1337 /* XXX, this doubles up with the operator name [#29666]
1338 * for now just remove from dir(bpy.types) */
1340 /* create a new operator type */
1341 dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator);
1342 RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context);
1343 dummyot.ext.data = data;
1344 dummyot.ext.call = call;
1345 dummyot.ext.free = free;
1347 dummyot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : NULL;
1348 dummyot.ui = (have_function[3]) ? rna_operator_draw_cb : NULL;
1350 WM_operatortype_append_macro_ptr(BPY_RNA_operator_macro_wrapper, (void *)&dummyot);
1352 /* update while blender is running */
1353 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1355 return dummyot.ext.srna;
1357 #endif /* WITH_PYTHON */
1359 static StructRNA *rna_Operator_refine(PointerRNA *opr)
1361 wmOperator *op = (wmOperator *)opr->data;
1362 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Operator;
1365 static StructRNA *rna_MacroOperator_refine(PointerRNA *opr)
1367 wmOperator *op = (wmOperator *)opr->data;
1368 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Macro;
1371 /* just to work around 'const char *' warning and to ensure this is a python op */
1372 static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
1374 wmOperator *data = (wmOperator *)(ptr->data);
1375 char *str = (char *)data->type->idname;
1377 BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
1379 assert(!"setting the bl_idname on a non-builtin operator");
1382 static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
1384 wmOperator *data = (wmOperator *)(ptr->data);
1385 char *str = (char *)data->type->name;
1387 BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
1389 assert(!"setting the bl_label on a non-builtin operator");
1392 static void rna_Operator_bl_translation_context_set(PointerRNA *ptr, const char *value)
1394 wmOperator *data = (wmOperator *)(ptr->data);
1395 char *str = (char *)data->type->translation_context;
1397 BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1399 assert(!"setting the bl_translation_context on a non-builtin operator");
1402 static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
1404 wmOperator *data = (wmOperator *)(ptr->data);
1405 char *str = (char *)data->type->description;
1407 BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1409 assert(!"setting the bl_description on a non-builtin operator");
1412 static void rna_Operator_bl_undo_group_set(PointerRNA *ptr, const char *value)
1414 wmOperator *data = (wmOperator *)(ptr->data);
1415 char *str = (char *)data->type->undo_group;
1417 BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
1419 assert(!"setting the bl_undo_group on a non-builtin operator");
1422 static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
1424 wmKeyMapItem *kmi = ptr->data;
1425 WM_keyconfig_update_tag(NULL, kmi);
1428 #else /* RNA_RUNTIME */
1431 * expose ``Operator.options`` as its own type so we can control each flags use (some are read-only).
1433 static void rna_def_operator_options_runtime(BlenderRNA *brna)
1438 srna = RNA_def_struct(brna, "OperatorOptions", NULL);
1439 RNA_def_struct_ui_text(srna, "Operator Options", "Runtime options");
1440 RNA_def_struct_sdna(srna, "wmOperator");
1442 prop = RNA_def_property(srna, "is_grab_cursor", PROP_BOOLEAN, PROP_BOOLEAN);
1443 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_MODAL_GRAB_CURSOR);
1444 RNA_def_property_ui_text(prop, "Grab Cursor", "True when the cursor is grabbed");
1445 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1447 prop = RNA_def_property(srna, "is_invoke", PROP_BOOLEAN, PROP_BOOLEAN);
1448 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_INVOKE);
1449 RNA_def_property_ui_text(prop, "Invoke", "True when invoked (even if only the execute callbacks available)");
1450 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1452 prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_BOOLEAN);
1453 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_REPEAT);
1454 RNA_def_property_ui_text(prop, "Repeat", "True when run from the redo panel");
1455 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1457 prop = RNA_def_property(srna, "use_cursor_region", PROP_BOOLEAN, PROP_BOOLEAN);
1458 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_MODAL_CURSOR_REGION);
1459 RNA_def_property_ui_text(prop, "Focus Region", "Enable to use the region under the cursor for modal execution");
1462 static void rna_def_operator(BlenderRNA *brna)
1467 srna = RNA_def_struct(brna, "Operator", NULL);
1468 RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution");
1469 RNA_def_struct_sdna(srna, "wmOperator");
1470 RNA_def_struct_refine_func(srna, "rna_Operator_refine");
1472 RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
1474 RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1475 RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
1477 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1478 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1479 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1480 RNA_def_property_ui_text(prop, "Name", "");
1482 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1483 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1484 RNA_def_property_struct_type(prop, "OperatorProperties");
1485 RNA_def_property_ui_text(prop, "Properties", "");
1486 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1488 prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
1489 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
1490 RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", NULL);
1491 RNA_def_property_ui_text(prop, "Has Reports",
1492 "Operator has a set of reports (warnings and errors) from last execution");
1494 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1495 RNA_def_property_struct_type(prop, "UILayout");
1497 prop = RNA_def_property(srna, "options", PROP_POINTER, PROP_NONE);
1498 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1499 RNA_def_property_struct_type(prop, "OperatorOptions");
1500 RNA_def_property_pointer_funcs(prop, "rna_Operator_options_get", NULL, NULL, NULL);
1501 RNA_def_property_ui_text(prop, "Options", "Runtime options");
1504 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1505 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1506 /* else it uses the pointer size!. -3 because '.' -> '_OT_' */
1507 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME - 3);
1508 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1509 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1510 RNA_def_property_flag(prop, PROP_REGISTER);
1511 RNA_def_struct_name_property(srna, prop);
1513 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1514 RNA_def_property_string_sdna(prop, NULL, "type->name");
1515 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1516 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1517 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1518 RNA_def_property_flag(prop, PROP_REGISTER);
1520 prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
1521 RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
1522 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1523 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_translation_context_set");
1524 RNA_def_property_string_default(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1525 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1526 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1528 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1529 RNA_def_property_string_sdna(prop, NULL, "type->description");
1530 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1531 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1532 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1533 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1534 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1536 prop = RNA_def_property(srna, "bl_undo_group", PROP_STRING, PROP_NONE);
1537 RNA_def_property_string_sdna(prop, NULL, "type->undo_group");
1538 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1539 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_undo_group_set");
1540 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1541 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1542 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1544 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1545 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1546 RNA_def_property_enum_items(prop, operator_flag_items);
1547 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1548 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1550 prop = RNA_def_property(srna, "macros", PROP_COLLECTION, PROP_NONE);
1551 RNA_def_property_collection_sdna(prop, NULL, "macro", NULL);
1552 RNA_def_property_struct_type(prop, "Macro");
1553 RNA_def_property_ui_text(prop, "Macros", "");
1555 RNA_api_operator(srna);
1557 srna = RNA_def_struct(brna, "OperatorProperties", NULL);
1558 RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator");
1559 RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
1560 RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops");
1561 RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES);
1564 static void rna_def_macro_operator(BlenderRNA *brna)
1569 srna = RNA_def_struct(brna, "Macro", NULL);
1570 RNA_def_struct_ui_text(srna, "Macro Operator",
1571 "Storage of a macro operator being executed, or registered after execution");
1572 RNA_def_struct_sdna(srna, "wmOperator");
1573 RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
1575 RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister",
1576 "rna_Operator_instance");
1578 RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1579 RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
1581 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1582 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1583 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1584 RNA_def_property_ui_text(prop, "Name", "");
1586 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1587 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1588 RNA_def_property_struct_type(prop, "OperatorProperties");
1589 RNA_def_property_ui_text(prop, "Properties", "");
1590 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1593 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1594 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1595 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1596 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1597 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1598 RNA_def_property_flag(prop, PROP_REGISTER);
1599 RNA_def_struct_name_property(srna, prop);
1601 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1602 RNA_def_property_string_sdna(prop, NULL, "type->name");
1603 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1604 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1605 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1606 RNA_def_property_flag(prop, PROP_REGISTER);
1608 prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
1609 RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
1610 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1611 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_translation_context_set");
1612 RNA_def_property_string_default(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1613 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1614 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1616 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1617 RNA_def_property_string_sdna(prop, NULL, "type->description");
1618 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1619 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1620 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1621 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1622 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1624 prop = RNA_def_property(srna, "bl_undo_group", PROP_STRING, PROP_NONE);
1625 RNA_def_property_string_sdna(prop, NULL, "type->undo_group");
1626 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1627 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_undo_group_set");
1628 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1629 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1630 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1632 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1633 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1634 RNA_def_property_enum_items(prop, operator_flag_items);
1635 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1636 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1638 RNA_api_macro(srna);
1641 static void rna_def_operator_type_macro(BlenderRNA *brna)
1646 srna = RNA_def_struct(brna, "OperatorMacro", NULL);
1647 RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added");
1648 RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
1650 /* prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */
1651 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1652 /* RNA_def_property_string_sdna(prop, NULL, "idname"); */
1653 /* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */
1654 /* RNA_def_struct_name_property(srna, prop); */
1656 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1657 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1658 RNA_def_property_struct_type(prop, "OperatorProperties");
1659 RNA_def_property_ui_text(prop, "Properties", "");
1660 RNA_def_property_pointer_funcs(prop, "rna_OperatorMacro_properties_get", NULL, NULL, NULL);
1663 static void rna_def_operator_utils(BlenderRNA *brna)
1668 srna = RNA_def_struct(brna, "OperatorMousePath", "PropertyGroup");
1669 RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths");
1671 prop = RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
1672 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1673 RNA_def_property_array(prop, 2);
1674 RNA_def_property_ui_text(prop, "Location", "Mouse location");
1676 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
1677 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1678 RNA_def_property_ui_text(prop, "Time", "Time of mouse location");
1681 static void rna_def_operator_filelist_element(BlenderRNA *brna)
1686 srna = RNA_def_struct(brna, "OperatorFileListElement", "PropertyGroup");
1687 RNA_def_struct_ui_text(srna, "Operator File List Element", "");
1690 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
1691 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1692 RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list");
1695 static void rna_def_event(BlenderRNA *brna)
1700 srna = RNA_def_struct(brna, "Event", NULL);
1701 RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
1702 RNA_def_struct_sdna(srna, "wmEvent");
1704 RNA_define_verify_sdna(0); /* not in sdna */
1707 prop = RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
1708 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1709 RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
1710 RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
1713 prop = RNA_def_property(srna, "unicode", PROP_STRING, PROP_NONE);
1714 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1715 RNA_def_property_string_funcs(prop, "rna_Event_unicode_get", "rna_Event_unicode_length", NULL);
1716 RNA_def_property_ui_text(prop, "Unicode", "Single unicode character for this event");
1719 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1720 RNA_def_property_enum_sdna(prop, NULL, "val");
1721 RNA_def_property_enum_items(prop, rna_enum_event_value_items);
1722 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1723 RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
1725 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1726 RNA_def_property_enum_sdna(prop, NULL, "type");
1727 RNA_def_property_enum_items(prop, rna_enum_event_type_items);
1728 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
1729 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1730 RNA_def_property_ui_text(prop, "Type", "");
1734 prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
1735 RNA_def_property_int_sdna(prop, NULL, "x");
1736 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1737 RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative horizontal location of the mouse");
1739 prop = RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
1740 RNA_def_property_int_sdna(prop, NULL, "y");
1741 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1742 RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative vertical location of the mouse");
1744 prop = RNA_def_property(srna, "mouse_region_x", PROP_INT, PROP_NONE);
1745 RNA_def_property_int_sdna(prop, NULL, "mval[0]");
1746 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1747 RNA_def_property_ui_text(prop, "Mouse X Position", "The region relative horizontal location of the mouse");
1749 prop = RNA_def_property(srna, "mouse_region_y", PROP_INT, PROP_NONE);
1750 RNA_def_property_int_sdna(prop, NULL, "mval[1]");
1751 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1752 RNA_def_property_ui_text(prop, "Mouse Y Position", "The region relative vertical location of the mouse");
1754 prop = RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
1755 RNA_def_property_int_sdna(prop, NULL, "prevx");
1756 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1757 RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative horizontal location of the mouse");
1759 prop = RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
1760 RNA_def_property_int_sdna(prop, NULL, "prevy");
1761 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1762 RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative vertical location of the mouse");
1764 prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
1765 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1766 RNA_def_property_float_funcs(prop, "rna_Event_pressure_get", NULL, NULL);
1767 RNA_def_property_ui_text(prop, "Tablet Pressure", "The pressure of the tablet or 1.0 if no tablet present");
1769 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_XYZ_LENGTH);
1770 RNA_def_property_array(prop, 2);
1771 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1772 RNA_def_property_float_funcs(prop, "rna_Event_tilt_get", NULL, NULL);
1773 RNA_def_property_ui_text(prop, "Tablet Tilt", "The pressure of the tablet or zeroes if no tablet present");
1775 prop = RNA_def_property(srna, "is_tablet", PROP_BOOLEAN, PROP_NONE);
1776 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1777 RNA_def_property_boolean_funcs(prop, "rna_Event_is_tablet_get", NULL);
1778 RNA_def_property_ui_text(prop, "Is Tablet", "The event has tablet data");
1780 prop = RNA_def_property(srna, "is_mouse_absolute", PROP_BOOLEAN, PROP_NONE);
1781 RNA_def_property_boolean_sdna(prop, NULL, "is_motion_absolute", 1);
1782 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1783 RNA_def_property_ui_text(prop, "Absolute Motion", "The last motion event was an absolute input");
1786 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1787 RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
1788 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1789 RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
1791 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1792 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
1793 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1794 RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
1796 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1797 RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
1798 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1799 RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
1801 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1802 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
1803 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1804 RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held");
1806 RNA_define_verify_sdna(1); /* not in sdna */
1809 static void rna_def_timer(BlenderRNA *brna)
1814 srna = RNA_def_struct(brna, "Timer", NULL);
1815 RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
1816 RNA_def_struct_sdna(srna, "wmTimer");
1818 RNA_define_verify_sdna(0); /* not in sdna */
1820 /* could wrap more, for now this is enough */
1821 prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
1822 RNA_def_property_float_sdna(prop, NULL, "timestep");
1823 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1824 RNA_def_property_ui_text(prop, "Time Step", "");
1826 prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
1827 RNA_def_property_float_sdna(prop, NULL, "delta");
1828 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1829 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1831 prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
1832 RNA_def_property_float_sdna(prop, NULL, "duration");
1833 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1834 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1836 RNA_define_verify_sdna(1); /* not in sdna */
1839 static void rna_def_popup_menu_wrapper(
1840 BlenderRNA *brna, const char *rna_type, const char *c_type, const char *layout_get_fn)
1845 srna = RNA_def_struct(brna, rna_type, NULL);
1846 /* UI name isn't visible, name same as type. */
1847 RNA_def_struct_ui_text(srna, rna_type, "");
1848 RNA_def_struct_sdna(srna, c_type);
1850 RNA_define_verify_sdna(0); /* not in sdna */
1852 /* could wrap more, for now this is enough */
1853 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1854 RNA_def_property_struct_type(prop, "UILayout");
1855 RNA_def_property_pointer_funcs(prop, layout_get_fn,
1858 RNA_define_verify_sdna(1); /* not in sdna */
1861 static void rna_def_popupmenu(BlenderRNA *brna)
1863 rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "uiPopupMenu", "rna_PopupMenu_layout_get");
1866 static void rna_def_piemenu(BlenderRNA *brna)
1868 rna_def_popup_menu_wrapper(brna, "UIPieMenu", "uiPieMenu", "rna_PieMenu_layout_get");
1871 static void rna_def_window_stereo3d(BlenderRNA *brna)
1876 srna = RNA_def_struct(brna, "Stereo3dDisplay", NULL);
1877 RNA_def_struct_sdna(srna, "Stereo3dFormat");
1878 RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
1879 RNA_def_struct_ui_text(srna, "Stereo 3D Display", "Settings for stereo 3D display");
1881 prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
1882 RNA_def_property_enum_items(prop, rna_enum_stereo3d_display_items);
1883 RNA_def_property_ui_text(prop, "Display Mode", "");
1885 prop = RNA_def_property(srna, "anaglyph_type", PROP_ENUM, PROP_NONE);
1886 RNA_def_property_enum_items(prop, rna_enum_stereo3d_anaglyph_type_items);
1887 RNA_def_property_ui_text(prop, "Anaglyph Type", "");
1889 prop = RNA_def_property(srna, "interlace_type", PROP_ENUM, PROP_NONE);
1890 RNA_def_property_enum_items(prop, rna_enum_stereo3d_interlace_type_items);
1891 RNA_def_property_ui_text(prop, "Interlace Type", "");
1893 prop = RNA_def_property(srna, "use_interlace_swap", PROP_BOOLEAN, PROP_BOOLEAN);
1894 RNA_def_property_boolean_sdna(prop, NULL, "flag", S3D_INTERLACE_SWAP);
1895 RNA_def_property_ui_text(prop, "Swap Left/Right", "Swap left and right stereo channels");
1897 prop = RNA_def_property(srna, "use_sidebyside_crosseyed", PROP_BOOLEAN, PROP_BOOLEAN);
1898 RNA_def_property_boolean_sdna(prop, NULL, "flag", S3D_SIDEBYSIDE_CROSSEYED);
1899 RNA_def_property_ui_text(prop, "Cross-Eyed", "Right eye should see left image and vice-versa");
1902 static void rna_def_window(BlenderRNA *brna)
1907 srna = RNA_def_struct(brna, "Window", NULL);
1908 RNA_def_struct_ui_text(srna, "Window", "Open window");
1909 RNA_def_struct_sdna(srna, "wmWindow");
1911 rna_def_window_stereo3d(brna);
1913 prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
1914 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1915 RNA_def_property_struct_type(prop, "Screen");
1916 RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window");
1917 RNA_def_property_flag(prop, PROP_EDITABLE);
1918 RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, "rna_Window_screen_assign_poll");
1919 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1920 RNA_def_property_update(prop, 0, "rna_Window_screen_update");
1922 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
1923 RNA_def_property_int_sdna(prop, NULL, "posx");
1924 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1925 RNA_def_property_ui_text(prop, "X Position", "Horizontal location of the window");
1927 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
1928 RNA_def_property_int_sdna(prop, NULL, "posy");
1929 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1930 RNA_def_property_ui_text(prop, "Y Position", "Vertical location of the window");
1932 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
1933 RNA_def_property_int_sdna(prop, NULL, "sizex");
1934 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1935 RNA_def_property_ui_text(prop, "Width", "Window width");
1937 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
1938 RNA_def_property_int_sdna(prop, NULL, "sizey");
1939 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1940 RNA_def_property_ui_text(prop, "Height", "Window height");
1942 prop = RNA_def_property(srna, "stereo_3d_display", PROP_POINTER, PROP_NONE);
1943 RNA_def_property_pointer_sdna(prop, NULL, "stereo3d_format");
1944 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1945 RNA_def_property_struct_type(prop, "Stereo3dDisplay");
1946 RNA_def_property_ui_text(prop, "Stereo 3D Display", "Settings for stereo 3d display");
1948 RNA_api_window(srna);
1952 static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
1957 RNA_def_property_srna(cprop, "KeyConfigurations");
1958 srna = RNA_def_struct(brna, "KeyConfigurations", NULL);
1959 RNA_def_struct_sdna(srna, "wmWindowManager");
1960 RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs");
1962 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1963 RNA_def_property_struct_type(prop, "KeyConfig");
1964 RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get",
1965 "rna_WindowManager_active_keyconfig_set", NULL, NULL);
1966 RNA_def_property_flag(prop, PROP_EDITABLE);
1967 RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
1969 prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
1970 RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
1971 RNA_def_property_struct_type(prop, "KeyConfig");
1972 RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
1974 prop = RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
1975 RNA_def_property_pointer_sdna(prop, NULL, "addonconf");
1976 RNA_def_property_struct_type(prop, "KeyConfig");
1977 RNA_def_property_ui_text(prop, "Add-on Key Configuration",
1978 "Key configuration that can be extended by add-ons, and is added to the active "
1979 "configuration when handling events");
1981 prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
1982 RNA_def_property_pointer_sdna(prop, NULL, "userconf");
1983 RNA_def_property_struct_type(prop, "KeyConfig");
1984 RNA_def_property_ui_text(prop, "User Key Configuration",
1985 "Final key configuration that combines keymaps from the active and add-on configurations, "
1986 "and can be edited by the user");
1988 RNA_api_keyconfigs(srna);
1991 static void rna_def_windowmanager(BlenderRNA *brna)
1996 srna = RNA_def_struct(brna, "WindowManager", "ID");
1997 RNA_def_struct_ui_text(srna, "Window Manager",
1998 "Window manager data-block defining open windows and other user interface data");
1999 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
2000 RNA_def_struct_sdna(srna, "wmWindowManager");
2002 prop = RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
2003 RNA_def_property_struct_type(prop, "Operator");
2004 RNA_def_property_ui_text(prop, "Operators", "Operator registry");
2006 prop = RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
2007 RNA_def_property_struct_type(prop, "Window");
2008 RNA_def_property_ui_text(prop, "Windows", "Open windows");
2010 prop = RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
2011 RNA_def_property_struct_type(prop, "KeyConfig");
2012 RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations");
2013 rna_def_wm_keyconfigs(brna, prop);
2015 prop = RNA_def_property(srna, "clipboard", PROP_STRING, PROP_NONE);
2016 RNA_def_property_string_funcs(prop, "rna_wmClipboard_get", "rna_wmClipboard_length", "rna_wmClipboard_set");
2017 RNA_def_property_ui_text(prop, "Text Clipboard", "");
2022 /* keyconfig.items */
2023 static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
2027 RNA_def_property_srna(cprop, "KeyMapItems");
2028 srna = RNA_def_struct(brna, "KeyMapItems", NULL);
2029 RNA_def_struct_sdna(srna, "wmKeyMap");
2030 RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
2032 RNA_api_keymapitems(srna);
2035 static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
2039 RNA_def_property_srna(cprop, "KeyMaps");
2040 srna = RNA_def_struct(brna, "KeyMaps", NULL);
2041 RNA_def_struct_sdna(srna, "wmKeyConfig");
2042 RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
2044 RNA_api_keymaps(srna);
2047 static void rna_def_keyconfig(BlenderRNA *brna)
2052 static const EnumPropertyItem map_type_items[] = {
2053 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
2054 {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
2055 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
2056 {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
2057 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
2058 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
2059 {0, NULL, 0, NULL, NULL}
2063 srna = RNA_def_struct(brna, "KeyConfig", NULL);
2064 RNA_def_struct_sdna(srna, "wmKeyConfig");
2065 RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps");
2067 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2068 RNA_def_property_string_sdna(prop, NULL, "idname");
2069 RNA_def_property_ui_text(prop, "Name", "Name of the key configuration");
2070 RNA_def_struct_name_property(srna, prop);
2072 prop = RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
2073 RNA_def_property_struct_type(prop, "KeyMap");
2074 RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration");
2075 rna_def_wm_keymaps(brna, prop);
2077 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
2078 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYCONF_USER);
2079 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2080 RNA_def_property_ui_text(prop, "User Defined", "Indicates that a keyconfig was defined by the user");
2082 RNA_api_keyconfig(srna);
2085 srna = RNA_def_struct(brna, "KeyMap", NULL);
2086 RNA_def_struct_sdna(srna, "wmKeyMap");
2087 RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps");
2089 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2090 RNA_def_property_string_sdna(prop, NULL, "idname");
2091 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2092 RNA_def_property_ui_text(prop, "Name", "Name of the key map");
2093 RNA_def_struct_name_property(srna, prop);
2095 prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
2096 RNA_def_property_enum_sdna(prop, NULL, "spaceid");
2097 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2098 RNA_def_property_enum_items(prop, rna_enum_space_type_items);
2099 RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with");
2101 prop = RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
2102 RNA_def_property_enum_sdna(prop, NULL, "regionid");
2103 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2104 RNA_def_property_enum_items(prop, rna_enum_region_type_items);
2105 RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with");
2107 prop = RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE);
2108 RNA_def_property_collection_sdna(prop, NULL, "items", NULL);
2109 RNA_def_property_struct_type(prop, "KeyMapItem");
2110 RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event");
2111 rna_def_keymap_items(brna, prop);
2113 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
2114 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER_MODIFIED);
2115 RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
2117 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
2118 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_MODAL);
2119 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2120 RNA_def_property_ui_text(prop, "Modal Keymap",
2121 "Indicates that a keymap is used for translate modal events for an operator");
2123 prop = RNA_def_property(srna, "show_expanded_items", PROP_BOOLEAN, PROP_NONE);
2124 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_EXPANDED);
2125 RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
2126 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2128 prop = RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
2129 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_CHILDREN_EXPANDED);
2130 RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
2131 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2134 RNA_api_keymap(srna);
2137 srna = RNA_def_struct(brna, "KeyMapItem", NULL);
2138 RNA_def_struct_sdna(srna, "wmKeyMapItem");
2139 RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map");
2141 prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
2142 RNA_def_property_string_sdna(prop, NULL, "idname");
2143 RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
2144 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length",
2145 "rna_wmKeyMapItem_idname_set");
2146 RNA_def_struct_name_property(srna, prop);
2147 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2149 /* this is in fact the operator name, but if the operator can't be found we
2150 * fallback on the operator ID */
2151 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2152 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2153 RNA_def_property_ui_text(prop, "Name", "Name of operator (translated) to call on input event");
2154 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
2156 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
2157 RNA_def_property_struct_type(prop, "OperatorProperties");
2158 RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
2159 RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
2160 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2162 prop = RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
2163 RNA_def_property_enum_sdna(prop, NULL, "maptype");
2164 RNA_def_property_enum_items(prop, map_type_items);
2165 RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
2166 RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
2167 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2169 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2170 RNA_def_property_enum_sdna(prop, NULL, "type");
2171 RNA_def_property_enum_items(prop, rna_enum_event_type_items);
2172 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
2173 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
2174 RNA_def_property_ui_text(prop, "Type", "Type of event");
2175 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2177 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
2178 RNA_def_property_enum_sdna(prop, NULL, "val");
2179 RNA_def_property_enum_items(prop, rna_enum_event_value_items);
2180 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
2181 RNA_def_property_ui_text(prop, "Value", "");
2182 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2184 prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
2185 RNA_def_property_int_sdna(prop, NULL, "id");
2186 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2187 RNA_def_property_ui_text(prop, "ID", "ID of the item");
2188 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2190 prop = RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
2191 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_get", "rna_KeyMapItem_any_set");
2192 RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
2193 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2195 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
2196 RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
2197 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_shift_get", NULL);
2198 /* RNA_def_property_enum_sdna(prop, NULL, "shift"); */
2199 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2200 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
2201 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2203 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
2204 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
2205 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_ctrl_get", NULL);
2206 /* RNA_def_property_enum_sdna(prop, NULL, "ctrl"); */
2207 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2208 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
2209 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2211 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
2212 RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
2213 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_alt_get", NULL);
2214 /* RNA_def_property_enum_sdna(prop, NULL, "alt"); */
2215 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2216 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
2217 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2219 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
2220 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
2221 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_oskey_get", NULL);
2222 /* RNA_def_property_enum_sdna(prop, NULL, "oskey"); */
2223 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2224 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
2225 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2227 prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
2228 RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
2229 RNA_def_property_enum_items(prop, rna_enum_event_type_items);
2230 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
2231 RNA_def_property_enum_funcs(prop, NULL, "rna_wmKeyMapItem_keymodifier_set", NULL);
2232 RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
2233 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2235 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
2236 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
2237 RNA_def_property_ui_text(prop, "Expanded", "Show key map event and property details in the user interface");
2238 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2240 prop = RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
2241 RNA_def_property_enum_sdna(prop, NULL, "propvalue");
2242 RNA_def_property_enum_items(prop, rna_enum_keymap_propvalue_items);
2243 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
2244 RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap");
2245 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2247 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
2248 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
2249 RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
2250 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
2251 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2253 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
2254 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_USER_MODIFIED);
2255 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2256 RNA_def_property_ui_text(prop, "User Modified", "Is this keymap item modified by the user");
2258 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
2259 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2260 RNA_def_property_ui_text(prop, "User Defined",
2261 "Is this keymap item user defined (doesn't just replace a builtin item)");
2262 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", NULL);
2264 RNA_api_keymapitem(srna);
2267 void RNA_def_wm(BlenderRNA *brna)
2269 rna_def_operator(brna);
2270 rna_def_operator_options_runtime(brna);
2271 rna_def_operator_utils(brna);
2272 rna_def_operator_filelist_element(brna);
2273 rna_def_macro_operator(brna);
2274 rna_def_operator_type_macro(brna);
2275 rna_def_event(brna);
2276 rna_def_timer(brna);
2277 rna_def_popupmenu(brna);
2278 rna_def_piemenu(brna);
2279 rna_def_window(brna);
2280 rna_def_windowmanager(brna);
2281 rna_def_keyconfig(brna);
2284 #endif /* RNA_RUNTIME */