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"},
383 {0, NULL, 0, NULL, NULL}
386 const EnumPropertyItem rna_enum_event_value_items[] = {
387 {KM_ANY, "ANY", 0, "Any", ""},
388 {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
389 {KM_PRESS, "PRESS", 0, "Press", ""},
390 {KM_RELEASE, "RELEASE", 0, "Release", ""},
391 {KM_CLICK, "CLICK", 0, "Click", ""},
392 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
393 {KM_CLICK_DRAG, "CLICK_DRAG", 0, "Click Drag", ""},
394 {EVT_GESTURE_N, "NORTH", 0, "North", ""},
395 {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
396 {EVT_GESTURE_E, "EAST", 0, "East", ""},
397 {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
398 {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
399 {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
400 {EVT_GESTURE_W, "WEST", 0, "West", ""},
401 {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
402 {0, NULL, 0, NULL, NULL}
405 const EnumPropertyItem rna_enum_keymap_propvalue_items[] = {
406 {0, "NONE", 0, "", ""},
407 {0, NULL, 0, NULL, NULL}
411 static const EnumPropertyItem keymap_modifiers_items[] = {
412 {KM_ANY, "ANY", 0, "Any", ""},
413 {0, "NONE", 0, "None", ""},
414 {1, "FIRST", 0, "First", ""},
415 {2, "SECOND", 0, "Second", ""},
416 {0, NULL, 0, NULL, NULL}
422 static const EnumPropertyItem operator_flag_items[] = {
423 {OPTYPE_REGISTER, "REGISTER", 0, "Register", "Display in the info window and support the redo toolbar panel"},
424 {OPTYPE_UNDO, "UNDO", 0, "Undo", "Push an undo event (needed for operator redo)"},
425 {OPTYPE_UNDO_GROUPED, "UNDO_GROUPED", 0, "Grouped Undo", "Push a single undo event for repetead instances of this operator"},
426 {OPTYPE_BLOCKING, "BLOCKING", 0, "Blocking", "Block anything else from using the cursor"},
427 {OPTYPE_MACRO, "MACRO", 0, "Macro", "Use to check if an operator is a macro"},
428 {OPTYPE_GRAB_CURSOR, "GRAB_CURSOR", 0, "Grab Pointer",
429 "Use so the operator grabs the mouse focus, enables wrapping when continuous grab "
431 {OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"},
432 {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"},
433 {0, NULL, 0, NULL, NULL}
437 const EnumPropertyItem rna_enum_operator_return_items[] = {
438 {OPERATOR_RUNNING_MODAL, "RUNNING_MODAL", 0, "Running Modal", "Keep the operator running with blender"},
439 {OPERATOR_CANCELLED, "CANCELLED", 0, "Cancelled", "When no action has been taken, operator exits"},
440 {OPERATOR_FINISHED, "FINISHED", 0, "Finished", "When the operator is complete, operator exits"},
442 {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"},
443 {OPERATOR_INTERFACE, "INTERFACE", 0, "Interface", "Handled but not executed (popup menus)"},
444 {0, NULL, 0, NULL, NULL}
448 const EnumPropertyItem rna_enum_wm_report_items[] = {
449 {RPT_DEBUG, "DEBUG", 0, "Debug", ""},
450 {RPT_INFO, "INFO", 0, "Info", ""},
451 {RPT_OPERATOR, "OPERATOR", 0, "Operator", ""},
452 {RPT_PROPERTY, "PROPERTY", 0, "Property", ""},
453 {RPT_WARNING, "WARNING", 0, "Warning", ""},
454 {RPT_ERROR, "ERROR", 0, "Error", ""},
455 {RPT_ERROR_INVALID_INPUT, "ERROR_INVALID_INPUT", 0, "Invalid Input", ""},
456 {RPT_ERROR_INVALID_CONTEXT, "ERROR_INVALID_CONTEXT", 0, "Invalid Context", ""},
457 {RPT_ERROR_OUT_OF_MEMORY, "ERROR_OUT_OF_MEMORY", 0, "Out of Memory", ""},
458 {0, NULL, 0, NULL, NULL}
467 #include "UI_interface.h"
469 #include "BKE_idprop.h"
471 #include "MEM_guardedalloc.h"
473 static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
475 wmWindowManager *wm = ptr->id.data;
478 IDProperty *properties = (IDProperty *)ptr->data;
479 for (wmOperator *op = wm->operators.last; op; op = op->prev) {
480 if (op->properties == properties) {
489 static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr)
491 wmOperator *op = rna_OperatorProperties_find_operator(ptr);
494 return op->type->srna;
499 static IDProperty *rna_OperatorProperties_idprops(PointerRNA *ptr, bool create)
501 if (create && !ptr->data) {
502 IDPropertyTemplate val = {0};
503 ptr->data = IDP_New(IDP_GROUP, &val, "RNA_OperatorProperties group");
509 static void rna_Operator_name_get(PointerRNA *ptr, char *value)
511 wmOperator *op = (wmOperator *)ptr->data;
512 strcpy(value, op->type->name);
515 static int rna_Operator_name_length(PointerRNA *ptr)
517 wmOperator *op = (wmOperator *)ptr->data;
518 return strlen(op->type->name);
521 static int rna_Operator_has_reports_get(PointerRNA *ptr)
523 wmOperator *op = (wmOperator *)ptr->data;
524 return (op->reports && op->reports->list.first);
527 static PointerRNA rna_Operator_options_get(PointerRNA *ptr)
529 return rna_pointer_inherit_refine(ptr, &RNA_OperatorOptions, ptr->data);
532 static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
534 wmOperator *op = (wmOperator *)ptr->data;
535 return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties);
538 static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
540 wmOperatorTypeMacro *otmacro = (wmOperatorTypeMacro *)ptr->data;
541 wmOperatorType *ot = WM_operatortype_find(otmacro->idname, true);
542 return rna_pointer_inherit_refine(ptr, ot->srna, otmacro->properties);
545 static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
547 const wmEvent *event = ptr->data;
548 value[0] = event->ascii;
552 static int rna_Event_ascii_length(PointerRNA *ptr)
554 const wmEvent *event = ptr->data;
555 return (event->ascii) ? 1 : 0;
558 static void rna_Event_unicode_get(PointerRNA *ptr, char *value)
560 /* utf8 buf isn't \0 terminated */
561 const wmEvent *event = ptr->data;
564 if (event->utf8_buf[0]) {
565 BLI_str_utf8_as_unicode_and_size(event->utf8_buf, &len);
567 memcpy(value, event->utf8_buf, len);
574 static int rna_Event_unicode_length(PointerRNA *ptr)
577 const wmEvent *event = ptr->data;
578 if (event->utf8_buf[0]) {
579 /* invalid value is checked on assignment so we don't need to account for this */
580 return BLI_str_utf8_size(event->utf8_buf);
587 static float rna_Event_pressure_get(PointerRNA *ptr)
589 const wmEvent *event = ptr->data;
590 return WM_event_tablet_data(event, NULL, NULL);
593 static int rna_Event_is_tablet_get(PointerRNA *ptr)
595 const wmEvent *event = ptr->data;
596 return WM_event_is_tablet(event);
599 static void rna_Event_tilt_get(PointerRNA *ptr, float *values)
601 wmEvent *event = ptr->data;
602 WM_event_tablet_data(event, NULL, values);
605 static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr)
607 struct uiPopupMenu *pup = ptr->data;
608 uiLayout *layout = UI_popup_menu_layout(pup);
611 RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr);
616 static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr)
618 struct uiPieMenu *pie = ptr->data;
619 uiLayout *layout = UI_pie_menu_layout(pie);
622 RNA_pointer_create(ptr->id.data, &RNA_UILayout, layout, &rptr);
627 static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
629 wmWindow *win = (wmWindow *)ptr->data;
631 /* disallow ID-browsing away from temp screens */
632 if (win->screen->temp) {
636 if (value.data == NULL)
639 /* exception: can't set screens inside of area/region handlers */
640 win->newscreen = value.data;
643 static int rna_Window_screen_assign_poll(PointerRNA *UNUSED(ptr), PointerRNA value)
645 bScreen *screen = (bScreen *)value.id.data;
647 return !screen->temp;
651 static void rna_Window_screen_update(bContext *C, PointerRNA *ptr)
653 wmWindow *win = (wmWindow *)ptr->data;
655 /* exception: can't set screens inside of area/region handlers,
656 * and must use context so notifier gets to the right window */
657 if (win->newscreen) {
658 WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, win->newscreen);
659 win->newscreen = NULL;
663 static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
665 wmKeyMapItem *kmi = ptr->data;
670 /*return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties); */
671 return PointerRNA_NULL;
674 static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
676 wmKeyMapItem *kmi = ptr->data;
678 return WM_keymap_map_type_get(kmi);
681 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
683 wmKeyMapItem *kmi = ptr->data;
684 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
686 if (value != map_type) {
688 case KMI_TYPE_KEYBOARD:
693 kmi->type = EVT_TWEAK_L;
697 kmi->type = LEFTMOUSE;
700 case KMI_TYPE_TEXTINPUT:
701 kmi->type = KM_TEXTINPUT;
702 kmi->val = KM_NOTHING;
706 kmi->val = KM_NOTHING;
709 kmi->type = NDOF_MOTION;
710 kmi->val = KM_NOTHING;
716 /* assumes value to be an enum from rna_enum_event_type_items */
717 /* function makes sure keymodifiers are only valid keys, ESC keeps it unaltered */
718 static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value)
720 wmKeyMapItem *kmi = ptr->data;
722 /* XXX, this should really be managed in an _itemf function,
723 * giving a list of valid enums, then silently changing them when they are set is not
724 * a good precedent, don't do this unless you have a good reason! */
725 if (value == ESCKEY) {
728 else if (value >= AKEY) {
729 kmi->keymodifier = value;
732 kmi->keymodifier = 0;
737 static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
738 bool *UNUSED(r_free))
740 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
742 if (map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
743 if (map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
744 if (map_type == KMI_TYPE_TIMER) return event_timer_type_items;
745 if (map_type == KMI_TYPE_NDOF) return event_ndof_type_items;
746 if (map_type == KMI_TYPE_TEXTINPUT) return event_textinput_type_items;
747 else return rna_enum_event_type_items;
750 static const EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop),
751 bool *UNUSED(r_free))
753 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
755 if (map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD || map_type == KMI_TYPE_NDOF)
756 return event_keymouse_value_items;
757 if (map_type == KMI_TYPE_TWEAK)
758 return event_tweak_value_items;
760 return rna_enum_event_value_items;
763 static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop),
764 bool *UNUSED(r_free))
766 wmWindowManager *wm = CTX_wm_manager(C);
770 for (kc = wm->keyconfigs.first; kc; kc = kc->next) {
771 for (km = kc->keymaps.first; km; km = km->next) {
772 /* only check if it's a modal keymap */
773 if (km->modal_items) {
775 for (kmi = km->items.first; kmi; kmi = kmi->next) {
776 if (kmi == ptr->data) {
777 return km->modal_items;
785 return rna_enum_keymap_propvalue_items; /* ERROR */
788 static int rna_KeyMapItem_any_get(PointerRNA *ptr)
790 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
792 if (kmi->shift == KM_ANY &&
793 kmi->ctrl == KM_ANY &&
794 kmi->alt == KM_ANY &&
795 kmi->oskey == KM_ANY)
804 static void rna_KeyMapItem_any_set(PointerRNA *ptr, int value)
806 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
809 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
812 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = 0;
816 static int rna_KeyMapItem_shift_get(PointerRNA *ptr)
818 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
819 return kmi->shift != 0;
822 static int rna_KeyMapItem_ctrl_get(PointerRNA *ptr)
824 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
825 return kmi->ctrl != 0;
828 static int rna_KeyMapItem_alt_get(PointerRNA *ptr)
830 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
831 return kmi->alt != 0;
834 static int rna_KeyMapItem_oskey_get(PointerRNA *ptr)
836 wmKeyMapItem *kmi = (wmKeyMapItem *)ptr->data;
837 return kmi->oskey != 0;
840 static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
842 wmWindowManager *wm = ptr->data;
845 kc = BLI_findstring(&wm->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname));
848 kc = wm->defaultconf;
850 return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
853 static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
855 wmWindowManager *wm = ptr->data;
856 wmKeyConfig *kc = value.data;
859 WM_keyconfig_set_active(wm, kc->idname);
862 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
864 wmKeyMapItem *kmi = ptr->data;
865 WM_operator_py_idname(value, kmi->idname);
868 static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
870 wmKeyMapItem *kmi = ptr->data;
871 char pyname[OP_MAX_TYPENAME];
873 WM_operator_py_idname(pyname, kmi->idname);
874 return strlen(pyname);
877 static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
879 wmKeyMapItem *kmi = ptr->data;
880 char idname[OP_MAX_TYPENAME];
882 WM_operator_bl_idname(idname, value);
884 if (!STREQ(idname, kmi->idname)) {
885 BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
887 WM_keymap_properties_reset(kmi, NULL);
891 static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
893 wmKeyMapItem *kmi = ptr->data;
894 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
895 strcpy(value, ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
898 static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
900 wmKeyMapItem *kmi = ptr->data;
901 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
902 return strlen(ot ? RNA_struct_ui_name(ot->srna) : kmi->idname);
905 static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
907 wmKeyMapItem *kmi = ptr->data;
911 static void rna_wmClipboard_get(PointerRNA *UNUSED(ptr), char *value)
916 pbuf = WM_clipboard_text_get(false, &pbuf_len);
918 memcpy(value, pbuf, pbuf_len + 1);
926 static int rna_wmClipboard_length(PointerRNA *UNUSED(ptr))
931 pbuf = WM_clipboard_text_get(false, &pbuf_len);
939 static void rna_wmClipboard_set(PointerRNA *UNUSED(ptr), const char *value)
941 WM_clipboard_text_set((void *) value, false);
946 static int rna_operator_poll_cb(bContext *C, wmOperatorType *ot)
948 extern FunctionRNA rna_Operator_poll_func;
956 RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */
957 func = &rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
959 RNA_parameter_list_create(&list, &ptr, func);
960 RNA_parameter_set_lookup(&list, "context", &C);
961 ot->ext.call(C, &ptr, func, &list);
963 RNA_parameter_get_lookup(&list, "visible", &ret);
964 visible = *(int *)ret;
966 RNA_parameter_list_free(&list);
971 static int rna_operator_execute_cb(bContext *C, wmOperator *op)
973 extern FunctionRNA rna_Operator_execute_func;
981 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
982 func = &rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
984 RNA_parameter_list_create(&list, &opr, func);
985 RNA_parameter_set_lookup(&list, "context", &C);
986 op->type->ext.call(C, &opr, func, &list);
988 RNA_parameter_get_lookup(&list, "result", &ret);
989 result = *(int *)ret;
991 RNA_parameter_list_free(&list);
996 /* same as execute() but no return value */
997 static bool rna_operator_check_cb(bContext *C, wmOperator *op)
999 extern FunctionRNA rna_Operator_check_func;
1007 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1008 func = &rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
1010 RNA_parameter_list_create(&list, &opr, func);
1011 RNA_parameter_set_lookup(&list, "context", &C);
1012 op->type->ext.call(C, &opr, func, &list);
1014 RNA_parameter_get_lookup(&list, "result", &ret);
1015 result = (*(int *)ret) != 0;
1017 RNA_parameter_list_free(&list);
1022 static int rna_operator_invoke_cb(bContext *C, wmOperator *op, const wmEvent *event)
1024 extern FunctionRNA rna_Operator_invoke_func;
1032 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1033 func = &rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
1035 RNA_parameter_list_create(&list, &opr, func);
1036 RNA_parameter_set_lookup(&list, "context", &C);
1037 RNA_parameter_set_lookup(&list, "event", &event);
1038 op->type->ext.call(C, &opr, func, &list);
1040 RNA_parameter_get_lookup(&list, "result", &ret);
1041 result = *(int *)ret;
1043 RNA_parameter_list_free(&list);
1048 /* same as invoke */
1049 static int rna_operator_modal_cb(bContext *C, wmOperator *op, const wmEvent *event)
1051 extern FunctionRNA rna_Operator_modal_func;
1059 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1060 func = &rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
1062 RNA_parameter_list_create(&list, &opr, func);
1063 RNA_parameter_set_lookup(&list, "context", &C);
1064 RNA_parameter_set_lookup(&list, "event", &event);
1065 op->type->ext.call(C, &opr, func, &list);
1067 RNA_parameter_get_lookup(&list, "result", &ret);
1068 result = *(int *)ret;
1070 RNA_parameter_list_free(&list);
1075 static void rna_operator_draw_cb(bContext *C, wmOperator *op)
1077 extern FunctionRNA rna_Operator_draw_func;
1083 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1084 func = &rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
1086 RNA_parameter_list_create(&list, &opr, func);
1087 RNA_parameter_set_lookup(&list, "context", &C);
1088 op->type->ext.call(C, &opr, func, &list);
1090 RNA_parameter_list_free(&list);
1093 /* same as exec(), but call cancel */
1094 static void rna_operator_cancel_cb(bContext *C, wmOperator *op)
1096 extern FunctionRNA rna_Operator_cancel_func;
1102 RNA_pointer_create(NULL, op->type->ext.srna, op, &opr);
1103 func = &rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
1105 RNA_parameter_list_create(&list, &opr, func);
1106 RNA_parameter_set_lookup(&list, "context", &C);
1107 op->type->ext.call(C, &opr, func, &list);
1109 RNA_parameter_list_free(&list);
1112 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type);
1114 /* bpy_operator_wrap.c */
1115 extern void BPY_RNA_operator_wrapper(wmOperatorType *ot, void *userdata);
1116 extern void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata);
1118 static StructRNA *rna_Operator_register(
1119 Main *bmain, ReportList *reports, void *data, const char *identifier,
1120 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1122 wmOperatorType dummyot = {NULL};
1123 wmOperator dummyop = {NULL};
1124 PointerRNA dummyotr;
1125 int have_function[7];
1128 char idname[OP_MAX_TYPENAME];
1129 char name[OP_MAX_TYPENAME];
1130 char description[RNA_DYN_DESCR_MAX];
1131 char translation_context[RNA_DYN_DESCR_MAX];
1132 char undo_group[OP_MAX_TYPENAME];
1135 /* setup dummy operator & operator type to store static properties in */
1136 dummyop.type = &dummyot;
1137 dummyot.idname = temp_buffers.idname; /* only assigne the pointer, string is NULL'd */
1138 dummyot.name = temp_buffers.name; /* only assigne the pointer, string is NULL'd */
1139 dummyot.description = temp_buffers.description; /* only assigne the pointer, string is NULL'd */
1140 dummyot.translation_context = temp_buffers.translation_context; /* only assigne the pointer, string is NULL'd */
1141 dummyot.undo_group = temp_buffers.undo_group; /* only assigne the pointer, string is NULL'd */
1142 RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
1144 /* clear in case they are left unset */
1145 temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = temp_buffers.undo_group[0] = '\0';
1146 /* We have to set default op context! */
1147 strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1149 /* validate the python class */
1150 if (validate(&dummyotr, data, have_function) != 0)
1153 /* check if we have registered this operator type before, and remove it */
1155 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
1156 if (ot && ot->ext.srna)
1157 rna_Operator_unregister(bmain, ot->ext.srna);
1160 if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) {
1164 char idname_conv[sizeof(dummyop.idname)];
1165 WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */
1167 if (!RNA_struct_available_or_report(reports, idname_conv)) {
1171 /* Convert foo.bar to FOO_OT_bar
1172 * allocate all strings at once. */
1174 const char *strings[] = {
1177 temp_buffers.description,
1178 temp_buffers.translation_context,
1179 temp_buffers.undo_group,
1181 char *strings_table[ARRAY_SIZE(strings)];
1182 BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
1184 dummyot.idname = strings_table[0]; /* allocated string stored here */
1185 dummyot.name = strings_table[1];
1186 dummyot.description = strings_table[2];
1187 dummyot.translation_context = strings_table[3];
1188 dummyot.undo_group = strings_table[4];
1189 BLI_assert(ARRAY_SIZE(strings) == 5);
1192 /* XXX, this doubles up with the operator name [#29666]
1193 * for now just remove from dir(bpy.types) */
1195 /* create a new operator type */
1196 dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator);
1197 RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
1198 RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context);
1199 dummyot.ext.data = data;
1200 dummyot.ext.call = call;
1201 dummyot.ext.free = free;
1203 dummyot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : NULL;
1204 dummyot.exec = (have_function[1]) ? rna_operator_execute_cb : NULL;
1205 dummyot.check = (have_function[2]) ? rna_operator_check_cb : NULL;
1206 dummyot.invoke = (have_function[3]) ? rna_operator_invoke_cb : NULL;
1207 dummyot.modal = (have_function[4]) ? rna_operator_modal_cb : NULL;
1208 dummyot.ui = (have_function[5]) ? rna_operator_draw_cb : NULL;
1209 dummyot.cancel = (have_function[6]) ? rna_operator_cancel_cb : NULL;
1210 WM_operatortype_append_ptr(BPY_RNA_operator_wrapper, (void *)&dummyot);
1212 /* update while blender is running */
1213 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1215 return dummyot.ext.srna;
1218 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
1221 wmOperatorType *ot = RNA_struct_blender_type_get(type);
1222 wmWindowManager *wm;
1227 /* update while blender is running */
1228 wm = bmain->wm.first;
1230 WM_operator_stack_clear(wm);
1232 WM_operator_handlers_clear(wm, ot);
1234 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1236 RNA_struct_free_extension(type, &ot->ext);
1238 idname = ot->idname;
1239 WM_operatortype_remove_ptr(ot);
1241 /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
1242 RNA_struct_free(&BLENDER_RNA, type);
1244 MEM_freeN((void *)idname);
1247 static void **rna_Operator_instance(PointerRNA *ptr)
1249 wmOperator *op = ptr->data;
1250 return &op->py_instance;
1253 static StructRNA *rna_MacroOperator_register(
1254 Main *bmain, ReportList *reports, void *data, const char *identifier,
1255 StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
1257 wmOperatorType dummyot = {NULL};
1258 wmOperator dummyop = {NULL};
1259 PointerRNA dummyotr;
1260 int have_function[4];
1263 char idname[OP_MAX_TYPENAME];
1264 char name[OP_MAX_TYPENAME];
1265 char description[RNA_DYN_DESCR_MAX];
1266 char translation_context[RNA_DYN_DESCR_MAX];
1267 char undo_group[OP_MAX_TYPENAME];
1270 /* setup dummy operator & operator type to store static properties in */
1271 dummyop.type = &dummyot;
1272 dummyot.idname = temp_buffers.idname; /* only assigne the pointer, string is NULL'd */
1273 dummyot.name = temp_buffers.name; /* only assigne the pointer, string is NULL'd */
1274 dummyot.description = temp_buffers.description; /* only assigne the pointer, string is NULL'd */
1275 dummyot.translation_context = temp_buffers.translation_context; /* only assigne the pointer, string is NULL'd */
1276 dummyot.undo_group = temp_buffers.undo_group; /* only assigne the pointer, string is NULL'd */
1277 RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr);
1279 /* clear in case they are left unset */
1280 temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] = temp_buffers.undo_group[0] = '\0';
1281 /* We have to set default op context! */
1282 strcpy(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1284 /* validate the python class */
1285 if (validate(&dummyotr, data, have_function) != 0)
1288 if (strlen(identifier) >= sizeof(dummyop.idname)) {
1289 BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s' is too long, maximum length is %d",
1290 identifier, (int)sizeof(dummyop.idname));
1294 /* check if we have registered this operator type before, and remove it */
1296 wmOperatorType *ot = WM_operatortype_find(dummyot.idname, true);
1297 if (ot && ot->ext.srna)
1298 rna_Operator_unregister(bmain, ot->ext.srna);
1301 if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummyot.idname)) {
1305 char idname_conv[sizeof(dummyop.idname)];
1306 WM_operator_bl_idname(idname_conv, dummyot.idname); /* convert the idname from python */
1308 if (!RNA_struct_available_or_report(reports, idname_conv)) {
1312 /* Convert foo.bar to FOO_OT_bar
1313 * allocate all strings at once. */
1315 const char *strings[] = {
1318 temp_buffers.description,
1319 temp_buffers.translation_context,
1320 temp_buffers.undo_group,
1322 char *strings_table[ARRAY_SIZE(strings)];
1323 BLI_string_join_array_by_sep_char_with_tableN('\0', strings_table, strings, ARRAY_SIZE(strings));
1325 dummyot.idname = strings_table[0]; /* allocated string stored here */
1326 dummyot.name = strings_table[1];
1327 dummyot.description = strings_table[2];
1328 dummyot.translation_context = strings_table[3];
1329 dummyot.undo_group = strings_table[4];
1330 BLI_assert(ARRAY_SIZE(strings) == 5);
1333 /* XXX, this doubles up with the operator name [#29666]
1334 * for now just remove from dir(bpy.types) */
1336 /* create a new operator type */
1337 dummyot.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummyot.idname, &RNA_Operator);
1338 RNA_def_struct_translation_context(dummyot.ext.srna, dummyot.translation_context);
1339 dummyot.ext.data = data;
1340 dummyot.ext.call = call;
1341 dummyot.ext.free = free;
1343 dummyot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : NULL;
1344 dummyot.ui = (have_function[3]) ? rna_operator_draw_cb : NULL;
1346 WM_operatortype_append_macro_ptr(BPY_RNA_operator_macro_wrapper, (void *)&dummyot);
1348 /* update while blender is running */
1349 WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL);
1351 return dummyot.ext.srna;
1353 #endif /* WITH_PYTHON */
1355 static StructRNA *rna_Operator_refine(PointerRNA *opr)
1357 wmOperator *op = (wmOperator *)opr->data;
1358 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Operator;
1361 static StructRNA *rna_MacroOperator_refine(PointerRNA *opr)
1363 wmOperator *op = (wmOperator *)opr->data;
1364 return (op->type && op->type->ext.srna) ? op->type->ext.srna : &RNA_Macro;
1367 /* just to work around 'const char *' warning and to ensure this is a python op */
1368 static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
1370 wmOperator *data = (wmOperator *)(ptr->data);
1371 char *str = (char *)data->type->idname;
1373 BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
1375 assert(!"setting the bl_idname on a non-builtin operator");
1378 static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
1380 wmOperator *data = (wmOperator *)(ptr->data);
1381 char *str = (char *)data->type->name;
1383 BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
1385 assert(!"setting the bl_label on a non-builtin operator");
1388 static void rna_Operator_bl_translation_context_set(PointerRNA *ptr, const char *value)
1390 wmOperator *data = (wmOperator *)(ptr->data);
1391 char *str = (char *)data->type->translation_context;
1393 BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1395 assert(!"setting the bl_translation_context on a non-builtin operator");
1398 static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
1400 wmOperator *data = (wmOperator *)(ptr->data);
1401 char *str = (char *)data->type->description;
1403 BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */
1405 assert(!"setting the bl_description on a non-builtin operator");
1408 static void rna_Operator_bl_undo_group_set(PointerRNA *ptr, const char *value)
1410 wmOperator *data = (wmOperator *)(ptr->data);
1411 char *str = (char *)data->type->undo_group;
1413 BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */
1415 assert(!"setting the bl_undo_group on a non-builtin operator");
1418 static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
1420 wmKeyMapItem *kmi = ptr->data;
1421 WM_keyconfig_update_tag(NULL, kmi);
1424 #else /* RNA_RUNTIME */
1427 * expose ``Operator.options`` as its own type so we can control each flags use (some are read-only).
1429 static void rna_def_operator_options_runtime(BlenderRNA *brna)
1434 srna = RNA_def_struct(brna, "OperatorOptions", NULL);
1435 RNA_def_struct_ui_text(srna, "Operator Options", "Runtime options");
1436 RNA_def_struct_sdna(srna, "wmOperator");
1438 prop = RNA_def_property(srna, "is_grab_cursor", PROP_BOOLEAN, PROP_BOOLEAN);
1439 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_MODAL_GRAB_CURSOR);
1440 RNA_def_property_ui_text(prop, "Grab Cursor", "True when the cursor is grabbed");
1441 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1443 prop = RNA_def_property(srna, "is_invoke", PROP_BOOLEAN, PROP_BOOLEAN);
1444 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_INVOKE);
1445 RNA_def_property_ui_text(prop, "Invoke", "True when invoked (even if only the execute callbacks available)");
1446 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1448 prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_BOOLEAN);
1449 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_REPEAT);
1450 RNA_def_property_ui_text(prop, "Repeat", "True when run from the redo panel");
1451 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1453 prop = RNA_def_property(srna, "use_cursor_region", PROP_BOOLEAN, PROP_BOOLEAN);
1454 RNA_def_property_boolean_sdna(prop, NULL, "flag", OP_IS_MODAL_CURSOR_REGION);
1455 RNA_def_property_ui_text(prop, "Focus Region", "Enable to use the region under the cursor for modal execution");
1458 static void rna_def_operator(BlenderRNA *brna)
1463 srna = RNA_def_struct(brna, "Operator", NULL);
1464 RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution");
1465 RNA_def_struct_sdna(srna, "wmOperator");
1466 RNA_def_struct_refine_func(srna, "rna_Operator_refine");
1468 RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
1470 RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1471 RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
1473 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1474 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1475 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1476 RNA_def_property_ui_text(prop, "Name", "");
1478 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1479 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1480 RNA_def_property_struct_type(prop, "OperatorProperties");
1481 RNA_def_property_ui_text(prop, "Properties", "");
1482 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1484 prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
1485 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
1486 RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", NULL);
1487 RNA_def_property_ui_text(prop, "Has Reports",
1488 "Operator has a set of reports (warnings and errors) from last execution");
1490 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1491 RNA_def_property_struct_type(prop, "UILayout");
1493 prop = RNA_def_property(srna, "options", PROP_POINTER, PROP_NONE);
1494 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1495 RNA_def_property_struct_type(prop, "OperatorOptions");
1496 RNA_def_property_pointer_funcs(prop, "rna_Operator_options_get", NULL, NULL, NULL);
1497 RNA_def_property_ui_text(prop, "Options", "Runtime options");
1500 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1501 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1502 /* else it uses the pointer size!. -3 because '.' -> '_OT_' */
1503 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME - 3);
1504 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1505 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1506 RNA_def_property_flag(prop, PROP_REGISTER);
1507 RNA_def_struct_name_property(srna, prop);
1509 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1510 RNA_def_property_string_sdna(prop, NULL, "type->name");
1511 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1512 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1513 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1514 RNA_def_property_flag(prop, PROP_REGISTER);
1516 prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
1517 RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
1518 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1519 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_translation_context_set");
1520 RNA_def_property_string_default(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1521 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1522 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1524 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1525 RNA_def_property_string_sdna(prop, NULL, "type->description");
1526 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1527 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1528 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1529 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1530 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1532 prop = RNA_def_property(srna, "bl_undo_group", PROP_STRING, PROP_NONE);
1533 RNA_def_property_string_sdna(prop, NULL, "type->undo_group");
1534 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1535 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_undo_group_set");
1536 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1537 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1538 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1540 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1541 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1542 RNA_def_property_enum_items(prop, operator_flag_items);
1543 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1544 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1546 prop = RNA_def_property(srna, "macros", PROP_COLLECTION, PROP_NONE);
1547 RNA_def_property_collection_sdna(prop, NULL, "macro", NULL);
1548 RNA_def_property_struct_type(prop, "Macro");
1549 RNA_def_property_ui_text(prop, "Macros", "");
1551 RNA_api_operator(srna);
1553 srna = RNA_def_struct(brna, "OperatorProperties", NULL);
1554 RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator");
1555 RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
1556 RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops");
1557 RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES);
1560 static void rna_def_macro_operator(BlenderRNA *brna)
1565 srna = RNA_def_struct(brna, "Macro", NULL);
1566 RNA_def_struct_ui_text(srna, "Macro Operator",
1567 "Storage of a macro operator being executed, or registered after execution");
1568 RNA_def_struct_sdna(srna, "wmOperator");
1569 RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
1571 RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister",
1572 "rna_Operator_instance");
1574 RNA_def_struct_translation_context(srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1575 RNA_def_struct_flag(srna, STRUCT_PUBLIC_NAMESPACE_INHERIT);
1577 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1578 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1579 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1580 RNA_def_property_ui_text(prop, "Name", "");
1582 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1583 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1584 RNA_def_property_struct_type(prop, "OperatorProperties");
1585 RNA_def_property_ui_text(prop, "Properties", "");
1586 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1589 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1590 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1591 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1592 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1593 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1594 RNA_def_property_flag(prop, PROP_REGISTER);
1595 RNA_def_struct_name_property(srna, prop);
1597 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1598 RNA_def_property_string_sdna(prop, NULL, "type->name");
1599 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1600 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1601 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1602 RNA_def_property_flag(prop, PROP_REGISTER);
1604 prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
1605 RNA_def_property_string_sdna(prop, NULL, "type->translation_context");
1606 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1607 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_translation_context_set");
1608 RNA_def_property_string_default(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1609 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1610 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1612 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1613 RNA_def_property_string_sdna(prop, NULL, "type->description");
1614 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
1615 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1616 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1617 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1618 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1620 prop = RNA_def_property(srna, "bl_undo_group", PROP_STRING, PROP_NONE);
1621 RNA_def_property_string_sdna(prop, NULL, "type->undo_group");
1622 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1623 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_undo_group_set");
1624 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1625 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1626 RNA_def_property_clear_flag(prop, PROP_NEVER_NULL); /* check for NULL */
1628 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1629 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1630 RNA_def_property_enum_items(prop, operator_flag_items);
1631 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG);
1632 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1634 RNA_api_macro(srna);
1637 static void rna_def_operator_type_macro(BlenderRNA *brna)
1642 srna = RNA_def_struct(brna, "OperatorMacro", NULL);
1643 RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added");
1644 RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
1646 /* prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */
1647 /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */
1648 /* RNA_def_property_string_sdna(prop, NULL, "idname"); */
1649 /* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */
1650 /* RNA_def_struct_name_property(srna, prop); */
1652 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1653 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1654 RNA_def_property_struct_type(prop, "OperatorProperties");
1655 RNA_def_property_ui_text(prop, "Properties", "");
1656 RNA_def_property_pointer_funcs(prop, "rna_OperatorMacro_properties_get", NULL, NULL, NULL);
1659 static void rna_def_operator_utils(BlenderRNA *brna)
1664 srna = RNA_def_struct(brna, "OperatorMousePath", "PropertyGroup");
1665 RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths");
1667 prop = RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
1668 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1669 RNA_def_property_array(prop, 2);
1670 RNA_def_property_ui_text(prop, "Location", "Mouse location");
1672 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
1673 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1674 RNA_def_property_ui_text(prop, "Time", "Time of mouse location");
1677 static void rna_def_operator_filelist_element(BlenderRNA *brna)
1682 srna = RNA_def_struct(brna, "OperatorFileListElement", "PropertyGroup");
1683 RNA_def_struct_ui_text(srna, "Operator File List Element", "");
1686 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
1687 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1688 RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list");
1691 static void rna_def_event(BlenderRNA *brna)
1696 srna = RNA_def_struct(brna, "Event", NULL);
1697 RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
1698 RNA_def_struct_sdna(srna, "wmEvent");
1700 RNA_define_verify_sdna(0); /* not in sdna */
1703 prop = RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
1704 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1705 RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
1706 RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
1709 prop = RNA_def_property(srna, "unicode", PROP_STRING, PROP_NONE);
1710 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1711 RNA_def_property_string_funcs(prop, "rna_Event_unicode_get", "rna_Event_unicode_length", NULL);
1712 RNA_def_property_ui_text(prop, "Unicode", "Single unicode character for this event");
1715 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1716 RNA_def_property_enum_sdna(prop, NULL, "val");
1717 RNA_def_property_enum_items(prop, rna_enum_event_value_items);
1718 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1719 RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
1721 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1722 RNA_def_property_enum_sdna(prop, NULL, "type");
1723 RNA_def_property_enum_items(prop, rna_enum_event_type_items);
1724 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
1725 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1726 RNA_def_property_ui_text(prop, "Type", "");
1730 prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
1731 RNA_def_property_int_sdna(prop, NULL, "x");
1732 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1733 RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative horizontal location of the mouse");
1735 prop = RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
1736 RNA_def_property_int_sdna(prop, NULL, "y");
1737 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1738 RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative vertical location of the mouse");
1740 prop = RNA_def_property(srna, "mouse_region_x", PROP_INT, PROP_NONE);
1741 RNA_def_property_int_sdna(prop, NULL, "mval[0]");
1742 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1743 RNA_def_property_ui_text(prop, "Mouse X Position", "The region relative horizontal location of the mouse");
1745 prop = RNA_def_property(srna, "mouse_region_y", PROP_INT, PROP_NONE);
1746 RNA_def_property_int_sdna(prop, NULL, "mval[1]");
1747 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1748 RNA_def_property_ui_text(prop, "Mouse Y Position", "The region relative vertical location of the mouse");
1750 prop = RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
1751 RNA_def_property_int_sdna(prop, NULL, "prevx");
1752 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1753 RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative horizontal location of the mouse");
1755 prop = RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
1756 RNA_def_property_int_sdna(prop, NULL, "prevy");
1757 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1758 RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative vertical location of the mouse");
1760 prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
1761 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1762 RNA_def_property_float_funcs(prop, "rna_Event_pressure_get", NULL, NULL);
1763 RNA_def_property_ui_text(prop, "Tablet Pressure", "The pressure of the tablet or 1.0 if no tablet present");
1765 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_XYZ_LENGTH);
1766 RNA_def_property_array(prop, 2);
1767 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1768 RNA_def_property_float_funcs(prop, "rna_Event_tilt_get", NULL, NULL);
1769 RNA_def_property_ui_text(prop, "Tablet Tilt", "The pressure of the tablet or zeroes if no tablet present");
1771 prop = RNA_def_property(srna, "is_tablet", PROP_BOOLEAN, PROP_NONE);
1772 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1773 RNA_def_property_boolean_funcs(prop, "rna_Event_is_tablet_get", NULL);
1774 RNA_def_property_ui_text(prop, "Is Tablet", "The event has tablet data");
1776 prop = RNA_def_property(srna, "is_mouse_absolute", PROP_BOOLEAN, PROP_NONE);
1777 RNA_def_property_boolean_sdna(prop, NULL, "is_motion_absolute", 1);
1778 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1779 RNA_def_property_ui_text(prop, "Absolute Motion", "The last motion event was an absolute input");
1782 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1783 RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
1784 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1785 RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
1787 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1788 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
1789 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1790 RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
1792 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1793 RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
1794 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1795 RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
1797 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1798 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
1799 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1800 RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held");
1802 RNA_define_verify_sdna(1); /* not in sdna */
1805 static void rna_def_timer(BlenderRNA *brna)
1810 srna = RNA_def_struct(brna, "Timer", NULL);
1811 RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
1812 RNA_def_struct_sdna(srna, "wmTimer");
1814 RNA_define_verify_sdna(0); /* not in sdna */
1816 /* could wrap more, for now this is enough */
1817 prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
1818 RNA_def_property_float_sdna(prop, NULL, "timestep");
1819 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1820 RNA_def_property_ui_text(prop, "Time Step", "");
1822 prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
1823 RNA_def_property_float_sdna(prop, NULL, "delta");
1824 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1825 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1827 prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
1828 RNA_def_property_float_sdna(prop, NULL, "duration");
1829 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1830 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1832 RNA_define_verify_sdna(1); /* not in sdna */
1835 static void rna_def_popup_menu_wrapper(
1836 BlenderRNA *brna, const char *rna_type, const char *c_type, const char *layout_get_fn)
1841 srna = RNA_def_struct(brna, rna_type, NULL);
1842 /* UI name isn't visible, name same as type. */
1843 RNA_def_struct_ui_text(srna, rna_type, "");
1844 RNA_def_struct_sdna(srna, c_type);
1846 RNA_define_verify_sdna(0); /* not in sdna */
1848 /* could wrap more, for now this is enough */
1849 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1850 RNA_def_property_struct_type(prop, "UILayout");
1851 RNA_def_property_pointer_funcs(prop, layout_get_fn,
1854 RNA_define_verify_sdna(1); /* not in sdna */
1857 static void rna_def_popupmenu(BlenderRNA *brna)
1859 rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "uiPopupMenu", "rna_PopupMenu_layout_get");
1862 static void rna_def_piemenu(BlenderRNA *brna)
1864 rna_def_popup_menu_wrapper(brna, "UIPieMenu", "uiPieMenu", "rna_PieMenu_layout_get");
1867 static void rna_def_window_stereo3d(BlenderRNA *brna)
1872 srna = RNA_def_struct(brna, "Stereo3dDisplay", NULL);
1873 RNA_def_struct_sdna(srna, "Stereo3dFormat");
1874 RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
1875 RNA_def_struct_ui_text(srna, "Stereo 3D Display", "Settings for stereo 3D display");
1877 prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
1878 RNA_def_property_enum_items(prop, rna_enum_stereo3d_display_items);
1879 RNA_def_property_ui_text(prop, "Display Mode", "");
1881 prop = RNA_def_property(srna, "anaglyph_type", PROP_ENUM, PROP_NONE);
1882 RNA_def_property_enum_items(prop, rna_enum_stereo3d_anaglyph_type_items);
1883 RNA_def_property_ui_text(prop, "Anaglyph Type", "");
1885 prop = RNA_def_property(srna, "interlace_type", PROP_ENUM, PROP_NONE);
1886 RNA_def_property_enum_items(prop, rna_enum_stereo3d_interlace_type_items);
1887 RNA_def_property_ui_text(prop, "Interlace Type", "");
1889 prop = RNA_def_property(srna, "use_interlace_swap", PROP_BOOLEAN, PROP_BOOLEAN);
1890 RNA_def_property_boolean_sdna(prop, NULL, "flag", S3D_INTERLACE_SWAP);
1891 RNA_def_property_ui_text(prop, "Swap Left/Right", "Swap left and right stereo channels");
1893 prop = RNA_def_property(srna, "use_sidebyside_crosseyed", PROP_BOOLEAN, PROP_BOOLEAN);
1894 RNA_def_property_boolean_sdna(prop, NULL, "flag", S3D_SIDEBYSIDE_CROSSEYED);
1895 RNA_def_property_ui_text(prop, "Cross-Eyed", "Right eye should see left image and vice-versa");
1898 static void rna_def_window(BlenderRNA *brna)
1903 srna = RNA_def_struct(brna, "Window", NULL);
1904 RNA_def_struct_ui_text(srna, "Window", "Open window");
1905 RNA_def_struct_sdna(srna, "wmWindow");
1907 rna_def_window_stereo3d(brna);
1909 prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
1910 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1911 RNA_def_property_struct_type(prop, "Screen");
1912 RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window");
1913 RNA_def_property_flag(prop, PROP_EDITABLE);
1914 RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, "rna_Window_screen_assign_poll");
1915 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1916 RNA_def_property_update(prop, 0, "rna_Window_screen_update");
1918 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
1919 RNA_def_property_int_sdna(prop, NULL, "posx");
1920 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1921 RNA_def_property_ui_text(prop, "X Position", "Horizontal location of the window");
1923 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
1924 RNA_def_property_int_sdna(prop, NULL, "posy");
1925 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1926 RNA_def_property_ui_text(prop, "Y Position", "Vertical location of the window");
1928 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
1929 RNA_def_property_int_sdna(prop, NULL, "sizex");
1930 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1931 RNA_def_property_ui_text(prop, "Width", "Window width");
1933 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
1934 RNA_def_property_int_sdna(prop, NULL, "sizey");
1935 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1936 RNA_def_property_ui_text(prop, "Height", "Window height");
1938 prop = RNA_def_property(srna, "stereo_3d_display", PROP_POINTER, PROP_NONE);
1939 RNA_def_property_pointer_sdna(prop, NULL, "stereo3d_format");
1940 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1941 RNA_def_property_struct_type(prop, "Stereo3dDisplay");
1942 RNA_def_property_ui_text(prop, "Stereo 3D Display", "Settings for stereo 3d display");
1944 RNA_api_window(srna);
1948 static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
1953 RNA_def_property_srna(cprop, "KeyConfigurations");
1954 srna = RNA_def_struct(brna, "KeyConfigurations", NULL);
1955 RNA_def_struct_sdna(srna, "wmWindowManager");
1956 RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs");
1958 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1959 RNA_def_property_struct_type(prop, "KeyConfig");
1960 RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get",
1961 "rna_WindowManager_active_keyconfig_set", NULL, NULL);
1962 RNA_def_property_flag(prop, PROP_EDITABLE);
1963 RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
1965 prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
1966 RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
1967 RNA_def_property_struct_type(prop, "KeyConfig");
1968 RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
1970 prop = RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
1971 RNA_def_property_pointer_sdna(prop, NULL, "addonconf");
1972 RNA_def_property_struct_type(prop, "KeyConfig");
1973 RNA_def_property_ui_text(prop, "Add-on Key Configuration",
1974 "Key configuration that can be extended by add-ons, and is added to the active "
1975 "configuration when handling events");
1977 prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
1978 RNA_def_property_pointer_sdna(prop, NULL, "userconf");
1979 RNA_def_property_struct_type(prop, "KeyConfig");
1980 RNA_def_property_ui_text(prop, "User Key Configuration",
1981 "Final key configuration that combines keymaps from the active and add-on configurations, "
1982 "and can be edited by the user");
1984 RNA_api_keyconfigs(srna);
1987 static void rna_def_windowmanager(BlenderRNA *brna)
1992 srna = RNA_def_struct(brna, "WindowManager", "ID");
1993 RNA_def_struct_ui_text(srna, "Window Manager",
1994 "Window manager data-block defining open windows and other user interface data");
1995 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1996 RNA_def_struct_sdna(srna, "wmWindowManager");
1998 prop = RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
1999 RNA_def_property_struct_type(prop, "Operator");
2000 RNA_def_property_ui_text(prop, "Operators", "Operator registry");
2002 prop = RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
2003 RNA_def_property_struct_type(prop, "Window");
2004 RNA_def_property_ui_text(prop, "Windows", "Open windows");
2006 prop = RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
2007 RNA_def_property_struct_type(prop, "KeyConfig");
2008 RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations");
2009 rna_def_wm_keyconfigs(brna, prop);
2011 prop = RNA_def_property(srna, "clipboard", PROP_STRING, PROP_NONE);
2012 RNA_def_property_string_funcs(prop, "rna_wmClipboard_get", "rna_wmClipboard_length", "rna_wmClipboard_set");
2013 RNA_def_property_ui_text(prop, "Text Clipboard", "");
2018 /* keyconfig.items */
2019 static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
2023 RNA_def_property_srna(cprop, "KeyMapItems");
2024 srna = RNA_def_struct(brna, "KeyMapItems", NULL);
2025 RNA_def_struct_sdna(srna, "wmKeyMap");
2026 RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
2028 RNA_api_keymapitems(srna);
2031 static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
2035 RNA_def_property_srna(cprop, "KeyMaps");
2036 srna = RNA_def_struct(brna, "KeyMaps", NULL);
2037 RNA_def_struct_sdna(srna, "wmKeyConfig");
2038 RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
2040 RNA_api_keymaps(srna);
2043 static void rna_def_keyconfig(BlenderRNA *brna)
2048 static const EnumPropertyItem map_type_items[] = {
2049 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
2050 {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
2051 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
2052 {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
2053 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
2054 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
2055 {0, NULL, 0, NULL, NULL}
2059 srna = RNA_def_struct(brna, "KeyConfig", NULL);
2060 RNA_def_struct_sdna(srna, "wmKeyConfig");
2061 RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps");
2063 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2064 RNA_def_property_string_sdna(prop, NULL, "idname");
2065 RNA_def_property_ui_text(prop, "Name", "Name of the key configuration");
2066 RNA_def_struct_name_property(srna, prop);
2068 prop = RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
2069 RNA_def_property_struct_type(prop, "KeyMap");
2070 RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration");
2071 rna_def_wm_keymaps(brna, prop);
2073 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
2074 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYCONF_USER);
2075 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2076 RNA_def_property_ui_text(prop, "User Defined", "Indicates that a keyconfig was defined by the user");
2078 RNA_api_keyconfig(srna);
2081 srna = RNA_def_struct(brna, "KeyMap", NULL);
2082 RNA_def_struct_sdna(srna, "wmKeyMap");
2083 RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps");
2085 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2086 RNA_def_property_string_sdna(prop, NULL, "idname");
2087 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2088 RNA_def_property_ui_text(prop, "Name", "Name of the key map");
2089 RNA_def_struct_name_property(srna, prop);
2091 prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
2092 RNA_def_property_enum_sdna(prop, NULL, "spaceid");
2093 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2094 RNA_def_property_enum_items(prop, rna_enum_space_type_items);
2095 RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with");
2097 prop = RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
2098 RNA_def_property_enum_sdna(prop, NULL, "regionid");
2099 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2100 RNA_def_property_enum_items(prop, rna_enum_region_type_items);
2101 RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with");
2103 prop = RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE);
2104 RNA_def_property_collection_sdna(prop, NULL, "items", NULL);
2105 RNA_def_property_struct_type(prop, "KeyMapItem");
2106 RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event");
2107 rna_def_keymap_items(brna, prop);
2109 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
2110 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER_MODIFIED);
2111 RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
2113 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
2114 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_MODAL);
2115 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2116 RNA_def_property_ui_text(prop, "Modal Keymap",
2117 "Indicates that a keymap is used for translate modal events for an operator");
2119 prop = RNA_def_property(srna, "show_expanded_items", PROP_BOOLEAN, PROP_NONE);
2120 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_EXPANDED);
2121 RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
2122 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2124 prop = RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
2125 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_CHILDREN_EXPANDED);
2126 RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
2127 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2130 RNA_api_keymap(srna);
2133 srna = RNA_def_struct(brna, "KeyMapItem", NULL);
2134 RNA_def_struct_sdna(srna, "wmKeyMapItem");
2135 RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map");
2137 prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
2138 RNA_def_property_string_sdna(prop, NULL, "idname");
2139 RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
2140 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length",
2141 "rna_wmKeyMapItem_idname_set");
2142 RNA_def_struct_name_property(srna, prop);
2143 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2145 /* this is in fact the operator name, but if the operator can't be found we
2146 * fallback on the operator ID */
2147 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2148 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2149 RNA_def_property_ui_text(prop, "Name", "Name of operator (translated) to call on input event");
2150 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
2152 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
2153 RNA_def_property_struct_type(prop, "OperatorProperties");
2154 RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
2155 RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
2156 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2158 prop = RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
2159 RNA_def_property_enum_sdna(prop, NULL, "maptype");
2160 RNA_def_property_enum_items(prop, map_type_items);
2161 RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
2162 RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
2163 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2165 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2166 RNA_def_property_enum_sdna(prop, NULL, "type");
2167 RNA_def_property_enum_items(prop, rna_enum_event_type_items);
2168 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
2169 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
2170 RNA_def_property_ui_text(prop, "Type", "Type of event");
2171 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2173 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
2174 RNA_def_property_enum_sdna(prop, NULL, "val");
2175 RNA_def_property_enum_items(prop, rna_enum_event_value_items);
2176 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
2177 RNA_def_property_ui_text(prop, "Value", "");
2178 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2180 prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
2181 RNA_def_property_int_sdna(prop, NULL, "id");
2182 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2183 RNA_def_property_ui_text(prop, "ID", "ID of the item");
2184 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2186 prop = RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
2187 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_get", "rna_KeyMapItem_any_set");
2188 RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
2189 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2191 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
2192 RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
2193 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_shift_get", NULL);
2194 /* RNA_def_property_enum_sdna(prop, NULL, "shift"); */
2195 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2196 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
2197 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2199 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
2200 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
2201 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_ctrl_get", NULL);
2202 /* RNA_def_property_enum_sdna(prop, NULL, "ctrl"); */
2203 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2204 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
2205 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2207 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
2208 RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
2209 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_alt_get", NULL);
2210 /* RNA_def_property_enum_sdna(prop, NULL, "alt"); */
2211 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2212 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
2213 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2215 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
2216 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
2217 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_oskey_get", NULL);
2218 /* RNA_def_property_enum_sdna(prop, NULL, "oskey"); */
2219 /* RNA_def_property_enum_items(prop, keymap_modifiers_items); */
2220 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
2221 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2223 prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
2224 RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
2225 RNA_def_property_enum_items(prop, rna_enum_event_type_items);
2226 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UI_EVENTS);
2227 RNA_def_property_enum_funcs(prop, NULL, "rna_wmKeyMapItem_keymodifier_set", NULL);
2228 RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
2229 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2231 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
2232 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
2233 RNA_def_property_ui_text(prop, "Expanded", "Show key map event and property details in the user interface");
2234 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2236 prop = RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
2237 RNA_def_property_enum_sdna(prop, NULL, "propvalue");
2238 RNA_def_property_enum_items(prop, rna_enum_keymap_propvalue_items);
2239 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
2240 RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap");
2241 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2243 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
2244 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
2245 RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
2246 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
2247 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
2249 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
2250 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_USER_MODIFIED);
2251 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2252 RNA_def_property_ui_text(prop, "User Modified", "Is this keymap item modified by the user");
2254 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
2255 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2256 RNA_def_property_ui_text(prop, "User Defined",
2257 "Is this keymap item user defined (doesn't just replace a builtin item)");
2258 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", NULL);
2260 RNA_api_keymapitem(srna);
2263 void RNA_def_wm(BlenderRNA *brna)
2265 rna_def_operator(brna);
2266 rna_def_operator_options_runtime(brna);
2267 rna_def_operator_utils(brna);
2268 rna_def_operator_filelist_element(brna);
2269 rna_def_macro_operator(brna);
2270 rna_def_operator_type_macro(brna);
2271 rna_def_event(brna);
2272 rna_def_timer(brna);
2273 rna_def_popupmenu(brna);
2274 rna_def_piemenu(brna);
2275 rna_def_window(brna);
2276 rna_def_windowmanager(brna);
2277 rna_def_keyconfig(brna);
2280 #endif /* RNA_RUNTIME */