Blender V5.3
rna_wm.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "DNA_scene_types.h"
13
14#include "BLI_path_utils.hh"
16
17#include "BLT_translation.hh"
18
19#include "BKE_screen.hh"
20
21#include "RNA_define.hh"
22#include "RNA_enum_types.hh"
23
24#include "rna_internal.hh"
25
26#include "UI_interface_c.hh"
28
29#include "WM_api.hh"
30#include "WM_keymap.hh"
31#include "WM_types.hh"
32
33#ifdef RNA_RUNTIME
34
35# include "DNA_userdef_types.h"
36
37# include "BLI_listbase.hh"
38# include "BLI_math_vector_c.hh"
39# include "BLI_string.hh"
40# include "BLI_string_utf8.hh"
41
42# include "BKE_keyconfig.h"
43# include "BKE_main.hh"
44# include "BKE_report.hh"
45# include "BKE_wm_runtime.hh"
46# include "BKE_workspace.hh"
47
48# include "wm_event_system.hh"
49
50namespace blender {
51
52static const EnumPropertyItem event_mouse_type_items[] = {
53 {LEFTMOUSE, "LEFTMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Left"), ""},
54 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Middle"), ""},
55 {RIGHTMOUSE, "RIGHTMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Right"), ""},
56 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button4"), ""},
57 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button5"), ""},
58 {BUTTON6MOUSE, "BUTTON6MOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button6"), ""},
59 {BUTTON7MOUSE, "BUTTON7MOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button7"), ""},
61 {TABLET_STYLUS, "PEN", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Pen"), ""},
62 {TABLET_ERASER, "ERASER", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Eraser"), ""},
64 {MOUSEMOVE, "MOUSEMOVE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Move"), ""},
65 {MOUSEPAN, "TRACKPADPAN", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Mouse/Trackpad Pan"), ""},
66 {MOUSEZOOM, "TRACKPADZOOM", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Mouse/Trackpad Zoom"), ""},
68 "MOUSEROTATE",
69 0,
70 CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Mouse/Trackpad Rotate"),
71 ""},
73 "MOUSESMARTZOOM",
74 0,
75 CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Mouse/Trackpad Smart Zoom"),
76 ""},
78 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Wheel Up"), ""},
79 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Wheel Down"), ""},
80 {WHEELINMOUSE, "WHEELINMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Wheel In"), ""},
81 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Wheel Out"), ""},
82 {WHEELLEFTMOUSE, "WHEELLEFTMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Wheel Left"), ""},
83 {WHEELRIGHTMOUSE, "WHEELRIGHTMOUSE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Wheel Right"), ""},
84 {0, nullptr, 0, nullptr, nullptr},
85};
86
87static const EnumPropertyItem event_timer_type_items[] = {
88 {TIMER, "TIMER", 0, "Timer", ""},
89 {TIMER0, "TIMER0", 0, "Timer 0", ""},
90 {TIMER1, "TIMER1", 0, "Timer 1", ""},
91 {TIMER2, "TIMER2", 0, "Timer 2", ""},
92 {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", ""},
93 {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", ""},
94 {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", ""},
95 {TIMERREGION, "TIMERREGION", 0, "Timer Region", ""},
96 {0, nullptr, 0, nullptr, nullptr},
97};
98
99static const EnumPropertyItem event_textinput_type_items[] = {
100 {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
101 {0, nullptr, 0, nullptr, nullptr},
102};
103
104static const EnumPropertyItem event_ndof_type_items[] = {
105 {NDOF_MOTION, "NDOF_MOTION", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Motion"), ""},
106 /* buttons on all 3dconnexion devices */
107 {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Menu"), ""},
108 {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Fit"), ""},
109 /* view buttons */
110 {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Top"), ""},
111 {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Bottom"), ""},
112 {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Left"), ""},
113 {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Right"), ""},
114 {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Front"), ""},
115 {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Back"), ""},
116 /* more views */
118 "NDOF_BUTTON_ISO1",
119 0,
120 CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Isometric 1"),
121 ""},
123 "NDOF_BUTTON_ISO2",
124 0,
125 CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Isometric 2"),
126 ""},
127 /* 90 degree rotations */
129 "NDOF_BUTTON_ROLL_CW",
130 0,
132 ""},
134 "NDOF_BUTTON_ROLL_CCW",
135 0,
137 ""},
139 "NDOF_BUTTON_SPIN_CW",
140 0,
142 ""},
144 "NDOF_BUTTON_SPIN_CCW",
145 0,
147 ""},
149 "NDOF_BUTTON_TILT_CW",
150 0,
152 ""},
154 "NDOF_BUTTON_TILT_CCW",
155 0,
157 ""},
158 /* device control */
159 {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Rotate"), ""},
161 "NDOF_BUTTON_PANZOOM",
162 0,
164 ""},
166 "NDOF_BUTTON_DOMINANT",
167 0,
169 ""},
170 {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Plus"), ""},
171 {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Minus"), ""},
172 /* View buttons. */
173 {NDOF_BUTTON_V1, "NDOF_BUTTON_V1", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "View 1"), ""},
174 {NDOF_BUTTON_V2, "NDOF_BUTTON_V2", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "View 2"), ""},
175 {NDOF_BUTTON_V3, "NDOF_BUTTON_V3", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "View 3"), ""},
176 /* general-purpose buttons */
177 {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 1"), ""},
178 {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 2"), ""},
179 {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 3"), ""},
180 {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 4"), ""},
181 {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 5"), ""},
182 {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 6"), ""},
183 {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 7"), ""},
184 {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 8"), ""},
185 {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 9"), ""},
186 {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 10"), ""},
187 {NDOF_BUTTON_11, "NDOF_BUTTON_11", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 11"), ""},
188 {NDOF_BUTTON_12, "NDOF_BUTTON_12", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Button 12"), ""},
189# if 0 /* Never used (converted to keyboard events by GHOST). */
190 /* keyboard emulation */
191 {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Esc")},
192 {NDOF_BUTTON_ENTER, "NDOF_BUTTON_ENTER", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Enter")},
193 {NDOF_BUTTON_DELETE, "NDOF_BUTTON_DELETE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Delete")},
194 {NDOF_BUTTON_TAB, "NDOF_BUTTON_TAB", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Tab")},
195 {NDOF_BUTTON_SPACE, "NDOF_BUTTON_SPACE", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Space")},
196 {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Alt")},
197 {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Shift")},
198 {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Ctrl")},
199# endif
200 {0, nullptr, 0, nullptr, nullptr},
201};
202} // namespace blender
203#endif /* RNA_RUNTIME */
204
205namespace blender {
206
217 {WM_JOB_TYPE_RENDER, "RENDER", 0, "Regular rendering", ""},
218 {WM_JOB_TYPE_RENDER_PREVIEW, "RENDER_PREVIEW", 0, "Rendering previews", ""},
219 {WM_JOB_TYPE_OBJECT_BAKE, "OBJECT_BAKE", 0, "Object Baking", ""},
220 {WM_JOB_TYPE_COMPOSITE, "COMPOSITE", 0, "Compositing", ""},
221 {WM_JOB_TYPE_SHADER_COMPILATION, "SHADER_COMPILATION", 0, "Shader compilation", ""},
222 {0, nullptr, 0, nullptr, nullptr},
223};
224
226 /* - Note we abuse 'tooltip' message here to store a 'compact' form of some (too) long names.
227 * - Intentionally excluded: #CAPSLOCKKEY, #UNKNOWNKEY.
228 */
229 {0, "NONE", 0, "", ""},
230 {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", "LMB"},
231 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", "MMB"},
232 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", "RMB"},
233 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", "MB4"},
234 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", "MB5"},
235 {BUTTON6MOUSE, "BUTTON6MOUSE", 0, "Button6 Mouse", "MB6"},
236 {BUTTON7MOUSE, "BUTTON7MOUSE", 0, "Button7 Mouse", "MB7"},
238 {TABLET_STYLUS, "PEN", 0, "Pen", ""},
239 {TABLET_ERASER, "ERASER", 0, "Eraser", ""},
241 {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", "MsMov"},
242 {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "In-between Move", "MsSubMov"},
243 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", "MsPan"},
244 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", "MsZoom"},
245 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", "MsRot"},
246 {MOUSESMARTZOOM, "MOUSESMARTZOOM", 0, "Mouse/Trackpad Smart Zoom", "MsSmartZoom"},
248 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", "WhUp"},
249 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", "WhDown"},
250 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", "WhIn"},
251 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", "WhOut"},
252 {WHEELLEFTMOUSE, "WHEELLEFTMOUSE", 0, "Wheel Left", "WhLeft"},
253 {WHEELRIGHTMOUSE, "WHEELRIGHTMOUSE", 0, "Wheel Right", "WhRight"},
255 {EVT_AKEY, "A", 0, "A", ""},
256 {EVT_BKEY, "B", 0, "B", ""},
257 {EVT_CKEY, "C", 0, "C", ""},
258 {EVT_DKEY, "D", 0, "D", ""},
259 {EVT_EKEY, "E", 0, "E", ""},
260 {EVT_FKEY, "F", 0, "F", ""},
261 {EVT_GKEY, "G", 0, "G", ""},
262 {EVT_HKEY, "H", 0, "H", ""},
263 {EVT_IKEY, "I", 0, "I", ""},
264 {EVT_JKEY, "J", 0, "J", ""},
265 {EVT_KKEY, "K", 0, "K", ""},
266 {EVT_LKEY, "L", 0, "L", ""},
267 {EVT_MKEY, "M", 0, "M", ""},
268 {EVT_NKEY, "N", 0, "N", ""},
269 {EVT_OKEY, "O", 0, "O", ""},
270 {EVT_PKEY, "P", 0, "P", ""},
271 {EVT_QKEY, "Q", 0, "Q", ""},
272 {EVT_RKEY, "R", 0, "R", ""},
273 {EVT_SKEY, "S", 0, "S", ""},
274 {EVT_TKEY, "T", 0, "T", ""},
275 {EVT_UKEY, "U", 0, "U", ""},
276 {EVT_VKEY, "V", 0, "V", ""},
277 {EVT_WKEY, "W", 0, "W", ""},
278 {EVT_XKEY, "X", 0, "X", ""},
279 {EVT_YKEY, "Y", 0, "Y", ""},
280 {EVT_ZKEY, "Z", 0, "Z", ""},
282 {EVT_ZEROKEY, "ZERO", 0, "0", ""},
283 {EVT_ONEKEY, "ONE", 0, "1", ""},
284 {EVT_TWOKEY, "TWO", 0, "2", ""},
285 {EVT_THREEKEY, "THREE", 0, "3", ""},
286 {EVT_FOURKEY, "FOUR", 0, "4", ""},
287 {EVT_FIVEKEY, "FIVE", 0, "5", ""},
288 {EVT_SIXKEY, "SIX", 0, "6", ""},
289 {EVT_SEVENKEY, "SEVEN", 0, "7", ""},
290 {EVT_EIGHTKEY, "EIGHT", 0, "8", ""},
291 {EVT_NINEKEY, "NINE", 0, "9", ""},
293 {EVT_LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", "CtrlL"},
294 {EVT_LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", "AltL"},
295 {EVT_LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", "ShiftL"},
296 {EVT_RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", "AltR"},
297 {EVT_RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", "CtrlR"},
298 {EVT_RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", "ShiftR"},
300 {EVT_OSKEY, "OSKEY", 0, "OS Key", "Cmd"},
301 {EVT_HYPER, "HYPER", 0, "Hyper", "Hyp"},
302 {EVT_APPKEY, "APP", 0, "Application", "App"},
303 {EVT_GRLESSKEY, "GRLESS", 0, "Grless", ""},
304 {EVT_ESCKEY, "ESC", 0, "Esc", ""},
305 {EVT_TABKEY, "TAB", 0, "Tab", ""},
306 {EVT_RETKEY, "RET", 0, "Return", "Enter"},
307 {EVT_SPACEKEY, "SPACE", 0, "Space Bar", "Spacebar"},
308 {EVT_LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
309 {EVT_BACKSPACEKEY, "BACK_SPACE", 0, "Backspace", "BkSpace"},
310 {EVT_DELKEY, "DEL", 0, "Delete", "Del"},
311 {EVT_SEMICOLONKEY, "SEMI_COLON", 0, ";", ""},
312 {EVT_PERIODKEY, "PERIOD", 0, ".", ""},
313 {EVT_COMMAKEY, "COMMA", 0, ",", ""},
314 {EVT_QUOTEKEY, "QUOTE", 0, "\"", ""},
315 {EVT_ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "`", ""},
316 {EVT_MINUSKEY, "MINUS", 0, "-", ""},
317 {EVT_PLUSKEY, "PLUS", 0, "+", ""},
318 {EVT_SLASHKEY, "SLASH", 0, "/", ""},
319 {EVT_BACKSLASHKEY, "BACK_SLASH", 0, "\\", ""},
320 {EVT_EQUALKEY, "EQUAL", 0, "=", ""},
321 {EVT_LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""},
322 {EVT_RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""},
323 {EVT_LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", BLI_STR_UTF8_LEFTWARDS_ARROW},
324 {EVT_DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", BLI_STR_UTF8_DOWNWARDS_ARROW},
325 {EVT_RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", BLI_STR_UTF8_RIGHTWARDS_ARROW},
326 {EVT_UPARROWKEY, "UP_ARROW", 0, "Up Arrow", BLI_STR_UTF8_UPWARDS_ARROW},
327 {EVT_PAD2, "NUMPAD_2", 0, "Numpad 2", "Pad2"},
328 {EVT_PAD4, "NUMPAD_4", 0, "Numpad 4", "Pad4"},
329 {EVT_PAD6, "NUMPAD_6", 0, "Numpad 6", "Pad6"},
330 {EVT_PAD8, "NUMPAD_8", 0, "Numpad 8", "Pad8"},
331 {EVT_PAD1, "NUMPAD_1", 0, "Numpad 1", "Pad1"},
332 {EVT_PAD3, "NUMPAD_3", 0, "Numpad 3", "Pad3"},
333 {EVT_PAD5, "NUMPAD_5", 0, "Numpad 5", "Pad5"},
334 {EVT_PAD7, "NUMPAD_7", 0, "Numpad 7", "Pad7"},
335 {EVT_PAD9, "NUMPAD_9", 0, "Numpad 9", "Pad9"},
336 {EVT_PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", "Pad."},
337 {EVT_PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", "Pad/"},
338 {EVT_PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", "Pad*"},
339 {EVT_PAD0, "NUMPAD_0", 0, "Numpad 0", "Pad0"},
340 {EVT_PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", "Pad-"},
341 {EVT_PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", "PadEnter"},
342 {EVT_PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", "Pad+"},
343 {EVT_F1KEY, "F1", 0, "F1", ""},
344 {EVT_F2KEY, "F2", 0, "F2", ""},
345 {EVT_F3KEY, "F3", 0, "F3", ""},
346 {EVT_F4KEY, "F4", 0, "F4", ""},
347 {EVT_F5KEY, "F5", 0, "F5", ""},
348 {EVT_F6KEY, "F6", 0, "F6", ""},
349 {EVT_F7KEY, "F7", 0, "F7", ""},
350 {EVT_F8KEY, "F8", 0, "F8", ""},
351 {EVT_F9KEY, "F9", 0, "F9", ""},
352 {EVT_F10KEY, "F10", 0, "F10", ""},
353 {EVT_F11KEY, "F11", 0, "F11", ""},
354 {EVT_F12KEY, "F12", 0, "F12", ""},
355 {EVT_F13KEY, "F13", 0, "F13", ""},
356 {EVT_F14KEY, "F14", 0, "F14", ""},
357 {EVT_F15KEY, "F15", 0, "F15", ""},
358 {EVT_F16KEY, "F16", 0, "F16", ""},
359 {EVT_F17KEY, "F17", 0, "F17", ""},
360 {EVT_F18KEY, "F18", 0, "F18", ""},
361 {EVT_F19KEY, "F19", 0, "F19", ""},
362 {EVT_F20KEY, "F20", 0, "F20", ""},
363 {EVT_F21KEY, "F21", 0, "F21", ""},
364 {EVT_F22KEY, "F22", 0, "F22", ""},
365 {EVT_F23KEY, "F23", 0, "F23", ""},
366 {EVT_F24KEY, "F24", 0, "F24", ""},
367 {EVT_PAUSEKEY, "PAUSE", 0, "Pause", ""},
368 {EVT_INSERTKEY, "INSERT", 0, "Insert", "Ins"},
369 {EVT_HOMEKEY, "HOME", 0, "Home", ""},
370 {EVT_PAGEUPKEY, "PAGE_UP", 0, "Page Up", "PgUp"},
371 {EVT_PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", "PgDown"},
372 {EVT_ENDKEY, "END", 0, "End", ""},
375 "MEDIA_PLAY",
376 0,
377 "Media Play/Pause",
379 {EVT_MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", BLI_STR_UTF8_BLACK_SQUARE_FOR_STOP},
381 "MEDIA_FIRST",
382 0,
383 "Media First",
386 "MEDIA_LAST",
387 0,
388 "Media Last",
391 {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", "TxtIn"},
393 {WINDEACTIVATE, "WINDOW_DEACTIVATE", 0, "Window Deactivate", ""},
394 {TIMER, "TIMER", 0, "Timer", "Tmr"},
395 {TIMER0, "TIMER0", 0, "Timer 0", "Tmr0"},
396 {TIMER1, "TIMER1", 0, "Timer 1", "Tmr1"},
397 {TIMER2, "TIMER2", 0, "Timer 2", "Tmr2"},
398 {TIMERJOBS, "TIMER_JOBS", 0, "Timer Jobs", "TmrJob"},
399 {TIMERAUTOSAVE, "TIMER_AUTOSAVE", 0, "Timer Autosave", "TmrSave"},
400 {TIMERREPORT, "TIMER_REPORT", 0, "Timer Report", "TmrReport"},
401 {TIMERREGION, "TIMERREGION", 0, "Timer Region", "TmrReg"},
403 {NDOF_MOTION, "NDOF_MOTION", 0, "NDOF Motion", "NdofMov"},
404 /* buttons on all 3dconnexion devices */
405 {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"},
406 {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", "NdofFit"},
407 /* view buttons */
408 {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", "Ndof" BLI_STR_UTF8_UPWARDS_ARROW},
410 "NDOF_BUTTON_BOTTOM",
411 0,
412 "NDOF Bottom",
414 {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", "Ndof" BLI_STR_UTF8_LEFTWARDS_ARROW},
416 "NDOF_BUTTON_RIGHT",
417 0,
418 "NDOF Right",
420 {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", "NdofFront"},
421 {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", "NdofBack"},
422 /* more views */
423 {NDOF_BUTTON_ISO1, "NDOF_BUTTON_ISO1", 0, "NDOF Isometric 1", "NdofIso1"},
424 {NDOF_BUTTON_ISO2, "NDOF_BUTTON_ISO2", 0, "NDOF Isometric 2", "NdofIso2"},
425 /* 90 degree rotations */
426 {NDOF_BUTTON_ROLL_CW, "NDOF_BUTTON_ROLL_CW", 0, "NDOF Roll CW", "NdofRCW"},
427 {NDOF_BUTTON_ROLL_CCW, "NDOF_BUTTON_ROLL_CCW", 0, "NDOF Roll CCW", "NdofRCCW"},
428 {NDOF_BUTTON_SPIN_CW, "NDOF_BUTTON_SPIN_CW", 0, "NDOF Spin CW", "NdofSCW"},
429 {NDOF_BUTTON_SPIN_CCW, "NDOF_BUTTON_SPIN_CCW", 0, "NDOF Spin CCW", "NdofSCCW"},
430 {NDOF_BUTTON_TILT_CW, "NDOF_BUTTON_TILT_CW", 0, "NDOF Tilt CW", "NdofTCW"},
431 {NDOF_BUTTON_TILT_CCW, "NDOF_BUTTON_TILT_CCW", 0, "NDOF Tilt CCW", "NdofTCCW"},
432 /* device control */
433 {NDOF_BUTTON_ROTATE, "NDOF_BUTTON_ROTATE", 0, "NDOF Rotate", "NdofRot"},
434 {NDOF_BUTTON_PANZOOM, "NDOF_BUTTON_PANZOOM", 0, "NDOF Pan/Zoom", "NdofPanZoom"},
435 {NDOF_BUTTON_DOMINANT, "NDOF_BUTTON_DOMINANT", 0, "NDOF Dominant", "NdofDom"},
436 {NDOF_BUTTON_PLUS, "NDOF_BUTTON_PLUS", 0, "NDOF Plus", "Ndof+"},
437 {NDOF_BUTTON_MINUS, "NDOF_BUTTON_MINUS", 0, "NDOF Minus", "Ndof-"},
438#if 0 /* Never used (converted to keyboard events by GHOST). */
439 /* keyboard emulation */
440 {NDOF_BUTTON_ESC, "NDOF_BUTTON_ESC", 0, "NDOF Esc", "NdofEsc"},
441 {NDOF_BUTTON_ALT, "NDOF_BUTTON_ALT", 0, "NDOF Alt", "NdofAlt"},
442 {NDOF_BUTTON_SHIFT, "NDOF_BUTTON_SHIFT", 0, "NDOF Shift", "NdofShift"},
443 {NDOF_BUTTON_CTRL, "NDOF_BUTTON_CTRL", 0, "NDOF Ctrl", "NdofCtrl"},
444#endif
445 /* View buttons. */
446 {NDOF_BUTTON_V1, "NDOF_BUTTON_V1", 0, "NDOF View 1", "NdofView1"},
447 {NDOF_BUTTON_V2, "NDOF_BUTTON_V2", 0, "NDOF View 2", "NdofView2"},
448 {NDOF_BUTTON_V3, "NDOF_BUTTON_V3", 0, "NDOF View 3", "NdofView3"},
449 {NDOF_BUTTON_SAVE_V1, "NDOF_BUTTON_SAVE_V1", 0, "NDOF Save View 1", "NdofSaveView1"},
450 {NDOF_BUTTON_SAVE_V2, "NDOF_BUTTON_SAVE_V2", 0, "NDOF Save View 2", "NdofSaveView2"},
451 {NDOF_BUTTON_SAVE_V3, "NDOF_BUTTON_SAVE_V3", 0, "NDOF Save View 3", "NdofSaveView3"},
452 /* general-purpose buttons */
453 {NDOF_BUTTON_1, "NDOF_BUTTON_1", 0, "NDOF Button 1", "NdofB1"},
454 {NDOF_BUTTON_2, "NDOF_BUTTON_2", 0, "NDOF Button 2", "NdofB2"},
455 {NDOF_BUTTON_3, "NDOF_BUTTON_3", 0, "NDOF Button 3", "NdofB3"},
456 {NDOF_BUTTON_4, "NDOF_BUTTON_4", 0, "NDOF Button 4", "NdofB4"},
457 {NDOF_BUTTON_5, "NDOF_BUTTON_5", 0, "NDOF Button 5", "NdofB5"},
458 {NDOF_BUTTON_6, "NDOF_BUTTON_6", 0, "NDOF Button 6", "NdofB6"},
459 {NDOF_BUTTON_7, "NDOF_BUTTON_7", 0, "NDOF Button 7", "NdofB7"},
460 {NDOF_BUTTON_8, "NDOF_BUTTON_8", 0, "NDOF Button 8", "NdofB8"},
461 {NDOF_BUTTON_9, "NDOF_BUTTON_9", 0, "NDOF Button 9", "NdofB9"},
462 {NDOF_BUTTON_10, "NDOF_BUTTON_10", 0, "NDOF Button 10", "NdofB10"},
463 {NDOF_BUTTON_11, "NDOF_BUTTON_11", 0, "NDOF Button 11", "NdofB11"},
464 {NDOF_BUTTON_12, "NDOF_BUTTON_12", 0, "NDOF Button 12", "NdofB12"},
465
466 /* Action Zones. */
467 {EVT_ACTIONZONE_AREA, "ACTIONZONE_AREA", 0, "ActionZone Area", "AZone Area"},
468 {EVT_ACTIONZONE_REGION, "ACTIONZONE_REGION", 0, "ActionZone Region", "AZone Region"},
469 {EVT_ACTIONZONE_REGION_QUAD, "ACTIONZONE_REGION_QUAD", 0, "ActionZone Quad", "AZone Quad"},
471 "ACTIONZONE_FULLSCREEN",
472 0,
473 "ActionZone Fullscreen",
474 "AZone FullScr"},
475 /* xr */
476 {EVT_XR_ACTION, "XR_ACTION", 0, "XR Action", ""},
477 {0, nullptr, 0, nullptr, nullptr},
478};
479
489 {KM_ANY, "ANY", 0, "Any", ""},
490 {KM_PRESS, "PRESS", 0, "Press", ""},
491 {KM_RELEASE, "RELEASE", 0, "Release", ""},
492 {KM_CLICK, "CLICK", 0, "Click", ""},
493 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
494 {KM_PRESS_DRAG, "CLICK_DRAG", 0, "Drag", ""},
495 /* Used for NDOF and trackpad events. */
496 {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
497 {0, nullptr, 0, nullptr, nullptr},
498};
499
501 {KM_ANY, "ANY", 0, "Any", ""},
502 {KM_DIRECTION_N, "NORTH", 0, "North", ""},
503 {KM_DIRECTION_NE, "NORTH_EAST", 0, "North-East", ""},
504 {KM_DIRECTION_E, "EAST", 0, "East", ""},
505 {KM_DIRECTION_SE, "SOUTH_EAST", 0, "South-East", ""},
506 {KM_DIRECTION_S, "SOUTH", 0, "South", ""},
507 {KM_DIRECTION_SW, "SOUTH_WEST", 0, "South-West", ""},
508 {KM_DIRECTION_W, "WEST", 0, "West", ""},
509 {KM_DIRECTION_NW, "NORTH_WEST", 0, "North-West", ""},
510 {0, nullptr, 0, nullptr, nullptr},
511};
512
517 {P_STARTING, "STARTING", 0, "Starting", ""},
518 {P_IN_PROGRESS, "IN_PROGRESS", 0, "In progress", ""},
519 {P_FINISHING, "FINISHING", 0, "Finishing", ""},
520 {0, nullptr, 0, nullptr, nullptr},
521};
522
524 {0, "NONE", 0, "", ""},
525 {0, nullptr, 0, nullptr, nullptr},
526};
527
528/* Mask event types used in keymap items. */
530 {EVT_TYPE_MASK_KEYBOARD_MODIFIER, "KEYBOARD_MODIFIER", 0, "Keyboard Modifier", ""},
531 {EVT_TYPE_MASK_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
532 {EVT_TYPE_MASK_MOUSE_WHEEL, "MOUSE_WHEEL", 0, "Mouse Wheel", ""},
533 {EVT_TYPE_MASK_MOUSE_GESTURE, "MOUSE_GESTURE", 0, "Mouse Gesture", ""},
534 {EVT_TYPE_MASK_MOUSE_BUTTON, "MOUSE_BUTTON", 0, "Mouse Button", ""},
535 {EVT_TYPE_MASK_MOUSE, "MOUSE", 0, "Mouse", ""},
536 {EVT_TYPE_MASK_NDOF, "NDOF", 0, "NDOF", ""},
537 {EVT_TYPE_MASK_ACTIONZONE, "ACTIONZONE", 0, "Action Zone", ""},
538 {0, nullptr, 0, nullptr, nullptr},
539};
540
541#if 0
542static const EnumPropertyItem keymap_modifiers_items[] = {
543 {KM_ANY, "ANY", 0, "Any", ""},
544 {0, "NONE", 0, "None", ""},
545 {KM_MOD_HELD, "HELD", 0, "Held", ""},
546 {0, nullptr, 0, nullptr, nullptr},
547};
548#endif
549
552 "REGISTER",
553 0,
554 "Register",
555 "Display in the info window and support the redo toolbar panel"},
557 "UNDO",
558 0,
559 "Undo",
560 "Push an undo event when the operator returns `FINISHED` (needed for operator redo, "
561 "mandatory if the operator modifies Blender data)"},
563 "UNDO_GROUPED",
564 0,
565 "Grouped Undo",
566 "Push a single undo event for repeated instances of this operator"},
567 {OPTYPE_BLOCKING, "BLOCKING", 0, "Blocking", "Block anything else from using the cursor"},
568 {OPTYPE_MACRO, "MACRO", 0, "Macro", "Use to check if an operator is a macro"},
570 "GRAB_CURSOR",
571 0,
572 "Grab Pointer",
573 "Use so the operator grabs the mouse focus, enables wrapping when continuous grab "
574 "is enabled"},
575 {OPTYPE_GRAB_CURSOR_X, "GRAB_CURSOR_X", 0, "Grab Pointer X", "Grab, only warping the X axis"},
576 {OPTYPE_GRAB_CURSOR_Y, "GRAB_CURSOR_Y", 0, "Grab Pointer Y", "Grab, only warping the Y axis"},
578 "DEPENDS_ON_CURSOR",
579 0,
580 "Depends on Cursor",
581 "The initial cursor location is used, "
582 "when running from a menus or buttons the user is prompted to place the cursor "
583 "before beginning the operation"},
584 {OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"},
585 {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"},
587 "MODAL_PRIORITY",
588 0,
589 "Modal Priority",
590 "Handle events before other modal operators without this option. Use with caution, do not "
591 "modify data that other modal operators assume is unchanged during their operation."},
592 {0, nullptr, 0, nullptr, nullptr},
593};
594
597 "RUNNING_MODAL",
598 0,
599 "Running Modal",
600 "Keep the operator running with blender"},
602 "CANCELLED",
603 0,
604 "Cancelled",
605 "The operator exited without doing anything, so no undo entry should be pushed"},
607 "FINISHED",
608 0,
609 "Finished",
610 "The operator exited after completing its action"},
611 /* used as a flag */
612 {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"},
613 {OPERATOR_INTERFACE, "INTERFACE", 0, "Interface", "Handled but not executed (popup menus)"},
614 {0, nullptr, 0, nullptr, nullptr},
615};
616
619 "ADVANCED",
620 0,
621 "Advanced",
622 "The property is advanced so UI is suggested to hide it"},
623 {0, nullptr, 0, nullptr, nullptr},
624};
625
626/* flag/enum */
628 {RPT_DEBUG, "DEBUG", 0, "Debug", ""},
629 {RPT_INFO, "INFO", 0, "Info", ""},
630 {RPT_OPERATOR, "OPERATOR", 0, "Operator", ""},
631 {RPT_PROPERTY, "PROPERTY", 0, "Property", ""},
632 {RPT_WARNING, "WARNING", 0, "Warning", ""},
633 {RPT_ERROR, "ERROR", 0, "Error", ""},
634 {RPT_ERROR_INVALID_INPUT, "ERROR_INVALID_INPUT", 0, "Invalid Input", ""},
635 {RPT_ERROR_INVALID_CONTEXT, "ERROR_INVALID_CONTEXT", 0, "Invalid Context", ""},
636 {RPT_ERROR_OUT_OF_MEMORY, "ERROR_OUT_OF_MEMORY", 0, "Out of Memory", ""},
637 {0, nullptr, 0, nullptr, nullptr},
638};
639
640} // namespace blender
641
642#ifdef RNA_RUNTIME
643
644# include "BLI_string_utils.hh"
645
646# include "WM_api.hh"
647
648# include "DNA_ID.h"
649# include "DNA_workspace_types.h"
650
651# include "BKE_global.hh"
652
653# include "ED_screen.hh"
654
655# include "UI_interface.hh"
656
657# include "MEM_guardedalloc.h"
658
659# ifdef WITH_PYTHON
660# include "BPY_extern.hh"
661# endif
662
663namespace blender {
664
665static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
666{
667 if (ptr->owner_id == nullptr || GS(ptr->owner_id->name) != ID_WM) {
668 return nullptr;
669 }
670
671 wmWindowManager *wm = id_cast<wmWindowManager *>(ptr->owner_id);
672
673 IDProperty *properties = static_cast<IDProperty *>(ptr->data);
674 for (wmOperator *op = wm->runtime->operators.last(); op; op = op->prev) {
675 if (op->properties == properties) {
676 return op;
677 }
678 }
679
680 return nullptr;
681}
682
683static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr)
684{
685 wmOperator *op = rna_OperatorProperties_find_operator(ptr);
686
687 if (op) {
688 return op->type->srna;
689 }
690 else {
691 return ptr->type;
692 }
693}
694
695static IDProperty **rna_OperatorProperties_idprops(PointerRNA *ptr)
696{
697 return reinterpret_cast<IDProperty **>(&ptr->data);
698}
699
700static void rna_Operator_name_get(PointerRNA *ptr, char *value)
701{
702 wmOperator *op = static_cast<wmOperator *>(ptr->data);
703 strcpy(value, op->type->name);
704}
705
706static int rna_Operator_name_length(PointerRNA *ptr)
707{
708 wmOperator *op = static_cast<wmOperator *>(ptr->data);
709 return strlen(op->type->name);
710}
711
712static bool rna_Operator_has_reports_get(PointerRNA *ptr)
713{
714 wmOperator *op = static_cast<wmOperator *>(ptr->data);
715 return (op->reports && op->reports->list.first());
716}
717
718static PointerRNA rna_Operator_layout_get(PointerRNA *ptr)
719{
720 /* Operator owner is not inherited, layout is owned by WM. */
721 wmOperator *op = static_cast<wmOperator *>(ptr->data);
722 return RNA_pointer_create_discrete(nullptr, RNA_UILayout, op->layout);
723}
724
725static PointerRNA rna_Operator_options_get(PointerRNA *ptr)
726{
727 return RNA_pointer_create_with_parent(*ptr, RNA_OperatorOptions, ptr->data);
728}
729
730static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
731{
732 wmOperator *op = static_cast<wmOperator *>(ptr->data);
733
735 result.owner_id = (ptr->owner_id) ? ptr->owner_id : result.owner_id;
736 result.data = op->properties;
737 return result;
738}
739
740static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr)
741{
742 wmOperatorTypeMacro *otmacro = static_cast<wmOperatorTypeMacro *>(ptr->data);
743 wmOperatorType *ot = WM_operatortype_find(otmacro->idname, true);
744
746 result.owner_id = (ptr->owner_id) ? ptr->owner_id : result.owner_id;
747 result.data = otmacro->properties;
748 return result;
749}
750
751static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
752{
753 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
754 value[0] = WM_event_utf8_to_ascii(event);
755 value[1] = '\0';
756}
757
758static int rna_Event_ascii_length(PointerRNA *ptr)
759{
760 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
761 return WM_event_utf8_to_ascii(event) ? 1 : 0;
762}
763
764static void rna_Event_unicode_get(PointerRNA *ptr, char *value)
765{
766 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
767 size_t len = 0;
768
769 if (event->utf8_buf[0]) {
770 if (BLI_str_utf8_as_unicode_step_or_error(event->utf8_buf, sizeof(event->utf8_buf), &len) !=
772 memcpy(value, event->utf8_buf, len);
773 }
774
775 value[len] = '\0';
776}
777
778static int rna_Event_unicode_length(PointerRNA *ptr)
779{
780 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
781 int len = 0;
782 if (event->utf8_buf[0]) {
783 len = BLI_str_utf8_size_or_error(event->utf8_buf);
784 if (len == -1) {
785 /* Even though this is documented as always being a valid UTF8 sequence,
786 * assert instead of returning a negative length if it is. */
788 len = 0;
789 }
790 }
791 return len;
792}
793
794static bool rna_Event_is_repeat_get(PointerRNA *ptr)
795{
796 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
797 return (event->flag & WM_EVENT_IS_REPEAT) != 0;
798}
799
800static bool rna_Event_is_consecutive_get(PointerRNA *ptr)
801{
802 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
803 return (event->flag & WM_EVENT_IS_CONSECUTIVE) != 0;
804}
805
806static float rna_Event_pressure_get(PointerRNA *ptr)
807{
808 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
809 return WM_event_tablet_data(event, nullptr, nullptr);
810}
811
812static bool rna_Event_is_tablet_get(PointerRNA *ptr)
813{
814 const wmEvent *event = static_cast<wmEvent *>(ptr->data);
815 return WM_event_is_tablet(event);
816}
817
818static void rna_Event_tilt_get(PointerRNA *ptr, float *values)
819{
820 wmEvent *event = static_cast<wmEvent *>(ptr->data);
821 WM_event_tablet_data(event, nullptr, values);
822}
823
824static void rna_NDOFMotionEventData_translation_get(PointerRNA *ptr, float *values)
825{
826# ifdef WITH_INPUT_NDOF
827 const wmNDOFMotionData &ndof = *static_cast<const wmNDOFMotionData *>(ptr->data);
828 copy_v3_v3(values, WM_event_ndof_translation_get(ndof));
829# else
830 UNUSED_VARS(ptr);
831 ARRAY_SET_ITEMS(values, 0, 0, 0);
832# endif
833}
834
835static void rna_NDOFMotionEventData_rotation_get(PointerRNA *ptr, float *values)
836{
837# ifdef WITH_INPUT_NDOF
838 const wmNDOFMotionData &ndof = *static_cast<const wmNDOFMotionData *>(ptr->data);
839 copy_v3_v3(values, WM_event_ndof_rotation_get(ndof));
840# else
841 UNUSED_VARS(ptr);
842 ARRAY_SET_ITEMS(values, 0, 0, 0);
843# endif
844}
845
846static float rna_NDOFMotionEventData_time_delta_get(PointerRNA *ptr)
847{
848# ifdef WITH_INPUT_NDOF
849 const wmNDOFMotionData &ndof = *static_cast<const wmNDOFMotionData *>(ptr->data);
850 return ndof.time_delta;
851# else
852 UNUSED_VARS(ptr);
853 return 0.0f;
854# endif
855}
856
857static int rna_NDOFMotionEventData_progress_get(PointerRNA *ptr)
858{
859# ifdef WITH_INPUT_NDOF
860 const wmNDOFMotionData &ndof = *static_cast<const wmNDOFMotionData *>(ptr->data);
861 return int(ndof.progress);
862# else
863 UNUSED_VARS(ptr);
864 return 0;
865# endif
866}
867
868static PointerRNA rna_Event_ndof_motion_get(PointerRNA *ptr)
869{
870# ifdef WITH_INPUT_NDOF
871 wmEvent *event = static_cast<wmEvent *>(ptr->data);
872 if (event->custom == EVT_DATA_NDOF_MOTION) {
873 wmNDOFMotionData *ndof = static_cast<wmNDOFMotionData *>(event->customdata);
874 return RNA_pointer_create_with_parent(*ptr, RNA_NDOFMotionEventData, ndof);
875 }
876# else
877 UNUSED_VARS(ptr);
878# endif
879 return {};
880}
881
882static PointerRNA rna_Event_xr_get(PointerRNA *ptr)
883{
884# ifdef WITH_XR_OPENXR
885 wmEvent *event = static_cast<wmEvent *>(ptr->data);
886 wmXrActionData *actiondata = static_cast<wmXrActionData *>(
887 WM_event_is_xr(event) ? event->customdata : nullptr);
888 return RNA_pointer_create_with_parent(*ptr, RNA_XrEventData, actiondata);
889# else
890 UNUSED_VARS(ptr);
891 return {};
892# endif
893}
894
895static PointerRNA rna_PopupMenu_layout_get(PointerRNA *ptr)
896{
897 ui::PopupMenu *pup = static_cast<ui::PopupMenu *>(ptr->data);
898 ui::Layout *layout = ui::popup_menu_layout(pup);
899
900 PointerRNA rptr = RNA_pointer_create_discrete(ptr->owner_id, RNA_UILayout, layout);
901 return rptr;
902}
903
904static PointerRNA rna_PopoverMenu_layout_get(PointerRNA *ptr)
905{
906 ui::Popover *pup = static_cast<ui::Popover *>(ptr->data);
907 ui::Layout *layout = ui::popover_layout(pup);
908
909 PointerRNA rptr = RNA_pointer_create_discrete(ptr->owner_id, RNA_UILayout, layout);
910 return rptr;
911}
912
913static PointerRNA rna_PieMenu_layout_get(PointerRNA *ptr)
914{
915 ui::PieMenu *pie = static_cast<ui::PieMenu *>(ptr->data);
916 ui::Layout *layout = ui::pie_menu_layout(pie);
917
918 PointerRNA rptr = RNA_pointer_create_discrete(ptr->owner_id, RNA_UILayout, layout);
919 return rptr;
920}
921
922static void rna_Window_scene_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
923{
924 wmWindow *win = static_cast<wmWindow *>(ptr->data);
925
926 if (!value) {
927 return;
928 }
929
930 win->new_scene = static_cast<Scene *>(value.data);
931}
932
933static void rna_Window_scene_update(bContext *C, PointerRNA *ptr)
934{
935 Main *bmain = CTX_data_main(C);
936 wmWindow *win = static_cast<wmWindow *>(ptr->data);
937
938 /* Exception: must use context so notifier gets to the right window. */
939 if (win->new_scene) {
940# ifdef WITH_PYTHON
942# endif
943
944 WM_window_set_active_scene(bmain, C, win, win->new_scene);
945
946# ifdef WITH_PYTHON
948# endif
949
951 WM_event_add_notifier_ex(wm, win, NC_SCENE | ND_SCENEBROWSE, win->new_scene);
952
953 if (G.debug & G_DEBUG) {
954 printf("scene set %p\n", win->new_scene);
955 }
956
957 win->new_scene = nullptr;
958 }
959}
960
961static PointerRNA rna_Window_workspace_get(PointerRNA *ptr)
962{
963 wmWindow *win = static_cast<wmWindow *>(ptr->data);
965 reinterpret_cast<ID *>(BKE_workspace_active_get(win->workspace_hook)));
966}
967
968static void rna_Window_workspace_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
969{
970 wmWindow *win = static_cast<wmWindow *>(ptr->data);
971
972 /* disallow ID-browsing away from temp screens */
973 if (WM_window_is_temp_screen(win)) {
974 return;
975 }
976 if (!value) {
977 return;
978 }
979
980 /* exception: can't set workspaces inside of area/region handlers */
981 win->workspace_hook->temp_workspace_store = static_cast<WorkSpace *>(value.data);
982}
983
984static void rna_Window_workspace_update(bContext *C, PointerRNA *ptr)
985{
986 wmWindow *win = static_cast<wmWindow *>(ptr->data);
987 WorkSpace *new_workspace = win->workspace_hook->temp_workspace_store;
988
989 /* exception: can't set screens inside of area/region handlers,
990 * and must use context so notifier gets to the right window */
991 if (new_workspace) {
995 win->workspace_hook->temp_workspace_store = nullptr;
996 }
997}
998
999PointerRNA rna_Window_screen_get(PointerRNA *ptr)
1000{
1001 wmWindow *win = static_cast<wmWindow *>(ptr->data);
1002 return RNA_id_pointer_create(
1003 reinterpret_cast<ID *>(BKE_workspace_active_screen_get(win->workspace_hook)));
1004}
1005
1006static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
1007{
1008 wmWindow *win = static_cast<wmWindow *>(ptr->data);
1009 WorkSpace *workspace = BKE_workspace_active_get(win->workspace_hook);
1010 WorkSpaceLayout *layout_new;
1011 const bScreen *screen = BKE_workspace_active_screen_get(win->workspace_hook);
1012
1013 /* disallow ID-browsing away from temp screens */
1014 if (screen->temp) {
1015 return;
1016 }
1017 if (!value) {
1018 return;
1019 }
1020
1021 /* exception: can't set screens inside of area/region handlers */
1022 layout_new = static_cast<WorkSpaceLayout *>(
1023 BKE_workspace_layout_find(workspace, static_cast<bScreen *>(value.data)));
1024 win->workspace_hook->temp_layout_store = layout_new;
1025}
1026
1027static bool rna_Window_screen_assign_poll(PointerRNA * /*ptr*/, PointerRNA value)
1028{
1029 bScreen *screen = id_cast<bScreen *>(value.owner_id);
1030 return !screen->temp;
1031}
1032
1033static void rna_workspace_screen_update(bContext *C, PointerRNA *ptr)
1034{
1035 wmWindow *win = static_cast<wmWindow *>(ptr->data);
1036 WorkSpaceLayout *layout_new = win->workspace_hook->temp_layout_store;
1037
1038 /* exception: can't set screens inside of area/region handlers,
1039 * and must use context so notifier gets to the right window */
1040 if (layout_new) {
1043 win->workspace_hook->temp_layout_store = nullptr;
1044 }
1045}
1046
1047static PointerRNA rna_Window_view_layer_get(PointerRNA *ptr)
1048{
1049 wmWindow *win = static_cast<wmWindow *>(ptr->data);
1050 Scene *scene = WM_window_get_active_scene(win);
1051 ViewLayer *view_layer = WM_window_get_active_view_layer(win);
1052
1053 return RNA_pointer_create_id_subdata(scene->id, RNA_ViewLayer, view_layer);
1054}
1055
1056static void rna_Window_view_layer_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
1057{
1058 wmWindow *win = static_cast<wmWindow *>(ptr->data);
1059 ViewLayer *view_layer = static_cast<ViewLayer *>(value.data);
1060
1061 WM_window_set_active_view_layer(win, view_layer);
1062}
1063
1064static bool rna_Window_support_hdr_color_get(PointerRNA *ptr)
1065{
1066 wmWindow *win = static_cast<wmWindow *>(ptr->data);
1067 return WM_window_support_hdr_color(win);
1068}
1069
1070static bool rna_Window_modal_handler_skip(CollectionPropertyIterator * /*iter*/, void *data)
1071{
1072 const wmEventHandler_Op *handler = static_cast<wmEventHandler_Op *>(data);
1073 return handler->head.type != WM_HANDLER_TYPE_OP;
1074}
1075
1076static void rna_Window_modal_operators_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1077{
1078 wmWindow *window = static_cast<wmWindow *>(ptr->data);
1080 iter, ptr, &window->runtime->modalhandlers, rna_Window_modal_handler_skip);
1081}
1082
1083static PointerRNA rna_Window_modal_operators_get(CollectionPropertyIterator *iter)
1084{
1085 const wmEventHandler_Op *handler = static_cast<wmEventHandler_Op *>(
1087 return RNA_pointer_create_with_parent(iter->parent, RNA_Operator, handler->op);
1088}
1089
1090static void rna_KeyMap_modal_event_values_items_begin(CollectionPropertyIterator *iter,
1091 PointerRNA *ptr)
1092{
1093 wmKeyMap *km = static_cast<wmKeyMap *>(ptr->data);
1094
1096 if ((km->flag & KEYMAP_MODAL) != 0 && km->modal_items != nullptr) {
1097 items = static_cast<const EnumPropertyItem *>(km->modal_items);
1098 }
1099
1100 const int totitem = RNA_enum_items_count(items);
1101
1103 iter, ptr, (void *)items, sizeof(EnumPropertyItem), totitem, false, nullptr);
1104}
1105
1106static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
1107{
1108 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1109
1110 if (kmi->ptr) {
1111 BLI_assert(kmi->ptr->owner_id == nullptr);
1112 return *(kmi->ptr);
1113 }
1114
1115 // return RNA_pointer_create_with_parent(*ptr, RNA_OperatorProperties, op->properties);
1116 return {};
1117}
1118
1119static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
1120{
1121 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1122
1123 return WM_keymap_item_map_type_get(kmi);
1124}
1125
1126static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
1127{
1128 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1129 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
1130
1131 if (value != map_type) {
1132 switch (value) {
1133 case KMI_TYPE_KEYBOARD:
1134 kmi->type = EVT_AKEY;
1135 kmi->val = KM_PRESS;
1136 break;
1137 case KMI_TYPE_MOUSE:
1138 kmi->type = LEFTMOUSE;
1139 kmi->val = KM_PRESS;
1140 break;
1141 case KMI_TYPE_TEXTINPUT:
1142 kmi->type = KM_TEXTINPUT;
1143 kmi->val = KM_NOTHING;
1144 break;
1145 case KMI_TYPE_TIMER:
1146 kmi->type = TIMER;
1147 kmi->val = KM_NOTHING;
1148 break;
1149 case KMI_TYPE_NDOF:
1150 kmi->type = NDOF_MOTION;
1151 kmi->val = KM_NOTHING;
1152 break;
1153 }
1154 }
1155}
1156
1161static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value)
1162{
1163 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1164
1165 /* XXX, this should really be managed in an _itemf function,
1166 * giving a list of valid enums, then silently changing them when they are set is not
1167 * a good precedent, don't do this unless you have a good reason! */
1168 if (value == EVT_ESCKEY) {
1169 /* pass */
1170 }
1171 else if (ISKEYBOARD(value) && !ISKEYMODIFIER(value)) {
1172 kmi->keymodifier = value;
1173 }
1174 else {
1175 kmi->keymodifier = 0;
1176 }
1177}
1178
1179static const EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext * /*C*/,
1180 PointerRNA *ptr,
1181 PropertyRNA * /*prop*/,
1182 bool * /*r_free*/)
1183{
1184 int map_type = rna_wmKeyMapItem_map_type_get(ptr);
1185
1186 if (map_type == KMI_TYPE_MOUSE) {
1187 return event_mouse_type_items;
1188 }
1189 if (map_type == KMI_TYPE_TIMER) {
1190 return event_timer_type_items;
1191 }
1192 if (map_type == KMI_TYPE_NDOF) {
1193 return event_ndof_type_items;
1194 }
1195 if (map_type == KMI_TYPE_TEXTINPUT) {
1196 return event_textinput_type_items;
1197 }
1198 else {
1200 }
1201}
1202
1203static const EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext * /*C*/,
1204 PointerRNA *ptr,
1205 PropertyRNA * /*prop*/,
1206 bool * /*r_free*/)
1207{
1208 wmWindowManager *wm = G_MAIN->wm.first();
1209 wmKeyConfig *kc;
1210 wmKeyMap *km;
1211
1212 for (kc = wm->runtime->keyconfigs.first(); kc; kc = kc->next) {
1213 for (km = kc->keymaps.first(); km; km = km->next) {
1214 /* only check if it's a modal keymap */
1215 if (km->modal_items) {
1216 wmKeyMapItem *kmi;
1217 for (kmi = km->items.first(); kmi; kmi = kmi->next) {
1218 if (kmi == ptr->data) {
1219 return static_cast<const EnumPropertyItem *>(km->modal_items);
1220 }
1221 }
1222 }
1223 }
1224 }
1225
1226 return rna_enum_keymap_propvalue_items; /* ERROR */
1227}
1228
1229static bool rna_KeyMapItem_any_get(PointerRNA *ptr)
1230{
1231 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1232
1233 if (kmi->shift == KM_ANY && kmi->ctrl == KM_ANY && kmi->alt == KM_ANY && kmi->oskey == KM_ANY &&
1234 kmi->hyper == KM_ANY)
1235 {
1236 return true;
1237 }
1238 else {
1239 return false;
1240 }
1241}
1242
1243static void rna_KeyMapItem_any_set(PointerRNA *ptr, bool value)
1244{
1245 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1246
1247 if (value) {
1248 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = kmi->hyper = KM_ANY;
1249 }
1250 else {
1251 kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = kmi->hyper = KM_NOTHING;
1252 }
1253}
1254
1255static bool rna_KeyMapItem_shift_get(PointerRNA *ptr)
1256{
1257 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1258 return kmi->shift != KM_NOTHING;
1259}
1260
1261static bool rna_KeyMapItem_ctrl_get(PointerRNA *ptr)
1262{
1263 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1264 return kmi->ctrl != KM_NOTHING;
1265}
1266
1267static bool rna_KeyMapItem_alt_get(PointerRNA *ptr)
1268{
1269 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1270 return kmi->alt != KM_NOTHING;
1271}
1272
1273static bool rna_KeyMapItem_oskey_get(PointerRNA *ptr)
1274{
1275 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1276 return kmi->oskey != KM_NOTHING;
1277}
1278
1279static bool rna_KeyMapItem_hyper_get(PointerRNA *ptr)
1280{
1281 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1282 return kmi->hyper != KM_NOTHING;
1283}
1284
1285static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
1286{
1287 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1288 wmKeyConfig *kc;
1289
1290 kc = static_cast<wmKeyConfig *>(
1291 BLI_findstring(&wm->runtime->keyconfigs, U.keyconfigstr, offsetof(wmKeyConfig, idname)));
1292
1293 if (!kc) {
1294 kc = wm->runtime->defaultconf;
1295 }
1296
1297 return RNA_pointer_create_with_parent(*ptr, RNA_KeyConfig, kc);
1298}
1299
1300static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr,
1301 PointerRNA value,
1302 ReportList * /*reports*/)
1303{
1304 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1305 wmKeyConfig *kc = static_cast<wmKeyConfig *>(value.data);
1306
1307 if (kc) {
1308 WM_keyconfig_set_active(wm, kc->idname);
1309 }
1310}
1311
1312static PointerRNA rna_WindowManager_default_keyconfig_get(PointerRNA *ptr)
1313{
1314 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1315 return RNA_pointer_create_with_parent(*ptr, RNA_KeyConfig, wm->runtime->defaultconf);
1316}
1317
1318static PointerRNA rna_WindowManager_addon_keyconfig_get(PointerRNA *ptr)
1319{
1320 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1321 return RNA_pointer_create_with_parent(*ptr, RNA_KeyConfig, wm->runtime->addonconf);
1322}
1323
1324static PointerRNA rna_WindowManager_user_keyconfig_get(PointerRNA *ptr)
1325{
1326 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1327 return RNA_pointer_create_with_parent(*ptr, RNA_KeyConfig, wm->runtime->userconf);
1328}
1329
1330static void rna_WindowManager_extensions_statusbar_update(Main * /*bmain*/,
1331 Scene * /*scene*/,
1332 PointerRNA *ptr)
1333{
1334 if ((U.statusbar_flag & STATUSBAR_SHOW_EXTENSIONS_UPDATES) == 0) {
1335 return;
1336 }
1337
1338 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1339 for (wmWindow &win : wm->windows) {
1341 }
1342}
1343
1344/* -------------------------------------------------------------------- */
1347
1348static PointerRNA rna_wmKeyConfig_preferences_get(PointerRNA *ptr)
1349{
1350 wmKeyConfig *kc = static_cast<wmKeyConfig *>(ptr->data);
1351 wmKeyConfigPrefType_Runtime *kpt_rt = BKE_keyconfig_pref_type_find(kc->idname, true);
1352 if (kpt_rt) {
1353 wmKeyConfigPref *kpt = BKE_keyconfig_pref_ensure(&U, kc->idname);
1354 return RNA_pointer_create_with_parent(*ptr, kpt_rt->rna_ext.srna, kpt->prop);
1355 }
1356 else {
1357 return {};
1358 }
1359}
1360
1361static IDProperty **rna_wmKeyConfigPref_idprops(PointerRNA *ptr)
1362{
1363 return reinterpret_cast<IDProperty **>(&ptr->data);
1364}
1365
1366static bool rna_wmKeyConfigPref_unregister(Main *bmain, StructRNA *type)
1367{
1368 wmKeyConfigPrefType_Runtime *kpt_rt = static_cast<wmKeyConfigPrefType_Runtime *>(
1370
1371 if (!kpt_rt) {
1372 return false;
1373 }
1375 RNA_struct_free_extension(type, &kpt_rt->rna_ext);
1377
1378 /* Possible we're not in the preferences if they have been reset. */
1380
1381 /* update while blender is running */
1383 return true;
1384}
1385
1386static StructRNA *rna_wmKeyConfigPref_register(Main *bmain,
1387 ReportList *reports,
1388 void *data,
1389 const char *identifier,
1390 StructValidateFunc validate,
1391 StructCallbackFunc call,
1393{
1394 const char *error_prefix = "Registering key-config preferences class:";
1395 wmKeyConfigPrefType_Runtime *kpt_rt, dummy_kpt_rt = {{'\0'}};
1396 wmKeyConfigPref dummy_kpt = {nullptr};
1397 // bool have_function[1];
1398
1399 /* setup dummy keyconf-prefs & keyconf-prefs type to store static properties in */
1401 nullptr, RNA_KeyConfigPreferences, &dummy_kpt);
1402
1403 /* validate the python class */
1404 if (validate(&dummy_kpt_ptr, data, nullptr /*have_function*/) != 0) {
1405 return nullptr;
1406 }
1407
1408 STRNCPY(dummy_kpt_rt.idname, dummy_kpt.idname);
1409 if (strlen(identifier) >= sizeof(dummy_kpt_rt.idname)) {
1410 BKE_reportf(reports,
1411 RPT_ERROR,
1412 "%s '%s' is too long, maximum length is %d",
1413 error_prefix,
1414 identifier,
1415 int(sizeof(dummy_kpt_rt.idname)));
1416 return nullptr;
1417 }
1418
1419 /* check if we have registered this keyconf-prefs type before, and remove it */
1420 kpt_rt = BKE_keyconfig_pref_type_find(dummy_kpt.idname, true);
1421 if (kpt_rt) {
1422 BKE_reportf(reports,
1423 RPT_INFO,
1424 "%s '%s', bl_idname '%s' has been registered before, unregistering previous",
1425 error_prefix,
1426 identifier,
1427 dummy_kpt.idname);
1428
1429 StructRNA *srna = kpt_rt->rna_ext.srna;
1430 if (!(srna && rna_wmKeyConfigPref_unregister(bmain, srna))) {
1431 BKE_reportf(reports,
1432 RPT_ERROR,
1433 "%s '%s', bl_idname '%s' %s",
1434 error_prefix,
1435 identifier,
1436 dummy_kpt.idname,
1437 srna ? "is built-in" : "could not be unregistered");
1438 return nullptr;
1439 }
1440 }
1441
1442 /* create a new keyconf-prefs type */
1443 kpt_rt = MEM_new_uninitialized<wmKeyConfigPrefType_Runtime>("keyconfigpreftype");
1444 memcpy(kpt_rt, &dummy_kpt_rt, sizeof(dummy_kpt_rt));
1445
1447
1448 kpt_rt->rna_ext.srna = RNA_def_struct_ptr(
1449 &RNA_blender_rna_get(), identifier, RNA_KeyConfigPreferences);
1450 kpt_rt->rna_ext.data = data;
1451 kpt_rt->rna_ext.call = call;
1452 kpt_rt->rna_ext.free = free;
1453 RNA_struct_blender_type_set(kpt_rt->rna_ext.srna, kpt_rt);
1454
1455 // kpt_rt->draw = (have_function[0]) ? header_draw : nullptr;
1456
1457 /* update while blender is running */
1459
1460 return kpt_rt->rna_ext.srna;
1461}
1462
1463/* placeholder, doesn't do anything useful yet */
1464static StructRNA *rna_wmKeyConfigPref_refine(PointerRNA *ptr)
1465{
1466 return (ptr->type) ? ptr->type : RNA_KeyConfigPreferences;
1467}
1468
1470
1471static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
1472{
1473 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1474 /* Pass in a fixed size buffer as the value may be allocated based on the callbacks length. */
1475 char value_buf[OP_MAX_TYPENAME];
1476 int len = WM_operator_py_idname(value_buf, kmi->idname);
1477 memcpy(value, value_buf, len + 1);
1478}
1479
1480static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
1481{
1482 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1483 char pyname[OP_MAX_TYPENAME];
1484 return WM_operator_py_idname(pyname, kmi->idname);
1485}
1486
1487static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
1488{
1489 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1490 char idname[OP_MAX_TYPENAME];
1491
1492 WM_operator_bl_idname(idname, value);
1493
1494 if (!STREQ(idname, kmi->idname)) {
1495 STRNCPY(kmi->idname, idname);
1496
1497 WM_keymap_item_properties_reset(kmi, nullptr);
1498 }
1499}
1500
1501static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
1502{
1503 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1504 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
1505 strcpy(value, ot ? WM_operatortype_name(ot, kmi->ptr).c_str() : kmi->idname);
1506}
1507
1508static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
1509{
1510 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1511 wmOperatorType *ot = WM_operatortype_find(kmi->idname, 1);
1512 return strlen(ot ? WM_operatortype_name(ot, kmi->ptr).c_str() : kmi->idname);
1513}
1514
1515static bool rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
1516{
1517 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
1518 return kmi->id < 0;
1519}
1520
1521static void rna_WindowManager_operators_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1522{
1523 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1524 rna_iterator_listbase_begin(iter, ptr, &wm->runtime->operators, nullptr);
1525}
1526
1527static void rna_WindowManager_reports_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1528{
1529 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1530 rna_iterator_listbase_begin(iter, ptr, &wm->runtime->reports.list, nullptr);
1531}
1532
1533static int rna_Report_session_uid_get(PointerRNA *ptr)
1534{
1535 const Report *report = static_cast<const Report *>(ptr->data);
1536 return report->session_uid;
1537}
1538
1539static int rna_Report_type_get(PointerRNA *ptr)
1540{
1541 const Report *report = static_cast<const Report *>(ptr->data);
1542 return report->type;
1543}
1544
1545static void rna_Report_message_get(PointerRNA *ptr, char *value)
1546{
1547 const Report *report = static_cast<const Report *>(ptr->data);
1548 strcpy(value, report->message);
1549}
1550
1551static int rna_Report_message_length(PointerRNA *ptr)
1552{
1553 const Report *report = static_cast<const Report *>(ptr->data);
1554 return report->len;
1555}
1556
1557static void rna_WindowManager_keyconfigs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
1558{
1559 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1560 rna_iterator_listbase_begin(iter, ptr, &wm->runtime->keyconfigs, nullptr);
1561}
1562
1563static bool rna_WindowManager_is_event_handling_break_get(PointerRNA *ptr)
1564{
1565 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1566 return wm->runtime->break_events_handling;
1567}
1568
1569static PointerRNA rna_WindowManager_xr_session_state_get(PointerRNA *ptr)
1570{
1571 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1572 struct wmXrSessionState *state =
1573# ifdef WITH_XR_OPENXR
1575# else
1576 nullptr;
1577 UNUSED_VARS(wm);
1578# endif
1579
1580 return RNA_pointer_create_with_parent(*ptr, RNA_XrSessionState, state);
1581}
1582
1583static PointerRNA rna_WindowManager_undo_stack_get(PointerRNA *ptr)
1584{
1585 wmWindowManager *wm = static_cast<wmWindowManager *>(ptr->data);
1586 return RNA_pointer_create_with_parent(*ptr, RNA_UndoStack, wm->runtime->undo_stack);
1587}
1588
1589# ifdef WITH_PYTHON
1590
1591static bool rna_operator_poll_cb(bContext *C, wmOperatorType *ot)
1592{
1593 extern FunctionRNA *rna_Operator_poll_func;
1594
1596 FunctionRNA *func;
1597 void *ret;
1598 bool visible;
1599
1600 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, ot->rna_ext.srna, nullptr); /* dummy */
1601 func = rna_Operator_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
1602
1603 RNA_parameter_list_create(&list, &ptr, func);
1604 RNA_parameter_set_lookup(&list, "context", &C);
1605 ot->rna_ext.call(C, &ptr, func, &list);
1606
1607 RNA_parameter_get_lookup(&list, "visible", &ret);
1608 visible = *static_cast<bool *>(ret);
1609
1611
1612 return visible;
1613}
1614
1615static wmOperatorStatus rna_operator_exec_cb(bContext *C, wmOperator *op)
1616{
1617 extern FunctionRNA *rna_Operator_execute_func;
1618
1620 FunctionRNA *func;
1621 void *ret;
1622
1623 ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
1624 PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
1625 func = rna_Operator_execute_func; /* RNA_struct_find_function(&opr, "execute"); */
1626
1627 RNA_parameter_list_create(&list, &opr, func);
1628 RNA_parameter_set_lookup(&list, "context", &C);
1629 const bool has_error = op->type->rna_ext.call(C, &opr, func, &list) == -1;
1630
1631 RNA_parameter_get_lookup(&list, "result", &ret);
1632 const wmOperatorStatus result = wmOperatorStatus(*static_cast<int *>(ret));
1633
1635
1636 if (has_error) [[unlikely]] {
1637 /* A modal handler may have been added, ensure this is removed, see: #113479. */
1639 }
1640
1642 return result;
1643}
1644
1645/* same as execute() but no return value */
1646static bool rna_operator_check_cb(bContext *C, wmOperator *op)
1647{
1648 extern FunctionRNA *rna_Operator_check_func;
1649
1651 FunctionRNA *func;
1652 void *ret;
1653 bool result;
1654
1655 ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
1656 PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
1657 func = rna_Operator_check_func; /* RNA_struct_find_function(&opr, "check"); */
1658
1659 RNA_parameter_list_create(&list, &opr, func);
1660 RNA_parameter_set_lookup(&list, "context", &C);
1661 op->type->rna_ext.call(C, &opr, func, &list);
1662
1663 RNA_parameter_get_lookup(&list, "result", &ret);
1664 result = (*static_cast<bool *>(ret)) != 0;
1665
1667
1668 return result;
1669}
1670
1671static wmOperatorStatus rna_operator_invoke_cb(bContext *C, wmOperator *op, const wmEvent *event)
1672{
1673 extern FunctionRNA *rna_Operator_invoke_func;
1674
1676 FunctionRNA *func;
1677 void *ret;
1678
1679 ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
1680 PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
1681 func = rna_Operator_invoke_func; /* RNA_struct_find_function(&opr, "invoke"); */
1682
1683 RNA_parameter_list_create(&list, &opr, func);
1684 RNA_parameter_set_lookup(&list, "context", &C);
1685 RNA_parameter_set_lookup(&list, "event", &event);
1686 const bool has_error = op->type->rna_ext.call(C, &opr, func, &list) == -1;
1687
1688 RNA_parameter_get_lookup(&list, "result", &ret);
1689 wmOperatorStatus retval = wmOperatorStatus(*static_cast<int *>(ret));
1690
1692
1693 if (has_error) [[unlikely]] {
1694 /* A modal handler may have been added, ensure this is removed, see: #113479. */
1696 }
1697
1698 OPERATOR_RETVAL_CHECK(retval);
1699 return retval;
1700}
1701
1702/* same as invoke */
1703static wmOperatorStatus rna_operator_modal_cb(bContext *C, wmOperator *op, const wmEvent *event)
1704{
1705 extern FunctionRNA *rna_Operator_modal_func;
1706
1708 FunctionRNA *func;
1709 void *ret;
1710
1711 ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
1712 PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
1713 func = rna_Operator_modal_func; /* RNA_struct_find_function(&opr, "modal"); */
1714
1715 RNA_parameter_list_create(&list, &opr, func);
1716 RNA_parameter_set_lookup(&list, "context", &C);
1717 RNA_parameter_set_lookup(&list, "event", &event);
1718 op->type->rna_ext.call(C, &opr, func, &list);
1719
1720 RNA_parameter_get_lookup(&list, "result", &ret);
1721 wmOperatorStatus retval = wmOperatorStatus(*static_cast<int *>(ret));
1722
1724
1725 OPERATOR_RETVAL_CHECK(retval);
1726 return retval;
1727}
1728
1729static void rna_operator_draw_cb(bContext *C, wmOperator *op)
1730{
1731 extern FunctionRNA *rna_Operator_draw_func;
1732
1734 FunctionRNA *func;
1735
1736 /* Operator draw gets reused for drawing stored properties, in which
1737 * case we need a proper owner. */
1738 ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
1739 PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
1740 func = rna_Operator_draw_func; /* RNA_struct_find_function(&opr, "draw"); */
1741
1742 RNA_parameter_list_create(&list, &opr, func);
1743 RNA_parameter_set_lookup(&list, "context", &C);
1744 op->type->rna_ext.call(C, &opr, func, &list);
1745
1747}
1748
1749/* same as exec(), but call cancel */
1750static void rna_operator_cancel_cb(bContext *C, wmOperator *op)
1751{
1752 extern FunctionRNA *rna_Operator_cancel_func;
1753
1755 FunctionRNA *func;
1756
1757 ID *owner_id = (op->ptr) ? op->ptr->owner_id : nullptr;
1758 PointerRNA opr = RNA_pointer_create_discrete(owner_id, op->type->rna_ext.srna, op);
1759 func = rna_Operator_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */
1760
1761 RNA_parameter_list_create(&list, &opr, func);
1762 RNA_parameter_set_lookup(&list, "context", &C);
1763 op->type->rna_ext.call(C, &opr, func, &list);
1764
1766}
1767
1768static std::string rna_operator_description_cb(bContext *C,
1769 wmOperatorType *ot,
1770 PointerRNA *prop_ptr)
1771{
1772 extern FunctionRNA *rna_Operator_description_func;
1773
1775 FunctionRNA *func;
1776 void *ret;
1777
1778 PointerRNA ptr = RNA_pointer_create_discrete(nullptr, ot->rna_ext.srna, nullptr); /* dummy */
1779 func = rna_Operator_description_func; /* RNA_struct_find_function(&ptr, "description"); */
1780
1781 RNA_parameter_list_create(&list, &ptr, func);
1782 RNA_parameter_set_lookup(&list, "context", &C);
1783 RNA_parameter_set_lookup(&list, "properties", prop_ptr);
1784 ot->rna_ext.call(C, &ptr, func, &list);
1785
1786 RNA_parameter_get_lookup(&list, "result", &ret);
1787 std::string result = ret ? std::string(static_cast<const char *>(ret)) : "";
1788
1790
1791 return result;
1792}
1793
1794static bool rna_Operator_unregister(Main *bmain, StructRNA *type);
1795
1796/* `bpy_operator_wrap.cc` */
1797
1798extern void BPY_RNA_operator_wrapper(wmOperatorType *ot, void *userdata);
1799extern void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata);
1800
1801static StructRNA *rna_Operator_register(Main *bmain,
1802 ReportList *reports,
1803 void *data,
1804 const char *identifier,
1805 StructValidateFunc validate,
1806 StructCallbackFunc call,
1808{
1809 const char *error_prefix = "Registering operator class:";
1810 wmOperatorType dummy_ot = {nullptr};
1811 wmOperator dummy_operator = {nullptr};
1812 bool have_function[8];
1813
1814 struct {
1815 char idname[OP_MAX_TYPENAME];
1816 char name[OP_MAX_TYPENAME];
1817 char description[RNA_DYN_DESCR_MAX];
1818 char translation_context[BKE_ST_MAXNAME];
1819 char undo_group[OP_MAX_TYPENAME];
1820 } temp_buffers;
1821
1822 /* setup dummy operator & operator type to store static properties in */
1823 dummy_operator.type = &dummy_ot;
1824 dummy_ot.idname = temp_buffers.idname; /* only assign the pointer, string is nullptr'd */
1825 dummy_ot.name = temp_buffers.name; /* only assign the pointer, string is nullptr'd */
1826 dummy_ot.description =
1827 temp_buffers.description; /* only assign the pointer, string is nullptr'd */
1828 dummy_ot.translation_context =
1829 temp_buffers.translation_context; /* only assign the pointer, string is nullptr'd */
1830 dummy_ot.undo_group = temp_buffers.undo_group; /* only assign the pointer, string is nullptr'd */
1831 PointerRNA dummy_operator_ptr = RNA_pointer_create_discrete(
1832 nullptr, RNA_Operator, &dummy_operator);
1833
1834 /* clear in case they are left unset */
1835 temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] =
1836 temp_buffers.undo_group[0] = temp_buffers.translation_context[0] = '\0';
1837
1838 /* validate the python class */
1839 if (validate(&dummy_operator_ptr, data, have_function) != 0) {
1840 return nullptr;
1841 }
1842
1843 /* check if we have registered this operator type before, and remove it */
1844 {
1845 wmOperatorType *ot = WM_operatortype_find(dummy_ot.idname, true);
1846 if (ot) {
1847 BKE_reportf(reports,
1848 RPT_INFO,
1849 "%s '%s', bl_idname '%s' has been registered before, unregistering previous",
1850 error_prefix,
1851 identifier,
1852 dummy_ot.idname);
1853
1854 StructRNA *srna = ot->rna_ext.srna;
1855 if (!(srna && rna_Operator_unregister(bmain, srna))) {
1856 BKE_reportf(reports,
1857 RPT_ERROR,
1858 "%s '%s', bl_idname '%s' %s",
1859 error_prefix,
1860 identifier,
1861 dummy_ot.idname,
1862 srna ? "is built-in" : "could not be unregistered");
1863 return nullptr;
1864 }
1865 }
1866 }
1867
1868 if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummy_ot.idname)) {
1869 return nullptr;
1870 }
1871
1872 char idname_conv[sizeof(dummy_operator.idname)];
1873 WM_operator_bl_idname(idname_conv, dummy_ot.idname); /* convert the idname from python */
1874
1875 if (!RNA_struct_available_or_report(reports, idname_conv)) {
1876 return nullptr;
1877 }
1878
1879 /* We have to set default context if the class doesn't define it. */
1880 if (temp_buffers.translation_context[0] == '\0') {
1881 STRNCPY(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
1882 }
1883
1884 /* Convert foo.bar to `FOO_OT_bar`
1885 * allocate all strings at once. */
1886 {
1887 const char *strings[] = {
1888 idname_conv,
1889 temp_buffers.name,
1890 temp_buffers.description,
1891 temp_buffers.translation_context,
1892 temp_buffers.undo_group,
1893 };
1894 char *strings_table[ARRAY_SIZE(strings)];
1896 '\0', strings_table, strings, ARRAY_SIZE(strings));
1897
1898 dummy_ot.idname = strings_table[0]; /* allocated string stored here */
1899 dummy_ot.name = strings_table[1];
1900 dummy_ot.description = *strings_table[2] ? strings_table[2] : nullptr;
1901 dummy_ot.translation_context = strings_table[3];
1902 dummy_ot.undo_group = strings_table[4];
1903 BLI_STATIC_ASSERT(ARRAY_SIZE(strings) == 5, "Unexpected number of strings")
1904 }
1905
1906 /* XXX, this doubles up with the operator name #29666.
1907 * for now just remove from `dir(bpy.types)`. */
1908
1909 /* create a new operator type */
1910 dummy_ot.rna_ext.srna = RNA_def_struct_ptr(
1911 &RNA_blender_rna_get(), dummy_ot.idname, RNA_Operator);
1912
1913 /* Operator properties are registered separately. */
1914 RNA_def_struct_flag(dummy_ot.rna_ext.srna, STRUCT_NO_IDPROPERTIES);
1915
1917 RNA_def_struct_translation_context(dummy_ot.rna_ext.srna, dummy_ot.translation_context);
1918 dummy_ot.rna_ext.data = data;
1919 dummy_ot.rna_ext.call = call;
1920 dummy_ot.rna_ext.free = free;
1921
1922 dummy_ot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : nullptr;
1923 dummy_ot.exec = (have_function[1]) ? rna_operator_exec_cb : nullptr;
1924 dummy_ot.check = (have_function[2]) ? rna_operator_check_cb : nullptr;
1925 dummy_ot.invoke = (have_function[3]) ? rna_operator_invoke_cb : nullptr;
1926 dummy_ot.modal = (have_function[4]) ? rna_operator_modal_cb : nullptr;
1927 dummy_ot.ui = (have_function[5]) ? rna_operator_draw_cb : nullptr;
1928 dummy_ot.cancel = (have_function[6]) ? rna_operator_cancel_cb : nullptr;
1929 dummy_ot.get_description = (have_function[7]) ? rna_operator_description_cb : nullptr;
1930 WM_operatortype_append_ptr(BPY_RNA_operator_wrapper, static_cast<void *>(&dummy_ot));
1931
1932 /* update while blender is running */
1934
1935 return dummy_ot.rna_ext.srna;
1936}
1937
1938static bool rna_Operator_unregister(Main *bmain, StructRNA *type)
1939{
1940 const char *idname;
1941 wmOperatorType *ot = static_cast<wmOperatorType *>(RNA_struct_blender_type_get(type));
1943
1944 if (!ot) {
1945 return false;
1946 }
1947 ui::refresh_for_srna_unregister(bmain, ot->srna);
1949 /* update while blender is running */
1950 wm = bmain->wm.first();
1951 if (wm) {
1953
1955 }
1957
1958 RNA_struct_free_extension(type, &ot->rna_ext);
1959
1960 idname = ot->idname;
1962
1963 /* Not to be confused with the RNA_struct_free that WM_operatortype_remove calls,
1964 * they are 2 different srna's. */
1966
1967 MEM_delete(idname);
1968 return true;
1969}
1970
1971static void **rna_Operator_instance(PointerRNA *ptr)
1972{
1973 wmOperator *op = static_cast<wmOperator *>(ptr->data);
1974 return &op->py_instance;
1975}
1976
1977static StructRNA *rna_MacroOperator_register(Main *bmain,
1978 ReportList *reports,
1979 void *data,
1980 const char *identifier,
1981 StructValidateFunc validate,
1982 StructCallbackFunc call,
1984{
1985 const char *error_prefix = "Registering operator macro class:";
1986 wmOperatorType dummy_ot = {nullptr};
1987 wmOperator dummy_operator = {nullptr};
1988 bool have_function[2];
1989
1990 struct {
1991 char idname[OP_MAX_TYPENAME];
1992 char name[OP_MAX_TYPENAME];
1993 char description[RNA_DYN_DESCR_MAX];
1994 char translation_context[BKE_ST_MAXNAME];
1995 char undo_group[OP_MAX_TYPENAME];
1996 } temp_buffers;
1997
1998 /* setup dummy operator & operator type to store static properties in */
1999 dummy_operator.type = &dummy_ot;
2000 dummy_ot.idname = temp_buffers.idname; /* only assign the pointer, string is nullptr'd */
2001 dummy_ot.name = temp_buffers.name; /* only assign the pointer, string is nullptr'd */
2002 dummy_ot.description =
2003 temp_buffers.description; /* only assign the pointer, string is nullptr'd */
2004 dummy_ot.translation_context =
2005 temp_buffers.translation_context; /* only assign the pointer, string is nullptr'd */
2006 dummy_ot.undo_group = temp_buffers.undo_group; /* only assign the pointer, string is nullptr'd */
2007 PointerRNA dummy_operator_ptr = RNA_pointer_create_discrete(nullptr, RNA_Macro, &dummy_operator);
2008
2009 /* clear in case they are left unset */
2010 temp_buffers.idname[0] = temp_buffers.name[0] = temp_buffers.description[0] =
2011 temp_buffers.undo_group[0] = temp_buffers.translation_context[0] = '\0';
2012
2013 /* validate the python class */
2014 if (validate(&dummy_operator_ptr, data, have_function) != 0) {
2015 return nullptr;
2016 }
2017
2018 if (!WM_operator_py_idname_ok_or_report(reports, identifier, dummy_ot.idname)) {
2019 return nullptr;
2020 }
2021
2022 /* check if we have registered this operator type before, and remove it */
2023 {
2024 wmOperatorType *ot = WM_operatortype_find(dummy_ot.idname, true);
2025 if (ot) {
2026 BKE_reportf(reports,
2027 RPT_INFO,
2028 "%s '%s', bl_idname '%s' has been registered before, unregistering previous",
2029 error_prefix,
2030 identifier,
2031 dummy_ot.idname);
2032
2033 StructRNA *srna = ot->rna_ext.srna;
2034 if (!(srna && rna_Operator_unregister(bmain, srna))) {
2035 BKE_reportf(reports,
2036 RPT_ERROR,
2037 "%s '%s', bl_idname '%s' %s",
2038 error_prefix,
2039 identifier,
2040 dummy_ot.idname,
2041 srna ? "is built-in" : "could not be unregistered");
2042 return nullptr;
2043 }
2044 }
2045 }
2046
2047 char idname_conv[sizeof(dummy_operator.idname)];
2048 WM_operator_bl_idname(idname_conv, dummy_ot.idname); /* convert the idname from python */
2049
2050 if (!RNA_struct_available_or_report(reports, idname_conv)) {
2051 return nullptr;
2052 }
2053
2054 /* We have to set default context if the class doesn't define it. */
2055 if (temp_buffers.translation_context[0] == '\0') {
2056 STRNCPY(temp_buffers.translation_context, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
2057 }
2058
2059 /* Convert `foo.bar` to `FOO_OT_bar`
2060 * allocate all strings at once. */
2061 {
2062 const char *strings[] = {
2063 idname_conv,
2064 temp_buffers.name,
2065 temp_buffers.description,
2066 temp_buffers.translation_context,
2067 temp_buffers.undo_group,
2068 };
2069 char *strings_table[ARRAY_SIZE(strings)];
2071 '\0', strings_table, strings, ARRAY_SIZE(strings));
2072
2073 dummy_ot.idname = strings_table[0]; /* allocated string stored here */
2074 dummy_ot.name = strings_table[1];
2075 dummy_ot.description = *strings_table[2] ? strings_table[2] : nullptr;
2076 dummy_ot.translation_context = strings_table[3];
2077 dummy_ot.undo_group = strings_table[4];
2078 BLI_STATIC_ASSERT(ARRAY_SIZE(strings) == 5, "Unexpected number of strings")
2079 }
2080
2081 /* XXX, this doubles up with the operator name #29666.
2082 * for now just remove from `dir(bpy.types)`. */
2083
2084 /* create a new operator type */
2085 dummy_ot.rna_ext.srna = RNA_def_struct_ptr(
2086 &RNA_blender_rna_get(), dummy_ot.idname, RNA_Operator);
2087 RNA_def_struct_translation_context(dummy_ot.rna_ext.srna, dummy_ot.translation_context);
2088 dummy_ot.rna_ext.data = data;
2089 dummy_ot.rna_ext.call = call;
2090 dummy_ot.rna_ext.free = free;
2091
2092 dummy_ot.pyop_poll = (have_function[0]) ? rna_operator_poll_cb : nullptr;
2093 dummy_ot.ui = (have_function[1]) ? rna_operator_draw_cb : nullptr;
2094
2096
2097 /* update while blender is running */
2099
2100 return dummy_ot.rna_ext.srna;
2101}
2102# endif /* WITH_PYTHON */
2103
2104static StructRNA *rna_Operator_refine(PointerRNA *opr)
2105{
2106 wmOperator *op = static_cast<wmOperator *>(opr->data);
2107 return (op->type && op->type->rna_ext.srna) ? op->type->rna_ext.srna : RNA_Operator;
2108}
2109
2110static StructRNA *rna_MacroOperator_refine(PointerRNA *opr)
2111{
2112 wmOperator *op = static_cast<wmOperator *>(opr->data);
2113 return (op->type && op->type->rna_ext.srna) ? op->type->rna_ext.srna : RNA_Macro;
2114}
2115
2116/* just to work around 'const char *' warning and to ensure this is a python op */
2117static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
2118{
2119 wmOperator *data = static_cast<wmOperator *>(ptr->data);
2120 char *str = const_cast<char *>(data->type->idname);
2121 if (!str[0]) {
2122 /* Calling UTF8 copy is disputable since registering ensures the value isn't truncated.
2123 * Use a UTF8 copy to ensure truncating never causes an incomplete UTF8 sequence,
2124 * even before registration. */
2126 }
2127 else {
2128 BLI_assert_msg(0, "setting the bl_idname on a non-builtin operator");
2129 }
2130}
2131
2132static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
2133{
2134 wmOperator *data = static_cast<wmOperator *>(ptr->data);
2135 char *str = const_cast<char *>(data->type->name);
2136 if (!str[0]) {
2138 }
2139 else {
2140 BLI_assert_msg(0, "setting the bl_label on a non-builtin operator");
2141 }
2142}
2143
2149# define OPERATOR_STR_MAYBE_NULL_GETSET(attr, attr_maxncpy) \
2150 static void rna_Operator_bl_##attr##_set(PointerRNA *ptr, const char *value) \
2151 { \
2152 wmOperator *data = (wmOperator *)(ptr->data); \
2153 char *str = (char *)data->type->attr; \
2154 if (str && !str[0]) { \
2155 BLI_strncpy_utf8(str, value, attr_maxncpy); \
2156 } \
2157 else { \
2158 BLI_assert_msg(false, "setting the bl_" #attr " on a non-builtin operator"); \
2159 } \
2160 } \
2161 static void rna_Operator_bl_##attr##_get(PointerRNA *ptr, char *value) \
2162 { \
2163 const wmOperator *data = (wmOperator *)(ptr->data); \
2164 const char *str = data->type->attr; \
2165 strcpy(value, str ? str : ""); \
2166 } \
2167 static int rna_Operator_bl_##attr##_length(PointerRNA *ptr) \
2168 { \
2169 const wmOperator *data = (wmOperator *)(ptr->data); \
2170 const char *str = data->type->attr; \
2171 return str ? strlen(str) : 0; \
2172 }
2173
2174OPERATOR_STR_MAYBE_NULL_GETSET(translation_context, BKE_ST_MAXNAME)
2175OPERATOR_STR_MAYBE_NULL_GETSET(description, RNA_DYN_DESCR_MAX)
2176OPERATOR_STR_MAYBE_NULL_GETSET(undo_group, OP_MAX_TYPENAME)
2177
2178static void rna_KeyMapItem_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
2179{
2180 wmKeyMapItem *kmi = static_cast<wmKeyMapItem *>(ptr->data);
2181 WM_keyconfig_update_tag(nullptr, kmi);
2182}
2183
2184} // namespace blender
2185
2186#else /* RNA_RUNTIME */
2187
2188namespace blender {
2189
2195{
2196 StructRNA *srna;
2197 PropertyRNA *prop;
2198
2199 srna = RNA_def_struct(brna, "OperatorOptions", nullptr);
2200 RNA_def_struct_ui_text(srna, "Operator Options", "Runtime options");
2201 RNA_def_struct_sdna(srna, "wmOperator");
2202
2203 prop = RNA_def_property(srna, "is_grab_cursor", PROP_BOOLEAN, PROP_BOOLEAN);
2205 RNA_def_property_ui_text(prop, "Grab Cursor", "True when the cursor is grabbed");
2207
2208 prop = RNA_def_property(srna, "is_invoke", PROP_BOOLEAN, PROP_BOOLEAN);
2209 RNA_def_property_boolean_sdna(prop, nullptr, "flag", OP_IS_INVOKE);
2211 prop, "Invoke", "True when invoked (even if only the execute callbacks available)");
2213
2214 prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_BOOLEAN);
2215 RNA_def_property_boolean_sdna(prop, nullptr, "flag", OP_IS_REPEAT);
2216 RNA_def_property_ui_text(prop, "Repeat", "True when run from the 'Adjust Last Operation' panel");
2218
2219 prop = RNA_def_property(srna, "is_repeat_last", PROP_BOOLEAN, PROP_BOOLEAN);
2220 RNA_def_property_boolean_sdna(prop, nullptr, "flag", OP_IS_REPEAT_LAST);
2221 RNA_def_property_ui_text(prop, "Repeat Call", "True when run from the operator 'Repeat Last'");
2223
2224 prop = RNA_def_property(srna, "use_cursor_region", PROP_BOOLEAN, PROP_BOOLEAN);
2227 prop, "Focus Region", "Enable to use the region under the cursor for modal execution");
2228}
2229
2231{
2232 PropertyRNA *prop;
2233
2234 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2237 prop, "rna_Operator_name_get", "rna_Operator_name_length", nullptr);
2238 RNA_def_property_ui_text(prop, "Name", "");
2239
2240 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
2242 RNA_def_property_struct_type(prop, "OperatorProperties");
2243 RNA_def_property_ui_text(prop, "Properties", "");
2244 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", nullptr, nullptr, nullptr);
2245
2246 prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
2247 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
2248 RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", nullptr);
2250 prop,
2251 "Has Reports",
2252 "Operator has a set of reports (warnings and errors) from last execution");
2253
2254 /* Registration */
2255 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
2256 RNA_def_property_string_sdna(prop, nullptr, "type->idname");
2257 /* String stored here is the 'BL' identifier (`OPMODULE_OT_my_op`),
2258 * not the 'python' identifier (`opmodule.my_op`). */
2260 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Operator_bl_idname_set");
2261 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2263 RNA_def_struct_name_property(srna, prop);
2264
2265 prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
2266 RNA_def_property_string_sdna(prop, nullptr, "type->name");
2267 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
2268 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_Operator_bl_label_set");
2269 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2271
2272 prop = RNA_def_property(srna, "bl_translation_context", PROP_STRING, PROP_NONE);
2273 RNA_def_property_string_sdna(prop, nullptr, "type->translation_context");
2274 RNA_def_property_string_maxlength(prop, BKE_ST_MAXNAME); /* else it uses the pointer size! */
2276 "rna_Operator_bl_translation_context_get",
2277 "rna_Operator_bl_translation_context_length",
2278 "rna_Operator_bl_translation_context_set");
2281
2282 prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
2283 RNA_def_property_string_sdna(prop, nullptr, "type->description");
2284 RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */
2286 "rna_Operator_bl_description_get",
2287 "rna_Operator_bl_description_length",
2288 "rna_Operator_bl_description_set");
2289 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2291
2292 prop = RNA_def_property(srna, "bl_undo_group", PROP_STRING, PROP_NONE);
2293 RNA_def_property_string_sdna(prop, nullptr, "type->undo_group");
2294 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
2296 "rna_Operator_bl_undo_group_get",
2297 "rna_Operator_bl_undo_group_length",
2298 "rna_Operator_bl_undo_group_set");
2299 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2301
2302 prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
2303 RNA_def_property_enum_sdna(prop, nullptr, "type->flag");
2306 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
2307
2308 prop = RNA_def_property(srna, "bl_cursor_pending", PROP_ENUM, PROP_NONE);
2309 RNA_def_property_enum_sdna(prop, nullptr, "type->cursor_pending");
2313 prop,
2314 "Idle Cursor",
2315 "Cursor to use when waiting for the user to select a location to activate the operator "
2316 "(when ``bl_options`` has ``DEPENDS_ON_CURSOR`` set)");
2317}
2318
2320{
2321 StructRNA *srna;
2322 PropertyRNA *prop;
2323
2324 srna = RNA_def_struct(brna, "Operator", nullptr);
2326 srna, "Operator", "Storage of an operator being executed, or registered after execution");
2327 RNA_def_struct_sdna(srna, "wmOperator");
2328 RNA_def_struct_refine_func(srna, "rna_Operator_refine");
2329# ifdef WITH_PYTHON
2331 srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
2332# endif
2335
2337
2338 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
2339 RNA_def_property_struct_type(prop, "UILayout");
2340 RNA_def_property_pointer_funcs(prop, "rna_Operator_layout_get", nullptr, nullptr, nullptr);
2341
2342 prop = RNA_def_property(srna, "options", PROP_POINTER, PROP_NONE);
2344 RNA_def_property_struct_type(prop, "OperatorOptions");
2345 RNA_def_property_pointer_funcs(prop, "rna_Operator_options_get", nullptr, nullptr, nullptr);
2346 RNA_def_property_ui_text(prop, "Options", "Runtime options");
2347
2348 prop = RNA_def_property(srna, "macros", PROP_COLLECTION, PROP_NONE);
2349 RNA_def_property_collection_sdna(prop, nullptr, "macro", nullptr);
2350 RNA_def_property_struct_type(prop, "Macro");
2351 RNA_def_property_ui_text(prop, "Macros", "");
2352
2353 RNA_api_operator(srna);
2354
2355 srna = RNA_def_struct(brna, "OperatorProperties", nullptr);
2356 RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an operator");
2357 RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
2358 /* NOTE: `RNA_def_struct_idprops_func` should be removed once #132129 is implemented.
2359 * Similar to the issue with the nodes modifiers, see #rna_def_modifier_nodes. */
2360 RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops");
2361 RNA_def_struct_system_idprops_func(srna, "rna_OperatorProperties_idprops");
2364}
2365
2367{
2368 StructRNA *srna;
2369
2370 srna = RNA_def_struct(brna, "Macro", nullptr);
2372 srna,
2373 "Macro Operator",
2374 "Storage of a macro operator being executed, or registered after execution");
2375 RNA_def_struct_sdna(srna, "wmOperator");
2376 RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
2377# ifdef WITH_PYTHON
2379 srna, "rna_MacroOperator_register", "rna_Operator_unregister", "rna_Operator_instance");
2380# endif
2383
2385
2386 RNA_api_macro(srna);
2387}
2388
2390{
2391 StructRNA *srna;
2392 PropertyRNA *prop;
2393
2394 srna = RNA_def_struct(brna, "OperatorMacro", nullptr);
2396 srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added");
2397 RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
2398
2399# if 0
2400 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2402 RNA_def_property_string_sdna(prop, nullptr, "idname");
2403 RNA_def_property_ui_text(prop, "Name", "Name of the sub operator");
2404 RNA_def_struct_name_property(srna, prop);
2405# endif
2406
2407 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
2409 RNA_def_property_struct_type(prop, "OperatorProperties");
2410 RNA_def_property_ui_text(prop, "Properties", "");
2412 prop, "rna_OperatorMacro_properties_get", nullptr, nullptr, nullptr);
2413}
2414
2416{
2417 StructRNA *srna;
2418 PropertyRNA *prop;
2419
2420 srna = RNA_def_struct(brna, "OperatorMousePath", "PropertyGroup");
2422 srna, "Operator Mouse Path", "Mouse path values for operators that record such paths");
2423
2424 prop = RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
2426 RNA_def_property_array(prop, 2);
2427 RNA_def_property_ui_text(prop, "Location", "Mouse location");
2428
2429 prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
2431 RNA_def_property_ui_text(prop, "Time", "Time of mouse location");
2432}
2433
2435{
2436 StructRNA *srna;
2437 PropertyRNA *prop;
2438
2439 srna = RNA_def_struct(brna, "OperatorFileListElement", "PropertyGroup");
2440 RNA_def_struct_ui_text(srna, "Operator File List Element", "");
2441
2442 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
2445 RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list");
2446}
2447
2449{
2450 StructRNA *srna;
2451 PropertyRNA *prop;
2452
2453 srna = RNA_def_struct(brna, "NDOFMotionEventData", nullptr);
2454 RNA_def_struct_ui_text(srna, "NDOF Motion Data", "NDOF motion data for window manager events");
2455
2456 prop = RNA_def_property(srna, "translation", PROP_FLOAT, PROP_XYZ);
2457 RNA_def_property_array(prop, 3);
2459 RNA_def_property_float_funcs(prop, "rna_NDOFMotionEventData_translation_get", nullptr, nullptr);
2461 "Translation",
2462 "The translation of this motion event. "
2463 "The range on each axis is [-1 to 1], "
2464 "before being multiplied by the sensitivity preference. "
2465 "This is typically scaled by the time-delta before use.");
2466
2467 prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_XYZ);
2468 RNA_def_property_array(prop, 3);
2470 RNA_def_property_float_funcs(prop, "rna_NDOFMotionEventData_rotation_get", nullptr, nullptr);
2472 "Rotation",
2473 "Axis-angle rotation of this motion event. "
2474 "The vector magnitude is the angle where 1.0 represents 360 degrees. "
2475 "The angle is typically scaled by the time-delta before use.");
2476
2477 prop = RNA_def_property(srna, "progress", PROP_ENUM, PROP_NONE);
2480 RNA_def_property_enum_funcs(prop, "rna_NDOFMotionEventData_progress_get", nullptr, nullptr);
2481 RNA_def_property_ui_text(prop, "Progress", "Indicates the gesture phase");
2482
2483 prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_TIME);
2485 RNA_def_property_float_funcs(prop, "rna_NDOFMotionEventData_time_delta_get", nullptr, nullptr);
2486 RNA_def_property_ui_text(prop, "Time Delta", "Time since previous motion event (in seconds)");
2487}
2488
2489static void rna_def_event(BlenderRNA *brna)
2490{
2491 StructRNA *srna;
2492 PropertyRNA *prop;
2493
2494 srna = RNA_def_struct(brna, "Event", nullptr);
2495 RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
2496 RNA_def_struct_sdna(srna, "wmEvent");
2497
2498 RNA_define_verify_sdna(false); /* not in sdna */
2499
2500 /* strings */
2501 prop = RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
2503 RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", nullptr);
2504 RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
2505
2506 prop = RNA_def_property(srna, "unicode", PROP_STRING, PROP_NONE);
2509 prop, "rna_Event_unicode_get", "rna_Event_unicode_length", nullptr);
2510 RNA_def_property_ui_text(prop, "Unicode", "Single unicode character for this event");
2511
2512 /* enums */
2513 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
2514 RNA_def_property_enum_sdna(prop, nullptr, "val");
2517 RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
2518
2519 prop = RNA_def_property(srna, "value_prev", PROP_ENUM, PROP_NONE);
2520 RNA_def_property_enum_sdna(prop, nullptr, "prev_val");
2523 RNA_def_property_ui_text(prop, "Previous Value", "The type of event, only applies to some");
2524
2525 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2526 RNA_def_property_enum_sdna(prop, nullptr, "type");
2530 RNA_def_property_ui_text(prop, "Type", "");
2531
2532 prop = RNA_def_property(srna, "type_prev", PROP_ENUM, PROP_NONE);
2533 RNA_def_property_enum_sdna(prop, nullptr, "prev_type");
2537 RNA_def_property_ui_text(prop, "Previous Type", "");
2538
2539 prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
2540 RNA_def_property_enum_sdna(prop, nullptr, "direction");
2543 RNA_def_property_ui_text(prop, "Direction", "The direction (only applies to drag events)");
2544
2545 /* keyboard */
2546 prop = RNA_def_property(srna, "is_repeat", PROP_BOOLEAN, PROP_NONE);
2548 RNA_def_property_boolean_funcs(prop, "rna_Event_is_repeat_get", nullptr);
2549 RNA_def_property_ui_text(prop, "Is Repeat", "The event is generated by holding a key down");
2550
2551 /* Trackpad & NDOF. */
2552 prop = RNA_def_property(srna, "is_consecutive", PROP_BOOLEAN, PROP_NONE);
2554 RNA_def_property_boolean_funcs(prop, "rna_Event_is_consecutive_get", nullptr);
2556 "Is Consecutive",
2557 "Part of a trackpad or NDOF motion, "
2558 "interrupted by cursor motion, button or key press events");
2559
2560 /* mouse */
2561 prop = RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
2562 RNA_def_property_int_sdna(prop, nullptr, "xy[0]");
2565 prop, "Mouse X Position", "The window relative horizontal location of the mouse");
2566
2567 prop = RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
2568 RNA_def_property_int_sdna(prop, nullptr, "xy[1]");
2571 prop, "Mouse Y Position", "The window relative vertical location of the mouse");
2572
2573 prop = RNA_def_property(srna, "mouse_region_x", PROP_INT, PROP_NONE);
2574 RNA_def_property_int_sdna(prop, nullptr, "mval[0]");
2577 prop, "Mouse X Position", "The region relative horizontal location of the mouse");
2578
2579 prop = RNA_def_property(srna, "mouse_region_y", PROP_INT, PROP_NONE);
2580 RNA_def_property_int_sdna(prop, nullptr, "mval[1]");
2583 prop, "Mouse Y Position", "The region relative vertical location of the mouse");
2584
2585 prop = RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
2586 RNA_def_property_int_sdna(prop, nullptr, "prev_xy[0]");
2589 prop, "Mouse Previous X Position", "The window relative horizontal location of the mouse");
2590
2591 prop = RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
2592 RNA_def_property_int_sdna(prop, nullptr, "prev_xy[1]");
2595 prop, "Mouse Previous Y Position", "The window relative vertical location of the mouse");
2596
2597 prop = RNA_def_property(srna, "mouse_prev_press_x", PROP_INT, PROP_NONE);
2598 RNA_def_property_int_sdna(prop, nullptr, "prev_press_xy[0]");
2601 "Mouse Previous X Press Position",
2602 "The window relative horizontal location of the last press event");
2603
2604 prop = RNA_def_property(srna, "mouse_prev_press_y", PROP_INT, PROP_NONE);
2605 RNA_def_property_int_sdna(prop, nullptr, "prev_press_xy[1]");
2608 "Mouse Previous Y Press Position",
2609 "The window relative vertical location of the last press event");
2610
2611 prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_FACTOR);
2614 RNA_def_property_float_funcs(prop, "rna_Event_pressure_get", nullptr, nullptr);
2616 prop, "Tablet Pressure", "The pressure of the tablet or 1.0 if no tablet present");
2617
2618 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_XYZ_LENGTH);
2619 RNA_def_property_array(prop, 2);
2621 RNA_def_property_float_funcs(prop, "rna_Event_tilt_get", nullptr, nullptr);
2623 prop, "Tablet Tilt", "The pressure of the tablet or zeroes if no tablet present");
2624
2625 prop = RNA_def_property(srna, "is_tablet", PROP_BOOLEAN, PROP_NONE);
2627 RNA_def_property_boolean_funcs(prop, "rna_Event_is_tablet_get", nullptr);
2628 RNA_def_property_ui_text(prop, "Is Tablet", "The event has tablet data");
2629
2630 prop = RNA_def_property(srna, "is_mouse_absolute", PROP_BOOLEAN, PROP_NONE);
2631 RNA_def_property_boolean_sdna(prop, nullptr, "tablet.is_motion_absolute", 1);
2633 RNA_def_property_ui_text(prop, "Absolute Motion", "The last motion event was an absolute input");
2634
2635 /* NDOF motion. */
2636 prop = RNA_def_property(srna, "ndof_motion", PROP_POINTER, PROP_NONE);
2637 RNA_def_property_struct_type(prop, "NDOFMotionEventData");
2639 RNA_def_property_pointer_funcs(prop, "rna_Event_ndof_motion_get", nullptr, nullptr, nullptr);
2640 RNA_def_property_ui_text(prop, "NDOF motion", "NDOF motion event data");
2641
2642 /* xr */
2643 prop = RNA_def_property(srna, "xr", PROP_POINTER, PROP_NONE);
2644 RNA_def_property_struct_type(prop, "XrEventData");
2646 RNA_def_property_pointer_funcs(prop, "rna_Event_xr_get", nullptr, nullptr, nullptr);
2647 RNA_def_property_ui_text(prop, "XR", "XR event data");
2648
2649 /* modifiers */
2650 prop = RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
2651 RNA_def_property_boolean_sdna(prop, nullptr, "modifier", KM_SHIFT);
2653 RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
2655
2656 prop = RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
2657 RNA_def_property_boolean_sdna(prop, nullptr, "modifier", KM_CTRL);
2659 RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
2660
2661 prop = RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
2662 RNA_def_property_boolean_sdna(prop, nullptr, "modifier", KM_ALT);
2664 RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
2665
2666 prop = RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
2667 RNA_def_property_boolean_sdna(prop, nullptr, "modifier", KM_OSKEY);
2669 RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held");
2670
2671 prop = RNA_def_property(srna, "hyper", PROP_BOOLEAN, PROP_NONE);
2672 RNA_def_property_boolean_sdna(prop, nullptr, "modifier", KM_HYPER);
2674 RNA_def_property_ui_text(prop, "Hyper", "True when the Hyper key is held");
2675
2676 RNA_define_verify_sdna(true); /* not in sdna */
2677}
2678
2679static void rna_def_timer(BlenderRNA *brna)
2680{
2681 StructRNA *srna;
2682 PropertyRNA *prop;
2683
2684 srna = RNA_def_struct(brna, "Timer", nullptr);
2685 RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
2686 RNA_def_struct_sdna(srna, "wmTimer");
2687
2688 RNA_define_verify_sdna(false); /* not in sdna */
2689
2690 /* could wrap more, for now this is enough */
2691 prop = RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
2692 RNA_def_property_float_sdna(prop, nullptr, "time_step");
2694 RNA_def_property_ui_text(prop, "Time Step", "");
2695
2696 prop = RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
2697 RNA_def_property_float_sdna(prop, nullptr, "time_delta");
2699 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
2700
2701 prop = RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
2702 RNA_def_property_float_sdna(prop, nullptr, "time_duration");
2704 RNA_def_property_ui_text(prop, "Delta", "Time since the timer started seconds");
2705
2706 RNA_define_verify_sdna(true); /* not in sdna */
2707}
2708
2710 const char *rna_type,
2711 const char *c_type,
2712 const char *layout_get_fn)
2713{
2714 StructRNA *srna;
2715 PropertyRNA *prop;
2716
2717 srna = RNA_def_struct(brna, rna_type, nullptr);
2718 /* UI name isn't visible, name same as type. */
2719 RNA_def_struct_ui_text(srna, rna_type, "");
2720 RNA_def_struct_sdna(srna, c_type);
2721
2722 RNA_define_verify_sdna(false); /* not in sdna */
2723
2724 /* could wrap more, for now this is enough */
2725 prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
2726 RNA_def_property_struct_type(prop, "UILayout");
2727 RNA_def_property_pointer_funcs(prop, layout_get_fn, nullptr, nullptr, nullptr);
2728
2729 RNA_define_verify_sdna(true); /* not in sdna */
2730}
2731
2733{
2734 rna_def_popup_menu_wrapper(brna, "UIPopupMenu", "ui::PopupMenu", "rna_PopupMenu_layout_get");
2735}
2736
2738{
2739 rna_def_popup_menu_wrapper(brna, "UIPopover", "ui::Popover", "rna_PopoverMenu_layout_get");
2740}
2741
2742static void rna_def_piemenu(BlenderRNA *brna)
2743{
2744 rna_def_popup_menu_wrapper(brna, "UIPieMenu", "ui::PieMenu", "rna_PieMenu_layout_get");
2745}
2746
2748{
2749 StructRNA *srna;
2750 PropertyRNA *prop;
2751
2752 srna = RNA_def_struct(brna, "Stereo3dDisplay", nullptr);
2753 RNA_def_struct_sdna(srna, "Stereo3dFormat");
2754 RNA_def_struct_ui_text(srna, "Stereo 3D Display", "Settings for stereo 3D display");
2755
2756 prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE);
2758 RNA_def_property_ui_text(prop, "Display Mode", "");
2759
2760 prop = RNA_def_property(srna, "anaglyph_type", PROP_ENUM, PROP_NONE);
2762 RNA_def_property_ui_text(prop, "Anaglyph Type", "");
2763
2764 prop = RNA_def_property(srna, "interlace_type", PROP_ENUM, PROP_NONE);
2766 RNA_def_property_ui_text(prop, "Interlace Type", "");
2767
2768 prop = RNA_def_property(srna, "use_interlace_swap", PROP_BOOLEAN, PROP_BOOLEAN);
2769 RNA_def_property_boolean_sdna(prop, nullptr, "flag", S3D_INTERLACE_SWAP);
2770 RNA_def_property_ui_text(prop, "Swap Left/Right", "Swap left and right stereo channels");
2771
2772 prop = RNA_def_property(srna, "use_sidebyside_crosseyed", PROP_BOOLEAN, PROP_BOOLEAN);
2774 RNA_def_property_ui_text(prop, "Cross-Eyed", "Right eye should see left image and vice versa");
2775}
2776
2777static void rna_def_window(BlenderRNA *brna)
2778{
2779 StructRNA *srna;
2780 PropertyRNA *prop;
2781
2782 srna = RNA_def_struct(brna, "Window", nullptr);
2783 RNA_def_struct_ui_text(srna, "Window", "Open window");
2784 RNA_def_struct_sdna(srna, "wmWindow");
2785
2786 prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
2787 RNA_def_property_ui_text(prop, "Parent Window", "Active workspace and scene follow this window");
2788
2790
2791 prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
2793 RNA_def_property_pointer_funcs(prop, nullptr, "rna_Window_scene_set", nullptr, nullptr);
2794 RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the window");
2796 RNA_def_property_update(prop, 0, "rna_Window_scene_update");
2797
2798 prop = RNA_def_property(srna, "global_areas", PROP_COLLECTION, PROP_NONE);
2799 RNA_def_property_collection_sdna(prop, nullptr, "global_areas.areabase", nullptr);
2800 RNA_def_property_struct_type(prop, "Area");
2802 "Areas",
2803 "Areas at the edges of the window that are not part of the flexible "
2804 "screen layout (such as top and status bar)");
2805
2806 prop = RNA_def_property(srna, "workspace", PROP_POINTER, PROP_NONE);
2808 RNA_def_property_struct_type(prop, "WorkSpace");
2809 RNA_def_property_ui_text(prop, "Workspace", "Active workspace showing in the window");
2811 prop, "rna_Window_workspace_get", "rna_Window_workspace_set", nullptr, nullptr);
2813 RNA_def_property_update(prop, 0, "rna_Window_workspace_update");
2814
2815 prop = RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
2816 RNA_def_property_struct_type(prop, "Screen");
2817 RNA_def_property_ui_text(prop, "Screen", "Active workspace screen showing in the window");
2819 "rna_Window_screen_get",
2820 "rna_Window_screen_set",
2821 nullptr,
2822 "rna_Window_screen_assign_poll");
2825 RNA_def_property_update(prop, 0, "rna_workspace_screen_update");
2826
2827 prop = RNA_def_property(srna, "view_layer", PROP_POINTER, PROP_NONE);
2828 RNA_def_property_struct_type(prop, "ViewLayer");
2830 prop, "rna_Window_view_layer_get", "rna_Window_view_layer_set", nullptr, nullptr);
2832 prop, "Active View Layer", "The active workspace view layer showing in the window");
2834 RNA_def_property_update(prop, NC_SCREEN | ND_LAYER, nullptr);
2835
2836 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
2837 RNA_def_property_int_sdna(prop, nullptr, "posx");
2839 RNA_def_property_ui_text(prop, "X Position", "Horizontal location of the window");
2840
2841 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
2842 RNA_def_property_int_sdna(prop, nullptr, "posy");
2844 RNA_def_property_ui_text(prop, "Y Position", "Vertical location of the window");
2845
2846 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
2847 RNA_def_property_int_sdna(prop, nullptr, "sizex");
2849 RNA_def_property_ui_text(prop, "Width", "Window width");
2850
2851 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
2852 RNA_def_property_int_sdna(prop, nullptr, "sizey");
2854 RNA_def_property_ui_text(prop, "Height", "Window height");
2855
2856 prop = RNA_def_property(srna, "stereo_3d_display", PROP_POINTER, PROP_NONE);
2857 RNA_def_property_pointer_sdna(prop, nullptr, "stereo3d_format");
2859 RNA_def_property_struct_type(prop, "Stereo3dDisplay");
2860 RNA_def_property_ui_text(prop, "Stereo 3D Display", "Settings for stereo 3D display");
2861
2862 prop = RNA_def_property(srna, "support_hdr_color", PROP_BOOLEAN, PROP_NONE);
2865 "Support HDR Color",
2866 "The window has a HDR graphics buffer that wide gamut and high dynamic "
2867 "range colors can be written to, in extended sRGB color space.");
2868 RNA_def_property_boolean_funcs(prop, "rna_Window_support_hdr_color_get", nullptr);
2869
2870 prop = RNA_def_property(srna, "modal_operators", PROP_COLLECTION, PROP_NONE);
2871 RNA_def_property_struct_type(prop, "Operator");
2874 "rna_Window_modal_operators_begin",
2875 "rna_iterator_listbase_next",
2876 "rna_iterator_listbase_end",
2877 "rna_Window_modal_operators_get",
2878 nullptr,
2879 nullptr,
2880 nullptr,
2881 nullptr);
2882 RNA_def_property_ui_text(prop, "Modal Operators", "A list of currently running modal operators");
2883
2884 RNA_api_window(srna);
2885}
2886
2887static void rna_def_windows(BlenderRNA *brna, PropertyRNA *cprop)
2888{
2889 StructRNA *srna;
2890
2891 RNA_def_property_srna(cprop, "Windows");
2892 srna = RNA_def_struct(brna, "Windows", nullptr);
2893 RNA_def_struct_sdna(srna, "wmWindowManager");
2894 RNA_def_struct_ui_text(srna, "Windows", "Collection of windows");
2895
2896 RNA_api_windows(srna);
2897}
2898
2899/* curve.splines */
2901{
2902 StructRNA *srna;
2903 PropertyRNA *prop;
2904
2905 RNA_def_property_srna(cprop, "KeyConfigurations");
2906 srna = RNA_def_struct(brna, "KeyConfigurations", nullptr);
2907 RNA_def_struct_sdna(srna, "wmWindowManager");
2908 RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs");
2909
2910 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2911 RNA_def_property_struct_type(prop, "KeyConfig");
2913 "rna_WindowManager_active_keyconfig_get",
2914 "rna_WindowManager_active_keyconfig_set",
2915 nullptr,
2916 nullptr);
2918 RNA_def_property_ui_text(prop, "Active KeyConfig", "Active key configuration (preset)");
2919
2920 prop = RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
2922 prop, "rna_WindowManager_default_keyconfig_get", nullptr, nullptr, nullptr);
2923 RNA_def_property_struct_type(prop, "KeyConfig");
2924 RNA_def_property_ui_text(prop, "Default Key Configuration", "Default builtin key configuration");
2925
2926 prop = RNA_def_property(srna, "addon", PROP_POINTER, PROP_NEVER_NULL);
2927 RNA_def_property_struct_type(prop, "KeyConfig");
2929 prop, "rna_WindowManager_addon_keyconfig_get", nullptr, nullptr, nullptr);
2931 prop,
2932 "Add-on Key Configuration",
2933 "Key configuration that can be extended by add-ons, and is added to the active "
2934 "configuration when handling events");
2935
2936 prop = RNA_def_property(srna, "user", PROP_POINTER, PROP_NEVER_NULL);
2937 RNA_def_property_struct_type(prop, "KeyConfig");
2939 prop, "rna_WindowManager_user_keyconfig_get", nullptr, nullptr, nullptr);
2941 prop,
2942 "User Key Configuration",
2943 "Final key configuration that combines keymaps from the active and add-on configurations, "
2944 "and can be edited by the user");
2945
2946 RNA_api_keyconfigs(srna);
2947}
2948
2949static void rna_def_report(BlenderRNA *brna)
2950{
2951 StructRNA *srna;
2952 PropertyRNA *prop;
2953
2954 srna = RNA_def_struct(brna, "Report", nullptr);
2955 RNA_def_struct_sdna(srna, "Report");
2956 RNA_def_struct_ui_text(srna, "Report", "Report entry");
2957
2958 prop = RNA_def_property(srna, "session_uid", PROP_INT, PROP_NONE);
2960 RNA_def_property_int_funcs(prop, "rna_Report_session_uid_get", nullptr, nullptr);
2961 RNA_def_property_ui_text(prop, "Session UID", "Unique per-session report identifier");
2962
2963 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2966 RNA_def_property_enum_funcs(prop, "rna_Report_type_get", nullptr, nullptr);
2967 RNA_def_property_ui_text(prop, "Type", "Report type (severity)");
2968
2969 prop = RNA_def_property(srna, "message", PROP_STRING, PROP_NONE);
2972 prop, "rna_Report_message_get", "rna_Report_message_length", nullptr);
2973 RNA_def_property_ui_text(prop, "Message", "Report message text");
2974}
2975
2977{
2978 StructRNA *srna;
2979 PropertyRNA *prop;
2980
2981 srna = RNA_def_struct(brna, "WindowManager", "ID");
2983 srna,
2984 "Window Manager",
2985 "Window manager data-block defining open windows and other user interface data");
2987 RNA_def_struct_sdna(srna, "wmWindowManager");
2988
2989 prop = RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
2990 RNA_def_property_struct_type(prop, "Operator");
2992 "rna_WindowManager_operators_begin",
2993 "rna_iterator_listbase_next",
2994 "rna_iterator_listbase_end",
2995 "rna_iterator_listbase_get",
2996 nullptr,
2997 nullptr,
2998 nullptr,
2999 nullptr);
3000 RNA_def_property_ui_text(prop, "Operators", "Operator registry");
3001
3002 prop = RNA_def_property(srna, "reports", PROP_COLLECTION, PROP_NONE);
3003 RNA_def_property_struct_type(prop, "Report");
3005 "rna_WindowManager_reports_begin",
3006 "rna_iterator_listbase_next",
3007 "rna_iterator_listbase_end",
3008 "rna_iterator_listbase_get",
3009 nullptr,
3010 nullptr,
3011 nullptr,
3012 nullptr);
3013 RNA_def_property_ui_text(prop, "Reports", "Collection of reports");
3014
3015 prop = RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
3016 RNA_def_property_struct_type(prop, "Window");
3017 RNA_def_property_ui_text(prop, "Windows", "Open windows");
3018 rna_def_windows(brna, prop);
3019
3020 prop = RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
3021 RNA_def_property_struct_type(prop, "KeyConfig");
3023 "rna_WindowManager_keyconfigs_begin",
3024 "rna_iterator_listbase_next",
3025 "rna_iterator_listbase_end",
3026 "rna_iterator_listbase_get",
3027 nullptr,
3028 nullptr,
3029 nullptr,
3030 nullptr);
3031 RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations");
3032 rna_def_wm_keyconfigs(brna, prop);
3033
3034 prop = RNA_def_property(srna, "undo_stack", PROP_POINTER, PROP_NONE);
3035 RNA_def_property_struct_type(prop, "UndoStack");
3037 RNA_def_property_ui_text(prop, "Undo Stack", "Read-only access to the undo stack");
3039 prop, "rna_WindowManager_undo_stack_get", nullptr, nullptr, nullptr);
3040
3041 prop = RNA_def_property(srna, "xr_session_settings", PROP_POINTER, PROP_NONE);
3042 RNA_def_property_pointer_sdna(prop, nullptr, "xr.session_settings");
3044 RNA_def_property_ui_text(prop, "XR Session Settings", "");
3045
3046 prop = RNA_def_property(srna, "xr_session_state", PROP_POINTER, PROP_NONE);
3047 RNA_def_property_struct_type(prop, "XrSessionState");
3049 prop, "rna_WindowManager_xr_session_state_get", nullptr, nullptr, nullptr);
3052 prop, "XR Session State", "Runtime state information about the VR session");
3053
3054 prop = RNA_def_property(srna, "extensions_updates", PROP_INT, PROP_NONE);
3056 prop, "Extensions Updates", "Number of extensions with available update");
3057 RNA_def_property_update(prop, 0, "rna_WindowManager_extensions_statusbar_update");
3058
3059 prop = RNA_def_property(srna, "extensions_blocked", PROP_INT, PROP_NONE);
3061 prop, "Extensions Blocked", "Number of installed extensions which are blocked");
3062 RNA_def_property_update(prop, 0, "rna_WindowManager_extensions_statusbar_update");
3063
3064 prop = RNA_def_property(srna, "is_event_handling_break", PROP_BOOLEAN, PROP_NONE);
3066 RNA_def_property_boolean_funcs(prop, "rna_WindowManager_is_event_handling_break_get", nullptr);
3068 prop,
3069 "Event Handling Break",
3070 "Remaining events in the queue are delayed until the next main loop iteration");
3071
3072 RNA_api_wm(srna);
3074}
3075
3076/* keyconfig.items */
3078{
3079 StructRNA *srna;
3080
3081 RNA_def_property_srna(cprop, "KeyMapItems");
3082 srna = RNA_def_struct(brna, "KeyMapItems", nullptr);
3083 RNA_def_struct_sdna(srna, "wmKeyMap");
3084 RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
3085
3086 RNA_api_keymapitems(srna);
3087}
3088
3090{
3091 StructRNA *srna;
3092
3093 RNA_def_property_srna(cprop, "KeyMaps");
3094 srna = RNA_def_struct(brna, "KeyMaps", nullptr);
3095 RNA_def_struct_sdna(srna, "wmKeyConfig");
3096 RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
3097
3098 RNA_api_keymaps(srna);
3099}
3100
3102{
3103 StructRNA *srna;
3104 PropertyRNA *prop;
3105
3106 srna = RNA_def_struct(brna, "KeyConfigPreferences", nullptr);
3107 RNA_def_struct_ui_text(srna, "Key-Config Preferences", "");
3108 RNA_def_struct_sdna(srna, "wmKeyConfigPref"); /* WARNING: only a bAddon during registration */
3109
3110 RNA_def_struct_refine_func(srna, "rna_wmKeyConfigPref_refine");
3112 srna, "rna_wmKeyConfigPref_register", "rna_wmKeyConfigPref_unregister", nullptr);
3113 RNA_def_struct_system_idprops_func(srna, "rna_wmKeyConfigPref_idprops");
3115
3116 /* registration */
3118 prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
3119 RNA_def_property_string_sdna(prop, nullptr, "idname");
3122}
3123
3125{
3126 StructRNA *srna;
3127 PropertyRNA *prop;
3128
3129 static const EnumPropertyItem map_type_items[] = {
3130 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
3131 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
3132 {KMI_TYPE_NDOF, "NDOF", 0, "NDOF", ""},
3133 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
3134 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
3135 {0, nullptr, 0, nullptr, nullptr},
3136 };
3137
3138 /* KeyConfig */
3139 srna = RNA_def_struct(brna, "KeyConfig", nullptr);
3140 RNA_def_struct_sdna(srna, "wmKeyConfig");
3141 RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps");
3142
3143 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3144 RNA_def_property_string_sdna(prop, nullptr, "idname");
3145 RNA_def_property_ui_text(prop, "Name", "Name of the key configuration");
3146 RNA_def_struct_name_property(srna, prop);
3147
3148 prop = RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
3149 RNA_def_property_struct_type(prop, "KeyMap");
3150 RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration");
3151 rna_def_wm_keymaps(brna, prop);
3152
3153 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
3154 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KEYCONF_USER);
3157 prop, "User Defined", "Indicates that a keyconfig was defined by the user");
3158
3159 /* Collection active property */
3160 prop = RNA_def_property(srna, "preferences", PROP_POINTER, PROP_NONE);
3161 RNA_def_property_struct_type(prop, "KeyConfigPreferences");
3163 prop, "rna_wmKeyConfig_preferences_get", nullptr, nullptr, nullptr);
3164
3165 RNA_api_keyconfig(srna);
3166
3167 /* KeyMap */
3168 srna = RNA_def_struct(brna, "KeyMap", nullptr);
3169 RNA_def_struct_sdna(srna, "wmKeyMap");
3170 RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps");
3171
3172 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3173 RNA_def_property_string_sdna(prop, nullptr, "idname");
3175 RNA_def_property_ui_text(prop, "Name", "Name of the key map");
3176 RNA_def_struct_name_property(srna, prop);
3177
3178 prop = RNA_def_property(srna, "bl_owner_id", PROP_STRING, PROP_NONE);
3179 RNA_def_property_string_sdna(prop, nullptr, "owner_id");
3180 RNA_def_property_ui_text(prop, "Owner", "Internal owner");
3181
3182 prop = RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
3183 RNA_def_property_enum_sdna(prop, nullptr, "spaceid");
3186 RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with");
3187
3188 prop = RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
3189 RNA_def_property_enum_sdna(prop, nullptr, "regionid");
3192 RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with");
3193
3194 prop = RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE);
3195 RNA_def_property_collection_sdna(prop, nullptr, "items", nullptr);
3196 RNA_def_property_struct_type(prop, "KeyMapItem");
3198 prop, "Items", "Items in the keymap, linking an operator to an input event");
3199 rna_def_keymap_items(brna, prop);
3200
3201 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
3203 RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
3204
3205 prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
3206 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KEYMAP_MODAL);
3209 prop,
3210 "Modal Keymap",
3211 "Indicates that a keymap is used for translate modal events for an operator");
3212
3213 prop = RNA_def_property(srna, "show_expanded_items", PROP_BOOLEAN, PROP_NONE);
3214 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KEYMAP_EXPANDED);
3215 RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
3216 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
3217
3218 prop = RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
3220 RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
3221 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
3222
3223 prop = RNA_def_property(srna, "modal_event_values", PROP_COLLECTION, PROP_NONE);
3225 RNA_def_property_struct_type(prop, "EnumPropertyItem");
3227 "rna_KeyMap_modal_event_values_items_begin",
3228 "rna_iterator_array_next",
3229 "rna_iterator_array_end",
3230 "rna_iterator_array_get",
3231 nullptr,
3232 nullptr,
3233 nullptr,
3234 nullptr);
3236 "Modal Events",
3237 "Give access to the possible event values of this modal keymap's items "
3238 "(#KeyMapItem.propvalue), for API introspection");
3239
3240 RNA_api_keymap(srna);
3241
3242 /* KeyMapItem */
3243 srna = RNA_def_struct(brna, "KeyMapItem", nullptr);
3244 RNA_def_struct_sdna(srna, "wmKeyMapItem");
3245 RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map");
3246
3247 prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
3248 RNA_def_property_string_sdna(prop, nullptr, "idname");
3249 RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
3251 "rna_wmKeyMapItem_idname_get",
3252 "rna_wmKeyMapItem_idname_length",
3253 "rna_wmKeyMapItem_idname_set");
3255 "WM_operatortype_idname_visit_for_search",
3257 RNA_def_struct_name_property(srna, prop);
3258 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3259
3260 /* this is in fact the operator name, but if the operator can't be found we
3261 * fall back on the operator ID */
3262 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
3264 RNA_def_property_ui_text(prop, "Name", "Name of operator (translated) to call on input event");
3266 prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", nullptr);
3267
3268 prop = RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
3269 RNA_def_property_struct_type(prop, "OperatorProperties");
3270 RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", nullptr, nullptr, nullptr);
3271 RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
3272 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3273
3274 prop = RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
3275 RNA_def_property_enum_sdna(prop, nullptr, "maptype");
3276 RNA_def_property_enum_items(prop, map_type_items);
3278 prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", nullptr);
3279 RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
3280 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3281
3282 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
3283 RNA_def_property_enum_sdna(prop, nullptr, "type");
3286 RNA_def_property_enum_funcs(prop, nullptr, nullptr, "rna_KeyMapItem_type_itemf");
3287 RNA_def_property_ui_text(prop, "Type", "Type of event");
3288 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3289
3290 prop = RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
3291 RNA_def_property_enum_sdna(prop, nullptr, "val");
3293 RNA_def_property_ui_text(prop, "Value", "");
3294 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3296
3297 prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
3298 RNA_def_property_enum_sdna(prop, nullptr, "direction");
3300 RNA_def_property_ui_text(prop, "Direction", "The direction (only applies to drag events)");
3301 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3302
3303 prop = RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
3304 RNA_def_property_int_sdna(prop, nullptr, "id");
3306 RNA_def_property_ui_text(prop, "ID", "ID of the item");
3307 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3308
3309 prop = RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
3310 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_get", "rna_KeyMapItem_any_set");
3311 RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
3312 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3313
3314 prop = RNA_def_property(srna, "shift", PROP_INT, PROP_NONE);
3315 RNA_def_property_int_sdna(prop, nullptr, "shift");
3317 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed, -1 for any state");
3319 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3320
3321 prop = RNA_def_property(srna, "ctrl", PROP_INT, PROP_NONE);
3322 RNA_def_property_int_sdna(prop, nullptr, "ctrl");
3324 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed, -1 for any state");
3325 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3326
3327 prop = RNA_def_property(srna, "alt", PROP_INT, PROP_NONE);
3328 RNA_def_property_int_sdna(prop, nullptr, "alt");
3330 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed, -1 for any state");
3331 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3332
3333 prop = RNA_def_property(srna, "oskey", PROP_INT, PROP_NONE);
3334 RNA_def_property_int_sdna(prop, nullptr, "oskey");
3336 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed, -1 for any state");
3337 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3338
3339 prop = RNA_def_property(srna, "hyper", PROP_INT, PROP_NONE);
3340 RNA_def_property_int_sdna(prop, nullptr, "hyper");
3342 RNA_def_property_ui_text(prop, "Hyper", "Hyper key pressed, -1 for any state");
3343 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3344
3345 /* XXX(@ideasman42): the `*_ui` suffix is only for the UI, may be removed,
3346 * since this is only exposed so the UI can show these settings as toggle-buttons. */
3347 prop = RNA_def_property(srna, "shift_ui", PROP_BOOLEAN, PROP_NONE);
3348 RNA_def_property_boolean_sdna(prop, nullptr, "shift", 0);
3349 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_shift_get", nullptr);
3350 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
3351 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
3353 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3354
3355 prop = RNA_def_property(srna, "ctrl_ui", PROP_BOOLEAN, PROP_NONE);
3356 RNA_def_property_boolean_sdna(prop, nullptr, "ctrl", 0);
3357 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_ctrl_get", nullptr);
3358 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
3359 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
3360 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3361
3362 prop = RNA_def_property(srna, "alt_ui", PROP_BOOLEAN, PROP_NONE);
3363 RNA_def_property_boolean_sdna(prop, nullptr, "alt", 0);
3364 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_alt_get", nullptr);
3365 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
3366 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
3367 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3368
3369 prop = RNA_def_property(srna, "oskey_ui", PROP_BOOLEAN, PROP_NONE);
3370 RNA_def_property_boolean_sdna(prop, nullptr, "oskey", 0);
3371 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_oskey_get", nullptr);
3372 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
3373 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
3374 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3375
3376 prop = RNA_def_property(srna, "hyper_ui", PROP_BOOLEAN, PROP_NONE);
3377 RNA_def_property_boolean_sdna(prop, nullptr, "hyper", 0);
3378 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_hyper_get", nullptr);
3379 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
3381 prop,
3382 "Hyper",
3383 "Hyper key pressed. "
3384 /* Additional info since this is not so widely known. */
3385 "An additional modifier which can be configured on Linux, typically replacing CapsLock");
3386 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3387 /* End `_ui` modifiers. */
3388
3389 prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
3390 RNA_def_property_enum_sdna(prop, nullptr, "keymodifier");
3393 RNA_def_property_enum_funcs(prop, nullptr, "rna_wmKeyMapItem_keymodifier_set", nullptr);
3394 RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
3395 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3396
3397 prop = RNA_def_property(srna, "repeat", PROP_BOOLEAN, PROP_NONE);
3400 RNA_def_property_ui_text(prop, "Repeat", "Active on key-repeat events (when a key is held)");
3401 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3402
3403 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
3405 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KMI_EXPANDED);
3407 prop, "Expanded", "Show key map event and property details in the user interface");
3408 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
3409 /* Display only, no need to call `rna_KeyMapItem_update`. */
3410
3411 prop = RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
3412 RNA_def_property_enum_sdna(prop, nullptr, "propvalue");
3414 RNA_def_property_enum_funcs(prop, nullptr, nullptr, "rna_KeyMapItem_propvalue_itemf");
3416 prop, "Property Value", "The value this event translates to in a modal keymap");
3418 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3419
3420 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
3422 RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
3423 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
3424 RNA_def_property_update(prop, 0, "rna_KeyMapItem_update");
3425
3426 prop = RNA_def_property(srna, "is_user_modified", PROP_BOOLEAN, PROP_NONE);
3427 RNA_def_property_boolean_sdna(prop, nullptr, "flag", KMI_USER_MODIFIED);
3429 RNA_def_property_ui_text(prop, "User Modified", "Is this keymap item modified by the user");
3430
3431 prop = RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
3434 prop,
3435 "User Defined",
3436 "Is this keymap item user defined (does not just replace a builtin item)");
3437 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", nullptr);
3438
3439 RNA_api_keymapitem(srna);
3440}
3441
3443{
3444 rna_def_operator(brna);
3451 rna_def_event(brna);
3452 rna_def_timer(brna);
3453 rna_def_popupmenu(brna);
3454 rna_def_popovermenu(brna);
3455 rna_def_piemenu(brna);
3456 rna_def_window(brna);
3457 rna_def_report(brna);
3460 rna_def_keyconfig(brna);
3461}
3462
3463} // namespace blender
3464
3465#endif /* RNA_RUNTIME */
#define G_MAIN
#define BKE_ST_MAXNAME
Definition BKE_screen.hh:91
#define FILE_MAX
#define BLI_UTF8_ERR
#define BLI_STR_UTF8_LEFTWARDS_ARROW
#define BLI_STR_UTF8_UPWARDS_ARROW
#define BLI_STR_UTF8_DOWNWARDS_ARROW
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR
#define BLI_STR_UTF8_BLACK_SQUARE_FOR_STOP
#define BLI_STR_UTF8_RIGHTWARDS_ARROW
#define BLI_STR_UTF8_BLACK_LEFT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR
#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_TRIANGLE_WITH_DOUBLE_VERTICAL_BAR
#define BLT_I18NCONTEXT_ID_WINDOWMANAGER
#define CTX_N_(context, msgid)
#define BLT_I18NCONTEXT_ID_SCREEN
#define BLT_I18NCONTEXT_OPERATOR_DEFAULT
#define BLT_I18NCONTEXT_UI_EVENTS
#define BPy_BEGIN_ALLOW_THREADS
Definition BPY_extern.hh:52
#define BPy_END_ALLOW_THREADS
Definition BPY_extern.hh:56
ID and Library types, which are fundamental for SDNA.
#define OPERATOR_RETVAL_CHECK(ret)
#define OP_MAX_TYPENAME
Read Blender memory allocation and freeing.
#define RNA_DYN_DESCR_MAX
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:762
#define C
Definition RandGen.cpp:29
#define NC_WINDOW
Definition WM_types.hh:388
#define ND_SPACE_INFO
Definition WM_types.hh:564
#define NC_SCREEN
Definition WM_types.hh:390
#define NC_SCENE
Definition WM_types.hh:391
#define NA_EDITED
Definition WM_types.hh:634
#define ND_LAYER
Definition WM_types.hh:469
#define ND_WORKSPACE_SET
Definition WM_types.hh:445
#define ND_LAYOUTBROWSE
Definition WM_types.hh:439
#define ND_SCENEBROWSE
Definition WM_types.hh:451
#define NC_SPACE
Definition WM_types.hh:405
#define KM_MOD_HELD
Definition WM_types.hh:339
#define BLI_assert_unreachable()
#define UNUSED_VARS(...)
#define ARRAY_SET_ITEMS(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
#define offsetof(t, d)
#define str(s)
const int state
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
void free(Subdiv *subdiv)
Definition subdiv.cc:192
Layout * pie_menu_layout(PieMenu *pie)
Layout * popup_menu_layout(PopupMenu *pup)
Layout * popover_layout(Popover *pup)
void refresh_for_srna_unregister(Main *bmain, StructRNA *srna_to_unreg)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
void RNA_api_keymap(StructRNA *srna)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void WM_keymap_item_properties_reset(wmKeyMapItem *kmi, IDProperty *properties)
Definition wm_keymap.cc:210
UserDef U
Definition blender.cc:58
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void WM_window_set_active_scene(Main *bmain, bContext *C, wmWindow *win, Scene *scene)
float WM_event_tablet_data(const wmEvent *event, bool *r_pen_flip, float r_tilt[2])
bool WM_operator_py_idname_ok_or_report(ReportList *reports, const char *classname, const char *idname)
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
@ KM_DIRECTION_E
Definition WM_types.hh:349
@ KM_DIRECTION_N
Definition WM_types.hh:347
@ KM_DIRECTION_SW
Definition WM_types.hh:352
@ KM_DIRECTION_S
Definition WM_types.hh:351
@ KM_DIRECTION_SE
Definition WM_types.hh:350
@ KM_DIRECTION_NW
Definition WM_types.hh:354
@ KM_DIRECTION_NE
Definition WM_types.hh:348
@ KM_DIRECTION_W
Definition WM_types.hh:353
const EnumPropertyItem rna_enum_wm_job_type_items[]
Definition rna_wm.cc:216
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
static void rna_def_keyconfig_prefs(BlenderRNA *brna)
Definition rna_wm.cc:3101
char * STRNCPY(char(&dst)[N], const char *src)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
int(*)(PointerRNA *ptr, void *data, bool *have_function) StructValidateFunc
void WM_event_add_notifier_ex(wmWindowManager *wm, const wmWindow *win, uint type, void *reference)
@ RPT_ERROR_INVALID_INPUT
Definition BKE_report.hh:42
@ RPT_ERROR_INVALID_CONTEXT
Definition BKE_report.hh:43
@ RPT_OPERATOR
Definition BKE_report.hh:38
@ RPT_ERROR_OUT_OF_MEMORY
Definition BKE_report.hh:44
@ RPT_PROPERTY
Definition BKE_report.hh:39
@ RPT_WARNING
Definition BKE_report.hh:40
static void rna_def_window_stereo3d(BlenderRNA *brna)
Definition rna_wm.cc:2747
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
@ STRUCT_ID_REFCOUNT
@ STRUCT_PUBLIC_NAMESPACE_INHERIT
@ STRUCT_NO_IDPROPERTIES
@ STRUCT_NO_DATABLOCK_IDPROPERTIES
@ STRUCT_NO_CONTEXT_WITHOUT_OWNER_ID
static void rna_def_popupmenu(BlenderRNA *brna)
Definition rna_wm.cc:2732
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:91
MINLINE void copy_v3_v3(float r[3], const float a[3])
static void rna_def_operator_utils(BlenderRNA *brna)
Definition rna_wm.cc:2415
std::string WM_operatortype_name(wmOperatorType *ot, PointerRNA *properties)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
@ EVT_DATA_NDOF_MOTION
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
PointerRNA RNA_id_pointer_create(ID *id)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_struct_system_idprops_func(StructRNA *srna, const char *system_idproperties)
bool RNA_struct_available_or_report(ReportList *reports, const char *identifier)
const EnumPropertyItem rna_enum_event_value_items[]
Definition rna_wm.cc:488
@ WM_JOB_TYPE_RENDER
Definition WM_api.hh:2011
@ WM_JOB_TYPE_COMPOSITE
Definition WM_api.hh:2010
@ WM_JOB_TYPE_SHADER_COMPILATION
Definition WM_api.hh:2040
@ WM_JOB_TYPE_OBJECT_BAKE
Definition WM_api.hh:2018
@ WM_JOB_TYPE_RENDER_PREVIEW
Definition WM_api.hh:2012
@ STATUSBAR_SHOW_EXTENSIONS_UPDATES
void RNA_api_keyconfig(StructRNA *srna)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void * RNA_struct_blender_type_get(StructRNA *srna)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
static void rna_def_popovermenu(BlenderRNA *brna)
Definition rna_wm.cc:2737
void RNA_def_wm(BlenderRNA *brna)
Definition rna_wm.cc:3442
size_t WM_operator_bl_idname(char *dst, const char *src)
char WM_event_utf8_to_ascii(const wmEvent *event)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void WM_operatortype_append_ptr(void(*opfunc)(wmOperatorType *, void *), void *userdata)
void WM_operatortype_append_macro_ptr(void(*opfunc)(wmOperatorType *ot, void *userdata), void *userdata)
bScreen * BKE_workspace_active_screen_get(const WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:684
uint RNA_enum_items_count(const EnumPropertyItem *item)
const EnumPropertyItem rna_enum_event_type_mask_items[]
Definition rna_wm.cc:529
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
WorkSpace * BKE_workspace_active_get(WorkSpaceInstanceHook *hook) GETTER_ATTRS
Definition workspace.cc:633
void RNA_api_keymaps(StructRNA *srna)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
ParameterList * RNA_parameter_list_create(ParameterList *parms, PointerRNA *, FunctionRNA *func)
@ EVT_ACTIONZONE_FULLSCREEN
@ EVT_ACTIONZONE_REGION_QUAD
@ INBETWEEN_MOUSEMOVE
@ EVT_ACTIONZONE_REGION
Global G
Definition blender.cc:57
const EnumPropertyItem rna_enum_operator_return_items[]
Definition rna_wm.cc:595
const EnumPropertyItem rna_enum_event_direction_items[]
Definition rna_wm.cc:500
const EnumPropertyItem rna_enum_keymap_propvalue_items[]
Definition rna_wm.cc:523
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
bool WM_event_is_tablet(const wmEvent *event)
void RNA_api_keymapitems(StructRNA *srna)
@ WM_EVENT_IS_CONSECUTIVE
Definition WM_types.hh:752
@ WM_EVENT_IS_REPEAT
Definition WM_types.hh:744
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
bool WM_window_support_hdr_color(const wmWindow *win)
void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
void BPY_RNA_operator_macro_wrapper(wmOperatorType *ot, void *userdata)
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna)
Scene * WM_window_get_active_scene(const wmWindow *win)
const EnumPropertyItem rna_enum_window_cursor_items[]
Definition rna_wm_api.cc:36
@ PROP_STRING_SEARCH_SORT
Definition RNA_types.hh:876
@ PROP_STRING_SEARCH_SUGGESTION
Definition RNA_types.hh:883
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
@ PROP_COLLECTION
Definition RNA_types.hh:216
unsigned int unsigned int BLI_str_utf8_as_unicode_step_or_error(const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void void char * BLI_string_join_array_by_sep_char_with_tableN(char sep, char *table[], const char *strings[], uint strings_num) ATTR_NONNULL(2
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_wm.cc:3077
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
const EnumPropertyItem rna_enum_event_type_items[]
Definition rna_wm.cc:225
BMesh const char void * data
void WM_operatortype_remove_ptr(wmOperatorType *ot)
const EnumPropertyItem rna_enum_operator_property_tag_items[]
Definition rna_wm.cc:617
static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_wm.cc:3089
static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_wm.cc:2900
static const EnumPropertyItem rna_enum_ndof_motion_progress_items[]
Definition rna_wm.cc:516
wmWindowManager * CTX_wm_manager(const bContext *C)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
static void rna_def_operator_options_runtime(BlenderRNA *brna)
Definition rna_wm.cc:2194
static void rna_def_macro_operator(BlenderRNA *brna)
Definition rna_wm.cc:2366
const EnumPropertyItem rna_enum_stereo3d_display_items[]
Definition rna_scene.cc:527
static void rna_def_window(BlenderRNA *brna)
Definition rna_wm.cc:2777
void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname)
Definition wm_keymap.cc:386
@ S3D_SIDEBYSIDE_CROSSEYED
static void rna_def_windows(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_wm.cc:2887
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
@ EVT_TYPE_MASK_ACTIONZONE
@ EVT_TYPE_MASK_MOUSE_GESTURE
@ EVT_TYPE_MASK_KEYBOARD_MODIFIER
@ EVT_TYPE_MASK_KEYBOARD
@ EVT_TYPE_MASK_MOUSE_BUTTON
@ EVT_TYPE_MASK_MOUSE_WHEEL
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_def_struct_clear_flag(StructRNA *srna, StructFlag flag)
void WM_window_status_area_tag_redraw(wmWindow *win)
void RNA_def_struct_property_tags(StructRNA *srna, const EnumPropertyItem *prop_tag_defines)
static void rna_def_event_ndof_motion(BlenderRNA *brna)
Definition rna_wm.cc:2448
@ OP_PROP_TAG_ADVANCED
Definition WM_types.hh:277
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
int WM_keymap_item_map_type_get(const wmKeyMapItem *kmi)
Definition wm_keymap.cc:227
static void rna_def_operator(BlenderRNA *brna)
Definition rna_wm.cc:2319
const char int BLI_str_utf8_size_or_error(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_keyconfig_pref_type_remove(const struct wmKeyConfigPrefType_Runtime *kpt_rt)
void(*)(void *data) StructFreeFunc
void RNA_def_struct_register_funcs(StructRNA *srna, const char *reg, const char *unreg, const char *instance)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_api_operator(StructRNA *srna)
void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void **r_value)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties)
@ KM_TEXTINPUT
Definition WM_types.hh:317
static void rna_def_operator_common(StructRNA *srna)
Definition rna_wm.cc:2230
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:28
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_handlers_clear(wmWindowManager *wm, const Set< wmOperatorType * > &types)
Definition wm.cc:400
static void rna_def_operator_type_macro(BlenderRNA *brna)
Definition rna_wm.cc:2389
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static void rna_def_keyconfig(BlenderRNA *brna)
Definition rna_wm.cc:3124
void * rna_iterator_listbase_get(CollectionPropertyIterator *iter)
static void rna_def_event(BlenderRNA *brna)
Definition rna_wm.cc:2489
void RNA_def_struct_flag(StructRNA *srna, StructFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void RNA_api_window(StructRNA *srna)
const EnumPropertyItem rna_enum_stereo3d_interlace_type_items[]
Definition rna_scene.cc:566
void RNA_struct_blender_type_set(StructRNA *srna, void *blender_type)
void WM_operator_stack_clear(wmWindowManager *wm)
Definition wm.cc:375
Main * CTX_data_main(const bContext *C)
void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
void RNA_api_keymapitem(StructRNA *srna)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
const EnumPropertyItem rna_enum_stereo3d_anaglyph_type_items[]
Definition rna_scene.cc:559
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:477
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_ENUM_FLAG
Definition RNA_types.hh:474
@ PROP_IDPROPERTY
Definition RNA_types.hh:496
@ PROP_REGISTER_OPTIONAL
Definition RNA_types.hh:482
@ PROP_REGISTER
Definition RNA_types.hh:481
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:509
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_api_asset_library_loading_status(StructRNA *srna)
void BPY_RNA_operator_wrapper(wmOperatorType *ot, void *userdata)
void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, const void *value)
PointerRNA RNA_pointer_create_id_subdata(ID &id, StructRNA *type, void *data)
@ P_STARTING
Definition WM_types.hh:913
@ P_FINISHING
Definition WM_types.hh:917
@ P_IN_PROGRESS
Definition WM_types.hh:915
void RNA_api_wm(StructRNA *srna)
const EnumPropertyItem rna_enum_operator_type_flag_items[]
Definition rna_wm.cc:550
const EnumPropertyItem rna_enum_wm_report_items[]
Definition rna_wm.cc:627
@ KM_NOTHING
Definition WM_types.hh:323
@ KM_PRESS_DRAG
Definition WM_types.hh:332
@ KM_DBL_CLICK
Definition WM_types.hh:327
@ KM_RELEASE
Definition WM_types.hh:325
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
static void rna_def_report(BlenderRNA *brna)
Definition rna_wm.cc:2949
struct wmKeyConfigPref * BKE_keyconfig_pref_ensure(struct UserDef *userdef, const char *kc_idname)
Definition keyconfig.cc:36
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_define_verify_sdna(bool verify)
@ OPTYPE_MODAL_PRIORITY
Definition WM_types.hh:231
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_UNDO_GROUPED
Definition WM_types.hh:215
@ OPTYPE_GRAB_CURSOR_Y
Definition WM_types.hh:200
@ OPTYPE_BLOCKING
Definition WM_types.hh:192
@ OPTYPE_PRESET
Definition WM_types.hh:203
@ OPTYPE_MACRO
Definition WM_types.hh:193
@ OPTYPE_GRAB_CURSOR_XY
Definition WM_types.hh:196
@ OPTYPE_DEPENDS_ON_CURSOR
Definition WM_types.hh:228
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
@ OPTYPE_GRAB_CURSOR_X
Definition WM_types.hh:198
wmXrSessionState * WM_xr_session_state_handle_get(const wmXrData *xr)
@ PROP_XYZ_LENGTH
Definition RNA_types.hh:327
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_FILENAME
Definition RNA_types.hh:286
@ PROP_UNSIGNED
Definition RNA_types.hh:306
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, ListBase *lb, IteratorSkipFunc skip)
void WM_keyconfig_update_tag(wmKeyMap *keymap, wmKeyMapItem *kmi)
void RNA_api_windows(StructRNA *srna)
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *rna_ext)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop, const bool allow_replace)
static void rna_def_windowmanager(BlenderRNA *brna)
Definition rna_wm.cc:2976
size_t WM_operator_py_idname(char *dst, const char *src)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_api_macro(StructRNA *srna)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_api_keyconfigs(StructRNA *srna)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr, void *data, size_t itemsize, int64_t length, bool free_ptr, IteratorSkipFunc skip)
WorkSpaceLayout * BKE_workspace_layout_find(const WorkSpace *workspace, const bScreen *screen) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition workspace.cc:499
int(*)(bContext *C, PointerRNA *ptr, FunctionRNA *func, ParameterList *list) StructCallbackFunc
void BKE_keyconfig_pref_type_add(struct wmKeyConfigPrefType_Runtime *kpt_rt)
Definition keyconfig.cc:86
void WM_event_remove_modal_handler_all(const wmOperator *op, const bool postpone)
static void rna_def_timer(BlenderRNA *brna)
Definition rna_wm.cc:2679
void RNA_def_property_string_search_func(PropertyRNA *prop, const char *search, const eStringPropertySearchFlag search_flag)
bool WM_window_is_temp_screen(const wmWindow *win)
struct wmKeyConfigPrefType_Runtime * BKE_keyconfig_pref_type_find(const char *idname, bool quiet)
Definition keyconfig.cc:62
void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
void RNA_parameter_list_free(ParameterList *parms)
static void rna_def_popup_menu_wrapper(BlenderRNA *brna, const char *rna_type, const char *c_type, const char *layout_get_fn)
Definition rna_wm.cc:2709
BlenderRNA RNA_blender_rna_get()
static void rna_def_piemenu(BlenderRNA *brna)
Definition rna_wm.cc:2742
static void rna_def_operator_filelist_element(BlenderRNA *brna)
Definition rna_wm.cc:2434
StructRNA * RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom)
eWM_EventHandlerType type
struct wmOperatorType * type
struct WorkSpaceInstanceHook * workspace_hook
#define ISKEYMODIFIER(event_type)
#define ISKEYBOARD(event_type)