4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2008).
22 * ***** END GPL LICENSE BLOCK *****
25 /** \file blender/makesrna/intern/rna_wm.c
32 #include "RNA_access.h"
33 #include "RNA_define.h"
34 #include "RNA_enum_types.h"
36 #include "rna_internal.h"
38 #include "DNA_screen_types.h"
39 #include "DNA_space_types.h"
40 #include "DNA_userdef_types.h"
41 #include "DNA_windowmanager_types.h"
45 EnumPropertyItem event_keymouse_value_items[] = {
46 {KM_ANY, "ANY", 0, "Any", ""},
47 {KM_PRESS, "PRESS", 0, "Press", ""},
48 {KM_RELEASE, "RELEASE", 0, "Release", ""},
49 {KM_CLICK, "CLICK", 0, "Click", ""},
50 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
51 {0, NULL, 0, NULL, NULL}};
53 EnumPropertyItem event_tweak_value_items[]= {
54 {KM_ANY, "ANY", 0, "Any", ""},
55 {EVT_GESTURE_N, "NORTH", 0, "North", ""},
56 {EVT_GESTURE_NE, "NORTH_EAST", 0, "North-East", ""},
57 {EVT_GESTURE_E, "EAST", 0, "East", ""},
58 {EVT_GESTURE_SE, "SOUTH_EAST", 0, "South-East", ""},
59 {EVT_GESTURE_S, "SOUTH", 0, "South", ""},
60 {EVT_GESTURE_SW, "SOUTH_WEST", 0, "South-West", ""},
61 {EVT_GESTURE_W, "WEST", 0, "West", ""},
62 {EVT_GESTURE_NW, "NORTH_WEST", 0, "North-West", ""},
63 {0, NULL, 0, NULL, NULL}};
65 EnumPropertyItem event_value_items[] = {
66 {KM_ANY, "ANY", 0, "Any", ""},
67 {KM_NOTHING, "NOTHING", 0, "Nothing", ""},
68 {KM_PRESS, "PRESS", 0, "Press", ""},
69 {KM_RELEASE, "RELEASE", 0, "Release", ""},
70 {KM_CLICK, "CLICK", 0, "Click", ""},
71 {KM_DBL_CLICK, "DOUBLE_CLICK", 0, "Double Click", ""},
72 {0, NULL, 0, NULL, NULL}};
74 EnumPropertyItem event_tweak_type_items[]= {
75 {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Left", ""},
76 {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Middle", ""},
77 {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Right", ""},
78 {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Action", ""},
79 {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Select", ""},
80 {0, NULL, 0, NULL, NULL}};
82 EnumPropertyItem event_mouse_type_items[]= {
83 {LEFTMOUSE, "LEFTMOUSE", 0, "Left", ""},
84 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle", ""},
85 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right", ""},
86 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4", ""},
87 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5", ""},
88 {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action", ""},
89 {SELECTMOUSE, "SELECTMOUSE", 0, "Select", ""},
90 {0, "", 0, NULL, NULL},
91 {MOUSEMOVE, "MOUSEMOVE", 0, "Move", ""},
92 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""},
93 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""},
94 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""},
95 {0, "", 0, NULL, NULL},
96 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
97 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
98 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
99 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
100 {0, NULL, 0, NULL, NULL}};
102 EnumPropertyItem event_timer_type_items[]= {
103 {TIMER, "TIMER", 0, "Timer", ""},
104 {TIMER0, "TIMER0", 0, "Timer 0", ""},
105 {TIMER1, "TIMER1", 0, "Timer 1", ""},
106 {TIMER2, "TIMER2", 0, "Timer 2", ""},
107 {0, NULL, 0, NULL, NULL}};
109 /* not returned: CAPSLOCKKEY, UNKNOWNKEY */
110 EnumPropertyItem event_type_items[] = {
112 {0, "NONE", 0, "", ""},
113 {LEFTMOUSE, "LEFTMOUSE", 0, "Left Mouse", ""},
114 {MIDDLEMOUSE, "MIDDLEMOUSE", 0, "Middle Mouse", ""},
115 {RIGHTMOUSE, "RIGHTMOUSE", 0, "Right Mouse", ""},
116 {BUTTON4MOUSE, "BUTTON4MOUSE", 0, "Button4 Mouse", ""},
117 {BUTTON5MOUSE, "BUTTON5MOUSE", 0, "Button5 Mouse", ""},
118 {ACTIONMOUSE, "ACTIONMOUSE", 0, "Action Mouse", ""},
119 {SELECTMOUSE, "SELECTMOUSE", 0, "Select Mouse", ""},
120 {0, "", 0, NULL, NULL},
121 {MOUSEMOVE, "MOUSEMOVE", 0, "Mouse Move", ""},
122 {INBETWEEN_MOUSEMOVE, "INBETWEEN_MOUSEMOVE", 0, "Inbetween Move", ""},
123 {MOUSEPAN, "TRACKPADPAN", 0, "Mouse/Trackpad Pan", ""},
124 {MOUSEZOOM, "TRACKPADZOOM", 0, "Mouse/Trackpad Zoom", ""},
125 {MOUSEROTATE, "MOUSEROTATE", 0, "Mouse/Trackpad Rotate", ""},
126 {0, "", 0, NULL, NULL},
127 {WHEELUPMOUSE, "WHEELUPMOUSE", 0, "Wheel Up", ""},
128 {WHEELDOWNMOUSE, "WHEELDOWNMOUSE", 0, "Wheel Down", ""},
129 {WHEELINMOUSE, "WHEELINMOUSE", 0, "Wheel In", ""},
130 {WHEELOUTMOUSE, "WHEELOUTMOUSE", 0, "Wheel Out", ""},
131 {0, "", 0, NULL, NULL},
132 {EVT_TWEAK_L, "EVT_TWEAK_L", 0, "Tweak Left", ""},
133 {EVT_TWEAK_M, "EVT_TWEAK_M", 0, "Tweak Middle", ""},
134 {EVT_TWEAK_R, "EVT_TWEAK_R", 0, "Tweak Right", ""},
135 {EVT_TWEAK_A, "EVT_TWEAK_A", 0, "Tweak Action", ""},
136 {EVT_TWEAK_S, "EVT_TWEAK_S", 0, "Tweak Select", ""},
137 {0, "", 0, NULL, NULL},
138 {AKEY, "A", 0, "A", ""},
139 {BKEY, "B", 0, "B", ""},
140 {CKEY, "C", 0, "C", ""},
141 {DKEY, "D", 0, "D", ""},
142 {EKEY, "E", 0, "E", ""},
143 {FKEY, "F", 0, "F", ""},
144 {GKEY, "G", 0, "G", ""},
145 {HKEY, "H", 0, "H", ""},
146 {IKEY, "I", 0, "I", ""},
147 {JKEY, "J", 0, "J", ""},
148 {KKEY, "K", 0, "K", ""},
149 {LKEY, "L", 0, "L", ""},
150 {MKEY, "M", 0, "M", ""},
151 {NKEY, "N", 0, "N", ""},
152 {OKEY, "O", 0, "O", ""},
153 {PKEY, "P", 0, "P", ""},
154 {QKEY, "Q", 0, "Q", ""},
155 {RKEY, "R", 0, "R", ""},
156 {SKEY, "S", 0, "S", ""},
157 {TKEY, "T", 0, "T", ""},
158 {UKEY, "U", 0, "U", ""},
159 {VKEY, "V", 0, "V", ""},
160 {WKEY, "W", 0, "W", ""},
161 {XKEY, "X", 0, "X", ""},
162 {YKEY, "Y", 0, "Y", ""},
163 {ZKEY, "Z", 0, "Z", ""},
164 {0, "", 0, NULL, NULL},
165 {ZEROKEY, "ZERO", 0, "0", ""},
166 {ONEKEY, "ONE", 0, "1", ""},
167 {TWOKEY, "TWO", 0, "2", ""},
168 {THREEKEY, "THREE", 0, "3", ""},
169 {FOURKEY, "FOUR", 0, "4", ""},
170 {FIVEKEY, "FIVE", 0, "5", ""},
171 {SIXKEY, "SIX", 0, "6", ""},
172 {SEVENKEY, "SEVEN", 0, "7", ""},
173 {EIGHTKEY, "EIGHT", 0, "8", ""},
174 {NINEKEY, "NINE", 0, "9", ""},
175 {0, "", 0, NULL, NULL},
176 {LEFTCTRLKEY, "LEFT_CTRL", 0, "Left Ctrl", ""},
177 {LEFTALTKEY, "LEFT_ALT", 0, "Left Alt", ""},
178 {LEFTSHIFTKEY, "LEFT_SHIFT", 0, "Left Shift", ""},
179 {RIGHTALTKEY, "RIGHT_ALT", 0, "Right Alt", ""},
180 {RIGHTCTRLKEY, "RIGHT_CTRL", 0, "Right Ctrl", ""},
181 {RIGHTSHIFTKEY, "RIGHT_SHIFT", 0, "Right Shift", ""},
182 {0, "", 0, NULL, NULL},
183 {OSKEY, "OSKEY", 0, "OS Key", ""},
184 {GRLESSKEY, "GRLESS", 0, "Grless", ""},
185 {ESCKEY, "ESC", 0, "Esc", ""},
186 {TABKEY, "TAB", 0, "Tab", ""},
187 {RETKEY, "RET", 0, "Return", ""},
188 {SPACEKEY, "SPACE", 0, "Spacebar", ""},
189 {LINEFEEDKEY, "LINE_FEED", 0, "Line Feed", ""},
190 {BACKSPACEKEY, "BACK_SPACE", 0, "Back Space", ""},
191 {DELKEY, "DEL", 0, "Delete", ""},
192 {SEMICOLONKEY, "SEMI_COLON", 0, ";", ""},
193 {PERIODKEY, "PERIOD", 0, ".", ""},
194 {COMMAKEY, "COMMA", 0, ",", ""},
195 {QUOTEKEY, "QUOTE", 0, "\"", ""},
196 {ACCENTGRAVEKEY, "ACCENT_GRAVE", 0, "`", ""},
197 {MINUSKEY, "MINUS", 0, "-", ""},
198 {SLASHKEY, "SLASH", 0, "/", ""},
199 {BACKSLASHKEY, "BACK_SLASH", 0, "\\", ""},
200 {EQUALKEY, "EQUAL", 0, "=", ""},
201 {LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""},
202 {RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""},
203 {LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", ""},
204 {DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", ""},
205 {RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", ""},
206 {UPARROWKEY, "UP_ARROW", 0, "Up Arrow", ""},
207 {PAD2, "NUMPAD_2", 0, "Numpad 2", ""},
208 {PAD4, "NUMPAD_4", 0, "Numpad 4", ""},
209 {PAD6, "NUMPAD_6", 0, "Numpad 6", ""},
210 {PAD8, "NUMPAD_8", 0, "Numpad 8", ""},
211 {PAD1, "NUMPAD_1", 0, "Numpad 1", ""},
212 {PAD3, "NUMPAD_3", 0, "Numpad 3", ""},
213 {PAD5, "NUMPAD_5", 0, "Numpad 5", ""},
214 {PAD7, "NUMPAD_7", 0, "Numpad 7", ""},
215 {PAD9, "NUMPAD_9", 0, "Numpad 9", ""},
216 {PADPERIOD, "NUMPAD_PERIOD", 0, "Numpad .", ""},
217 {PADSLASHKEY, "NUMPAD_SLASH", 0, "Numpad /", ""},
218 {PADASTERKEY, "NUMPAD_ASTERIX", 0, "Numpad *", ""},
219 {PAD0, "NUMPAD_0", 0, "Numpad 0", ""},
220 {PADMINUS, "NUMPAD_MINUS", 0, "Numpad -", ""},
221 {PADENTER, "NUMPAD_ENTER", 0, "Numpad Enter", ""},
222 {PADPLUSKEY, "NUMPAD_PLUS", 0, "Numpad +", ""},
223 {F1KEY, "F1", 0, "F1", ""},
224 {F2KEY, "F2", 0, "F2", ""},
225 {F3KEY, "F3", 0, "F3", ""},
226 {F4KEY, "F4", 0, "F4", ""},
227 {F5KEY, "F5", 0, "F5", ""},
228 {F6KEY, "F6", 0, "F6", ""},
229 {F7KEY, "F7", 0, "F7", ""},
230 {F8KEY, "F8", 0, "F8", ""},
231 {F9KEY, "F9", 0, "F9", ""},
232 {F10KEY, "F10", 0, "F10", ""},
233 {F11KEY, "F11", 0, "F11", ""},
234 {F12KEY, "F12", 0, "F12", ""},
235 {F13KEY, "F13", 0, "F13", ""},
236 {F14KEY, "F14", 0, "F14", ""},
237 {F15KEY, "F15", 0, "F15", ""},
238 {F16KEY, "F16", 0, "F16", ""},
239 {F17KEY, "F17", 0, "F17", ""},
240 {F18KEY, "F18", 0, "F18", ""},
241 {F19KEY, "F19", 0, "F19", ""},
242 {PAUSEKEY, "PAUSE", 0, "Pause", ""},
243 {INSERTKEY, "INSERT", 0, "Insert", ""},
244 {HOMEKEY, "HOME", 0, "Home", ""},
245 {PAGEUPKEY, "PAGE_UP", 0, "Page Up", ""},
246 {PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", ""},
247 {ENDKEY, "END", 0, "End", ""},
248 {0, "", 0, NULL, NULL},
249 {MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ""},
250 {MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", ""},
251 {MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", ""},
252 {MEDIALAST, "MEDIA_LAST", 0, "Media Last", ""},
253 {0, "", 0, NULL, NULL},
254 {WINDEACTIVATE, "WINDOW_DEACTIVATE", 0, "Window Deactivate", ""},
255 {TIMER, "TIMER", 0, "Timer", ""},
256 {TIMER0, "TIMER0", 0, "Timer 0", ""},
257 {TIMER1, "TIMER1", 0, "Timer 1", ""},
258 {TIMER2, "TIMER2", 0, "Timer 2", ""},
259 {0, NULL, 0, NULL, NULL}};
261 EnumPropertyItem keymap_propvalue_items[] = {
262 {0, "NONE", 0, "", ""},
263 {0, NULL, 0, NULL, NULL}};
265 EnumPropertyItem keymap_modifiers_items[] = {
266 {KM_ANY, "ANY", 0, "Any", ""},
267 {0, "NONE", 0, "None", ""},
268 {1, "FIRST", 0, "First", ""},
269 {2, "SECOND", 0, "Second", ""},
270 {0, NULL, 0, NULL, NULL}};
272 EnumPropertyItem operator_flag_items[] = {
273 {OPTYPE_REGISTER, "REGISTER", 0, "Register", ""},
274 {OPTYPE_UNDO, "UNDO", 0, "Undo", ""},
275 {OPTYPE_BLOCKING, "BLOCKING", 0, "Finished", ""},
276 {OPTYPE_MACRO, "MACRO", 0, "Macro", ""},
277 {OPTYPE_GRAB_POINTER, "GRAB_POINTER", 0, "Grab Pointer", ""},
278 {OPTYPE_PRESET, "PRESET", 0, "Preset", ""},
279 {0, NULL, 0, NULL, NULL}};
281 EnumPropertyItem operator_return_items[] = {
282 {OPERATOR_RUNNING_MODAL, "RUNNING_MODAL", 0, "Running Modal", ""},
283 {OPERATOR_CANCELLED, "CANCELLED", 0, "Cancelled", ""},
284 {OPERATOR_FINISHED, "FINISHED", 0, "Finished", ""},
285 {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", ""}, // used as a flag
286 {0, NULL, 0, NULL, NULL}};
289 EnumPropertyItem wm_report_items[] = {
290 {RPT_DEBUG, "DEBUG", 0, "Debug", ""},
291 {RPT_INFO, "INFO", 0, "Info", ""},
292 {RPT_OPERATOR, "OPERATOR", 0, "Operator", ""},
293 {RPT_WARNING, "WARNING", 0, "Warning", ""},
294 {RPT_ERROR, "ERROR", 0, "Error", ""},
295 {RPT_ERROR_INVALID_INPUT, "ERROR_INVALID_INPUT", 0, "Invalid Input", ""},\
296 {RPT_ERROR_INVALID_CONTEXT, "ERROR_INVALID_CONTEXT", 0, "Invalid Context", ""},
297 {RPT_ERROR_OUT_OF_MEMORY, "ERROR_OUT_OF_MEMORY", 0, "Out of Memory", ""},
298 {0, NULL, 0, NULL, NULL}};
300 #define KMI_TYPE_KEYBOARD 0
301 #define KMI_TYPE_MOUSE 1
302 #define KMI_TYPE_TWEAK 2
303 #define KMI_TYPE_TEXTINPUT 3
304 #define KMI_TYPE_TIMER 4
312 #include "BKE_idprop.h"
314 #include "MEM_guardedalloc.h"
316 static wmOperator *rna_OperatorProperties_find_operator(PointerRNA *ptr)
318 wmWindowManager *wm= ptr->id.data;
319 IDProperty *properties= (IDProperty*)ptr->data;
323 for(op=wm->operators.first; op; op=op->next)
324 if(op->properties == properties)
330 static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr)
332 wmOperator *op= rna_OperatorProperties_find_operator(ptr);
335 return op->type->srna;
340 static IDProperty *rna_OperatorProperties_idprops(PointerRNA *ptr, int create)
342 if(create && !ptr->data) {
343 IDPropertyTemplate val = {0};
344 ptr->data= IDP_New(IDP_GROUP, val, "RNA_OperatorProperties group");
350 static void rna_Operator_name_get(PointerRNA *ptr, char *value)
352 wmOperator *op= (wmOperator*)ptr->data;
353 strcpy(value, op->type->name);
356 static int rna_Operator_name_length(PointerRNA *ptr)
358 wmOperator *op= (wmOperator*)ptr->data;
359 return strlen(op->type->name);
362 static int rna_Operator_has_reports_get(PointerRNA *ptr)
364 wmOperator *op= (wmOperator*)ptr->data;
365 return (op->reports && op->reports->list.first);
368 static PointerRNA rna_Operator_properties_get(PointerRNA *ptr)
370 wmOperator *op= (wmOperator*)ptr->data;
371 return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties);
374 static PointerRNA rna_OperatorTypeMacro_properties_get(PointerRNA *ptr)
376 wmOperatorTypeMacro *otmacro= (wmOperatorTypeMacro*)ptr->data;
377 wmOperatorType *ot = WM_operatortype_find(otmacro->idname, TRUE);
378 return rna_pointer_inherit_refine(ptr, ot->srna, otmacro->properties);
381 static void rna_Event_ascii_get(PointerRNA *ptr, char *value)
383 wmEvent *event= (wmEvent*)ptr->id.data;
384 value[0]= event->ascii;
388 static int rna_Event_ascii_length(PointerRNA *ptr)
390 wmEvent *event= (wmEvent*)ptr->id.data;
391 return (event->ascii)? 1 : 0;
394 static void rna_Window_screen_set(PointerRNA *ptr, PointerRNA value)
396 wmWindow *win= (wmWindow*)ptr->data;
398 if(value.data == NULL)
401 /* exception: can't set screens inside of area/region handers */
402 win->newscreen= value.data;
405 static void rna_Window_screen_update(bContext *C, PointerRNA *ptr)
407 wmWindow *win= (wmWindow*)ptr->data;
409 /* exception: can't set screens inside of area/region handers */
411 WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, win->newscreen);
412 win->newscreen= NULL;
416 static PointerRNA rna_KeyMapItem_properties_get(PointerRNA *ptr)
418 wmKeyMapItem *kmi= ptr->data;
423 //return rna_pointer_inherit_refine(ptr, &RNA_OperatorProperties, op->properties);
424 return PointerRNA_NULL;
427 static int rna_wmKeyMapItem_map_type_get(PointerRNA *ptr)
429 wmKeyMapItem *kmi= ptr->data;
431 if(ISTIMER(kmi->type)) return KMI_TYPE_TIMER;
432 if(ISKEYBOARD(kmi->type)) return KMI_TYPE_KEYBOARD;
433 if(ISTWEAK(kmi->type)) return KMI_TYPE_TWEAK;
434 if(ISMOUSE(kmi->type)) return KMI_TYPE_MOUSE;
435 if(kmi->type == KM_TEXTINPUT) return KMI_TYPE_TEXTINPUT;
436 return KMI_TYPE_KEYBOARD;
439 static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value)
441 wmKeyMapItem *kmi= ptr->data;
442 int map_type= rna_wmKeyMapItem_map_type_get(ptr);
444 if(value != map_type) {
446 case KMI_TYPE_KEYBOARD:
451 kmi->type= EVT_TWEAK_L;
455 kmi->type= LEFTMOUSE;
458 case KMI_TYPE_TEXTINPUT:
459 kmi->type= KM_TEXTINPUT;
460 kmi->val= KM_NOTHING;
464 kmi->val= KM_NOTHING;
470 static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
472 int map_type= rna_wmKeyMapItem_map_type_get(ptr);
474 if(map_type == KMI_TYPE_MOUSE) return event_mouse_type_items;
475 if(map_type == KMI_TYPE_TWEAK) return event_tweak_type_items;
476 if(map_type == KMI_TYPE_TIMER) return event_timer_type_items;
477 else return event_type_items;
480 static EnumPropertyItem *rna_KeyMapItem_value_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
482 int map_type= rna_wmKeyMapItem_map_type_get(ptr);
484 if(map_type == KMI_TYPE_MOUSE || map_type == KMI_TYPE_KEYBOARD) return event_keymouse_value_items;
485 if(map_type == KMI_TYPE_TWEAK) return event_tweak_value_items;
486 else return event_value_items;
489 static EnumPropertyItem *rna_KeyMapItem_propvalue_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free)
491 wmWindowManager *wm = CTX_wm_manager(C);
495 /* check user keymaps */
496 for(km=U.keymaps.first; km; km=km->next) {
498 for (kmi=km->items.first; kmi; kmi=kmi->next) {
499 if (kmi == ptr->data) {
500 if (!km->modal_items) {
501 if (!WM_keymap_user_init(wm, km)) {
502 return keymap_propvalue_items; /* ERROR */
506 return km->modal_items;
511 for(kc=wm->keyconfigs.first; kc; kc=kc->next) {
512 for(km=kc->keymaps.first; km; km=km->next) {
513 /* only check if it's a modal keymap */
514 if (km->modal_items) {
516 for (kmi=km->items.first; kmi; kmi=kmi->next) {
517 if (kmi == ptr->data) {
518 return km->modal_items;
526 return keymap_propvalue_items; /* ERROR */
529 static int rna_KeyMapItem_any_getf(PointerRNA *ptr)
531 wmKeyMapItem *kmi = (wmKeyMapItem*)ptr->data;
533 if (kmi->shift == KM_ANY &&
534 kmi->ctrl == KM_ANY &&
535 kmi->alt == KM_ANY &&
536 kmi->oskey == KM_ANY)
543 static void rna_KeyMapItem_any_setf(PointerRNA *ptr, int value)
545 wmKeyMapItem *kmi = (wmKeyMapItem*)ptr->data;
548 kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= KM_ANY;
551 kmi->shift= kmi->ctrl= kmi->alt= kmi->oskey= 0;
556 static PointerRNA rna_WindowManager_active_keyconfig_get(PointerRNA *ptr)
558 wmWindowManager *wm= ptr->data;
561 for(kc=wm->keyconfigs.first; kc; kc=kc->next)
562 if(strcmp(kc->idname, U.keyconfigstr) == 0)
568 return rna_pointer_inherit_refine(ptr, &RNA_KeyConfig, kc);
571 static void rna_WindowManager_active_keyconfig_set(PointerRNA *ptr, PointerRNA value)
573 wmKeyConfig *kc= value.data;
576 BLI_strncpy(U.keyconfigstr, kc->idname, sizeof(U.keyconfigstr));
579 static void rna_wmKeyMapItem_idname_get(PointerRNA *ptr, char *value)
581 wmKeyMapItem *kmi= ptr->data;
582 WM_operator_py_idname(value, kmi->idname);
585 static int rna_wmKeyMapItem_idname_length(PointerRNA *ptr)
587 wmKeyMapItem *kmi= ptr->data;
588 char pyname[OP_MAX_TYPENAME];
590 WM_operator_py_idname(pyname, kmi->idname);
591 return strlen(pyname);
594 static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value)
596 wmKeyMapItem *kmi= ptr->data;
597 char idname[OP_MAX_TYPENAME];
599 WM_operator_bl_idname(idname, value);
601 if(strcmp(idname, kmi->idname) != 0) {
602 BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname));
604 WM_keymap_properties_reset(kmi, NULL);
608 static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value)
610 wmKeyMapItem *kmi= ptr->data;
611 wmOperatorType *ot= WM_operatortype_find(kmi->idname, 1);
614 strcpy(value, ot->name);
617 static int rna_wmKeyMapItem_name_length(PointerRNA *ptr)
619 wmKeyMapItem *kmi= ptr->data;
620 wmOperatorType *ot= WM_operatortype_find(kmi->idname, 1);
623 return strlen(ot->name);
628 static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr)
630 wmKeyMapItem *kmi= ptr->data;
634 static void rna_wmClipboard_get(PointerRNA *ptr, char *value)
638 pbuf= WM_clipboard_text_get(FALSE);
648 static int rna_wmClipboard_length(PointerRNA *ptr)
653 pbuf = WM_clipboard_text_get(FALSE);
655 length = strlen(pbuf);
666 static void rna_wmClipboard_set(PointerRNA *ptr, const char *value)
668 WM_clipboard_text_set((void *) value, FALSE);
672 static void rna_Operator_unregister(struct Main *bmain, StructRNA *type)
675 wmOperatorType *ot= RNA_struct_blender_type_get(type);
681 /* update while blender is running */
684 WM_operator_stack_clear(wm);
685 WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
687 RNA_struct_free_extension(type, &ot->ext);
690 WM_operatortype_remove(ot->idname);
691 MEM_freeN((void *)idname);
693 /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */
694 RNA_struct_free(&BLENDER_RNA, type);
697 static int operator_poll(bContext *C, wmOperatorType *ot)
705 RNA_pointer_create(NULL, ot->ext.srna, NULL, &ptr); /* dummy */
706 func= RNA_struct_find_function(&ptr, "poll");
708 RNA_parameter_list_create(&list, &ptr, func);
709 RNA_parameter_set_lookup(&list, "context", &C);
710 ot->ext.call(C, &ptr, func, &list);
712 RNA_parameter_get_lookup(&list, "visible", &ret);
715 RNA_parameter_list_free(&list);
720 static int operator_execute(bContext *C, wmOperator *op)
728 RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
729 func= RNA_struct_find_function(&opr, "execute");
731 RNA_parameter_list_create(&list, &opr, func);
732 RNA_parameter_set_lookup(&list, "context", &C);
733 op->type->ext.call(C, &opr, func, &list);
735 RNA_parameter_get_lookup(&list, "result", &ret);
738 RNA_parameter_list_free(&list);
743 /* same as execute() but no return value */
744 static int operator_check(bContext *C, wmOperator *op)
752 RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
753 func= RNA_struct_find_function(&opr, "check");
755 RNA_parameter_list_create(&list, &opr, func);
756 RNA_parameter_set_lookup(&list, "context", &C);
757 op->type->ext.call(C, &opr, func, &list);
759 RNA_parameter_get_lookup(&list, "result", &ret);
762 RNA_parameter_list_free(&list);
767 static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event)
775 RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
776 func= RNA_struct_find_function(&opr, "invoke");
778 RNA_parameter_list_create(&list, &opr, func);
779 RNA_parameter_set_lookup(&list, "context", &C);
780 RNA_parameter_set_lookup(&list, "event", &event);
781 op->type->ext.call(C, &opr, func, &list);
783 RNA_parameter_get_lookup(&list, "result", &ret);
786 RNA_parameter_list_free(&list);
792 static int operator_modal(bContext *C, wmOperator *op, wmEvent *event)
800 RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
801 func= RNA_struct_find_function(&opr, "modal");
803 RNA_parameter_list_create(&list, &opr, func);
804 RNA_parameter_set_lookup(&list, "context", &C);
805 RNA_parameter_set_lookup(&list, "event", &event);
806 op->type->ext.call(C, &opr, func, &list);
808 RNA_parameter_get_lookup(&list, "result", &ret);
811 RNA_parameter_list_free(&list);
816 static void operator_draw(bContext *C, wmOperator *op)
822 RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
823 func= RNA_struct_find_function(&opr, "draw");
825 RNA_parameter_list_create(&list, &opr, func);
826 RNA_parameter_set_lookup(&list, "context", &C);
827 op->type->ext.call(C, &opr, func, &list);
829 RNA_parameter_list_free(&list);
832 /* same as exec(), but call cancel */
833 static int operator_cancel(bContext *C, wmOperator *op)
841 RNA_pointer_create(&CTX_wm_screen(C)->id, op->type->ext.srna, op, &opr);
842 func= RNA_struct_find_function(&opr, "cancel");
844 RNA_parameter_list_create(&list, &opr, func);
845 RNA_parameter_set_lookup(&list, "context", &C);
846 op->type->ext.call(C, &opr, func, &list);
848 RNA_parameter_get_lookup(&list, "result", &ret);
851 RNA_parameter_list_free(&list);
856 void operator_wrapper(wmOperatorType *ot, void *userdata);
857 void macro_wrapper(wmOperatorType *ot, void *userdata);
859 static char _operator_idname[OP_MAX_TYPENAME];
860 static char _operator_name[OP_MAX_TYPENAME];
861 static char _operator_descr[1024];
862 static StructRNA *rna_Operator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
864 wmOperatorType dummyot = {NULL};
865 wmOperator dummyop= {NULL};
867 int have_function[7];
869 /* setup dummy operator & operator type to store static properties in */
870 dummyop.type= &dummyot;
871 dummyot.idname= _operator_idname; /* only assigne the pointer, string is NULL'd */
872 dummyot.name= _operator_name; /* only assigne the pointer, string is NULL'd */
873 dummyot.description= _operator_descr; /* only assigne the pointer, string is NULL'd */
874 RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
876 /* clear incase they are left unset */
877 _operator_idname[0]= _operator_name[0]= _operator_descr[0]= '\0';
879 /* validate the python class */
880 if(validate(&dummyotr, data, have_function) != 0)
883 { /* convert foo.bar to FOO_OT_bar
884 * allocate the description and the idname in 1 go */
886 /* inconveniently long name sanity check */
888 char *ch= _operator_idname;
892 if((*ch >= 'a' && *ch <= 'z') || (*ch >= '0' && *ch <= '9') || *ch == '_') {
895 else if(*ch == '.') {
899 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', at position %d", identifier, _operator_idname, i);
906 if(i > ((int)sizeof(dummyop.idname)) - 3) {
907 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', is too long, maximum length is %d.", identifier, _operator_idname, (int)sizeof(dummyop.idname) - 3);
912 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s', invalid bl_idname '%s', must contain 1 '.' character", identifier, _operator_idname);
916 /* end sanity check */
919 int idlen = strlen(_operator_idname) + 4;
920 int namelen = strlen(_operator_name) + 1;
921 int desclen = strlen(_operator_descr) + 1;
923 ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */
924 WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
927 strcpy(ch, _operator_name);
930 strcpy(ch, _operator_descr);
931 dummyot.description = ch;
935 /* check if we have registered this operator type before, and remove it */
937 wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE);
938 if(ot && ot->ext.srna)
939 rna_Operator_unregister(bmain, ot->ext.srna);
942 /* create a new menu type */
943 dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
944 RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
945 dummyot.ext.data= data;
946 dummyot.ext.call= call;
947 dummyot.ext.free= free;
949 dummyot.pyop_poll= (have_function[0])? operator_poll: NULL;
950 dummyot.exec= (have_function[1])? operator_execute: NULL;
951 dummyot.check= (have_function[2])? operator_check: NULL;
952 dummyot.invoke= (have_function[3])? operator_invoke: NULL;
953 dummyot.modal= (have_function[4])? operator_modal: NULL;
954 dummyot.ui= (have_function[5])? operator_draw: NULL;
955 dummyot.cancel= (have_function[6])? operator_cancel: NULL;
956 WM_operatortype_append_ptr(operator_wrapper, (void *)&dummyot);
958 /* update while blender is running */
959 WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
961 return dummyot.ext.srna;
964 void **rna_Operator_instance(PointerRNA *ptr)
966 wmOperator *op = ptr->data;
967 return &op->py_instance;
970 static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
972 wmOperatorType dummyot = {NULL};
973 wmOperator dummyop= {NULL};
975 int have_function[4];
977 /* setup dummy operator & operator type to store static properties in */
978 dummyop.type= &dummyot;
979 dummyot.idname= _operator_idname; /* only assigne the pointer, string is NULL'd */
980 dummyot.name= _operator_name; /* only assigne the pointer, string is NULL'd */
981 dummyot.description= _operator_descr; /* only assigne the pointer, string is NULL'd */
982 RNA_pointer_create(NULL, &RNA_Macro, &dummyop, &dummyotr);
984 /* validate the python class */
985 if(validate(&dummyotr, data, have_function) != 0)
988 { /* convert foo.bar to FOO_OT_bar
989 * allocate the description and the idname in 1 go */
990 int idlen = strlen(_operator_idname) + 4;
991 int namelen = strlen(_operator_name) + 1;
992 int desclen = strlen(_operator_descr) + 1;
994 ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */
995 WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
998 strcpy(ch, _operator_name);
1001 strcpy(ch, _operator_descr);
1002 dummyot.description = ch;
1005 if(strlen(identifier) >= sizeof(dummyop.idname)) {
1006 BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d.", identifier, (int)sizeof(dummyop.idname));
1010 /* check if we have registered this operator type before, and remove it */
1012 wmOperatorType *ot= WM_operatortype_find(dummyot.idname, TRUE);
1013 if(ot && ot->ext.srna)
1014 rna_Operator_unregister(bmain, ot->ext.srna);
1017 /* create a new menu type */
1018 dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
1019 dummyot.ext.data= data;
1020 dummyot.ext.call= call;
1021 dummyot.ext.free= free;
1023 dummyot.pyop_poll= (have_function[0])? operator_poll: NULL;
1024 dummyot.ui= (have_function[3])? operator_draw: NULL;
1026 WM_operatortype_append_macro_ptr(macro_wrapper, (void *)&dummyot);
1028 /* update while blender is running */
1029 WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
1031 return dummyot.ext.srna;
1033 #endif /* WITH_PYTHON */
1035 static StructRNA* rna_Operator_refine(PointerRNA *opr)
1037 wmOperator *op= (wmOperator*)opr->data;
1038 return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Operator;
1041 static StructRNA* rna_MacroOperator_refine(PointerRNA *opr)
1043 wmOperator *op= (wmOperator*)opr->data;
1044 return (op->type && op->type->ext.srna)? op->type->ext.srna: &RNA_Macro;
1047 static wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, const char *idname, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
1049 // wmWindowManager *wm = CTX_wm_manager(C);
1052 /* only on non-modal maps */
1053 if (km->flag & KEYMAP_MODAL) {
1054 BKE_report(reports, RPT_ERROR, "Not a non-modal keymap.");
1058 if(shift) modifier |= KM_SHIFT;
1059 if(ctrl) modifier |= KM_CTRL;
1060 if(alt) modifier |= KM_ALT;
1061 if(oskey) modifier |= KM_OSKEY;
1063 if(any) modifier = KM_ANY;
1065 return WM_keymap_add_item(km, idname, type, value, modifier, keymodifier);
1068 static wmKeyMapItem *rna_KeyMap_item_new_modal(wmKeyMap *km, bContext *C, ReportList *reports, const char *propvalue_str, int type, int value, int any, int shift, int ctrl, int alt, int oskey, int keymodifier)
1070 wmWindowManager *wm = CTX_wm_manager(C);
1074 /* only modal maps */
1075 if ((km->flag & KEYMAP_MODAL) == 0) {
1076 BKE_report(reports, RPT_ERROR, "Not a modal keymap.");
1080 if (!km->modal_items) {
1081 if(!WM_keymap_user_init(wm, km)) {
1082 BKE_report(reports, RPT_ERROR, "User defined keymap doesn't correspond to a system keymap.");
1087 if (!km->modal_items) {
1088 BKE_report(reports, RPT_ERROR, "No property values defined.");
1093 if(RNA_enum_value_from_id(km->modal_items, propvalue_str, &propvalue)==0) {
1094 BKE_report(reports, RPT_WARNING, "Property value not in enumeration.");
1097 if(shift) modifier |= KM_SHIFT;
1098 if(ctrl) modifier |= KM_CTRL;
1099 if(alt) modifier |= KM_ALT;
1100 if(oskey) modifier |= KM_OSKEY;
1102 if(any) modifier = KM_ANY;
1104 return WM_modalkeymap_add_item(km, type, value, modifier, keymodifier, propvalue);
1107 static wmKeyMap *rna_keymap_new(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid, int modal)
1110 return WM_keymap_find(keyconf, idname, spaceid, regionid);
1112 return WM_modalkeymap_add(keyconf, idname, NULL); /* items will be lazy init */
1116 static wmKeyMap *rna_keymap_find(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
1118 return WM_keymap_list_find(&keyconf->keymaps, idname, spaceid, regionid);
1121 static wmKeyMap *rna_keymap_find_modal(wmKeyConfig *keyconf, const char *idname)
1123 wmOperatorType *ot = WM_operatortype_find(idname, 0);
1128 return ot->modalkeymap;
1131 /* just to work around 'const char *' warning and to ensure this is a python op */
1132 static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value)
1134 wmOperator *data= (wmOperator*)(ptr->data);
1135 char *str= (char *)data->type->idname;
1136 if(!str[0]) strcpy(str, value);
1137 else assert(!"setting the bl_idname on a non-builtin operator");
1140 static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value)
1142 wmOperator *data= (wmOperator*)(ptr->data);
1143 char *str= (char *)data->type->name;
1144 if(!str[0]) strcpy(str, value);
1145 else assert(!"setting the bl_label on a non-builtin operator");
1148 static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value)
1150 wmOperator *data= (wmOperator*)(ptr->data);
1151 char *str= (char *)data->type->description;
1152 if(!str[0]) strcpy(str, value);
1153 else assert(!"setting the bl_description on a non-builtin operator");
1156 #else /* RNA_RUNTIME */
1158 static void rna_def_operator(BlenderRNA *brna)
1163 srna= RNA_def_struct(brna, "Operator", NULL);
1164 RNA_def_struct_ui_text(srna, "Operator", "Storage of an operator being executed, or registered after execution");
1165 RNA_def_struct_sdna(srna, "wmOperator");
1166 RNA_def_struct_refine_func(srna, "rna_Operator_refine");
1168 RNA_def_struct_register_funcs(srna, "rna_Operator_register", "rna_Operator_unregister", "rna_Operator_instance");
1171 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1172 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1173 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1174 RNA_def_property_ui_text(prop, "Name", "");
1176 prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1177 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1178 RNA_def_property_struct_type(prop, "OperatorProperties");
1179 RNA_def_property_ui_text(prop, "Properties", "");
1180 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1182 prop= RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE);
1183 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */
1184 RNA_def_property_boolean_funcs(prop, "rna_Operator_has_reports_get", NULL);
1185 RNA_def_property_ui_text(prop, "Has Reports", "Operator has a set of reports (warnings and errors) from last execution");
1187 prop= RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);
1188 RNA_def_property_struct_type(prop, "UILayout");
1191 prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1192 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1193 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME-3); /* else it uses the pointer size!. -3 because '.' -> '_OT_' */
1194 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1195 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1196 RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP);
1197 RNA_def_struct_name_property(srna, prop);
1199 prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1200 RNA_def_property_string_sdna(prop, NULL, "type->name");
1201 RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
1202 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1203 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1204 RNA_def_property_flag(prop, PROP_REGISTER);
1206 prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1207 RNA_def_property_string_sdna(prop, NULL, "type->description");
1208 RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
1209 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1210 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1211 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1213 prop= RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1214 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1215 RNA_def_property_enum_items(prop, operator_flag_items);
1216 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL|PROP_ENUM_FLAG);
1217 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1219 RNA_api_operator(srna);
1221 srna= RNA_def_struct(brna, "OperatorProperties", NULL);
1222 RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator");
1223 RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine");
1224 RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops");
1227 static void rna_def_macro_operator(BlenderRNA *brna)
1232 srna= RNA_def_struct(brna, "Macro", NULL);
1233 RNA_def_struct_ui_text(srna, "Macro Operator", "Storage of a macro operator being executed, or registered after execution");
1234 RNA_def_struct_sdna(srna, "wmOperator");
1235 RNA_def_struct_refine_func(srna, "rna_MacroOperator_refine");
1237 RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister", "rna_Operator_instance");
1240 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1241 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1242 RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL);
1243 RNA_def_property_ui_text(prop, "Name", "");
1245 prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1246 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1247 RNA_def_property_struct_type(prop, "OperatorProperties");
1248 RNA_def_property_ui_text(prop, "Properties", "");
1249 RNA_def_property_pointer_funcs(prop, "rna_Operator_properties_get", NULL, NULL, NULL);
1252 prop= RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
1253 RNA_def_property_string_sdna(prop, NULL, "type->idname");
1254 RNA_def_property_string_maxlength(prop, OP_MAX_TYPENAME); /* else it uses the pointer size! */
1255 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_idname_set");
1256 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1257 RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP);
1258 RNA_def_struct_name_property(srna, prop);
1260 prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
1261 RNA_def_property_string_sdna(prop, NULL, "type->name");
1262 RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
1263 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_label_set");
1264 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1265 RNA_def_property_flag(prop, PROP_REGISTER);
1267 prop= RNA_def_property(srna, "bl_description", PROP_STRING, PROP_NONE);
1268 RNA_def_property_string_sdna(prop, NULL, "type->description");
1269 RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
1270 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Operator_bl_description_set");
1271 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1272 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL);
1274 prop= RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE);
1275 RNA_def_property_enum_sdna(prop, NULL, "type->flag");
1276 RNA_def_property_enum_items(prop, operator_flag_items);
1277 RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL|PROP_ENUM_FLAG);
1278 RNA_def_property_ui_text(prop, "Options", "Options for this operator type");
1280 RNA_api_macro(srna);
1283 static void rna_def_operator_type_macro(BlenderRNA *brna)
1288 srna= RNA_def_struct(brna, "OperatorTypeMacro", NULL);
1289 RNA_def_struct_ui_text(srna, "OperatorTypeMacro", "Storage of a sub operator in a macro after it has been added");
1290 RNA_def_struct_sdna(srna, "wmOperatorTypeMacro");
1292 // prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1293 // RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1294 // RNA_def_property_string_sdna(prop, NULL, "idname");
1295 // RNA_def_property_ui_text(prop, "Name", "Name of the sub operator");
1296 // RNA_def_struct_name_property(srna, prop);
1298 prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1299 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1300 RNA_def_property_struct_type(prop, "OperatorProperties");
1301 RNA_def_property_ui_text(prop, "Properties", "");
1302 RNA_def_property_pointer_funcs(prop, "rna_OperatorTypeMacro_properties_get", NULL, NULL, NULL);
1305 static void rna_def_operator_utils(BlenderRNA *brna)
1310 srna= RNA_def_struct(brna, "OperatorMousePath", "PropertyGroup");
1311 RNA_def_struct_ui_text(srna, "Operator Mouse Path", "Mouse path values for operators that record such paths");
1313 prop= RNA_def_property(srna, "loc", PROP_FLOAT, PROP_XYZ);
1314 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1315 RNA_def_property_array(prop, 2);
1316 RNA_def_property_ui_text(prop, "Location", "Mouse location");
1318 prop= RNA_def_property(srna, "time", PROP_FLOAT, PROP_NONE);
1319 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1320 RNA_def_property_ui_text(prop, "Time", "Time of mouse location");
1323 static void rna_def_operator_filelist_element(BlenderRNA *brna)
1328 srna= RNA_def_struct(brna, "OperatorFileListElement", "PropertyGroup");
1329 RNA_def_struct_ui_text(srna, "Operator File List Element", "");
1332 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_FILENAME);
1333 RNA_def_property_flag(prop, PROP_IDPROPERTY);
1334 RNA_def_property_ui_text(prop, "Name", "the name of a file or directory within a file list");
1337 static void rna_def_event(BlenderRNA *brna)
1342 srna= RNA_def_struct(brna, "Event", NULL);
1343 RNA_def_struct_ui_text(srna, "Event", "Window Manager Event");
1344 RNA_def_struct_sdna(srna, "wmEvent");
1346 RNA_define_verify_sdna(0); // not in sdna
1349 prop= RNA_def_property(srna, "ascii", PROP_STRING, PROP_NONE);
1350 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1351 RNA_def_property_string_funcs(prop, "rna_Event_ascii_get", "rna_Event_ascii_length", NULL);
1352 RNA_def_property_ui_text(prop, "ASCII", "Single ASCII character for this event");
1356 prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1357 RNA_def_property_enum_sdna(prop, NULL, "val");
1358 RNA_def_property_enum_items(prop, event_value_items);
1359 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1360 RNA_def_property_ui_text(prop, "Value", "The type of event, only applies to some");
1362 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1363 RNA_def_property_enum_sdna(prop, NULL, "type");
1364 RNA_def_property_enum_items(prop, event_type_items);
1365 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1366 RNA_def_property_ui_text(prop, "Type", "");
1370 prop= RNA_def_property(srna, "mouse_x", PROP_INT, PROP_NONE);
1371 RNA_def_property_int_sdna(prop, NULL, "x");
1372 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1373 RNA_def_property_ui_text(prop, "Mouse X Position", "The window relative vertical location of the mouse");
1375 prop= RNA_def_property(srna, "mouse_y", PROP_INT, PROP_NONE);
1376 RNA_def_property_int_sdna(prop, NULL, "y");
1377 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1378 RNA_def_property_ui_text(prop, "Mouse Y Position", "The window relative horizontal location of the mouse");
1380 prop= RNA_def_property(srna, "mouse_region_x", PROP_INT, PROP_NONE);
1381 RNA_def_property_int_sdna(prop, NULL, "mval[0]");
1382 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1383 RNA_def_property_ui_text(prop, "Mouse X Position", "The region relative vertical location of the mouse");
1385 prop= RNA_def_property(srna, "mouse_region_y", PROP_INT, PROP_NONE);
1386 RNA_def_property_int_sdna(prop, NULL, "mval[1]");
1387 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1388 RNA_def_property_ui_text(prop, "Mouse Y Position", "The region relative horizontal location of the mouse");
1390 prop= RNA_def_property(srna, "mouse_prev_x", PROP_INT, PROP_NONE);
1391 RNA_def_property_int_sdna(prop, NULL, "prevx");
1392 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1393 RNA_def_property_ui_text(prop, "Mouse Previous X Position", "The window relative vertical location of the mouse");
1395 prop= RNA_def_property(srna, "mouse_prev_y", PROP_INT, PROP_NONE);
1396 RNA_def_property_int_sdna(prop, NULL, "prevy");
1397 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1398 RNA_def_property_ui_text(prop, "Mouse Previous Y Position", "The window relative horizontal location of the mouse");
1402 prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1403 RNA_def_property_boolean_sdna(prop, NULL, "shift", 1);
1404 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1405 RNA_def_property_ui_text(prop, "Shift", "True when the Shift key is held");
1407 prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1408 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 1);
1409 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1410 RNA_def_property_ui_text(prop, "Ctrl", "True when the Ctrl key is held");
1412 prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1413 RNA_def_property_boolean_sdna(prop, NULL, "alt", 1);
1414 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1415 RNA_def_property_ui_text(prop, "Alt", "True when the Alt/Option key is held");
1417 prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1418 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 1);
1419 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1420 RNA_def_property_ui_text(prop, "OS Key", "True when the Cmd key is held");
1422 RNA_define_verify_sdna(1); // not in sdna
1425 static void rna_def_timer(BlenderRNA *brna)
1430 srna= RNA_def_struct(brna, "Timer", NULL);
1431 RNA_def_struct_ui_text(srna, "Timer", "Window event timer");
1432 RNA_def_struct_sdna(srna, "wmTimer");
1434 RNA_define_verify_sdna(0); // not in sdna
1436 /* could wrap more, for now this is enough */
1437 prop= RNA_def_property(srna, "time_step", PROP_FLOAT, PROP_NONE);
1438 RNA_def_property_float_sdna(prop, NULL, "timestep");
1439 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1440 RNA_def_property_ui_text(prop, "Time Step", "");
1442 prop= RNA_def_property(srna, "time_delta", PROP_FLOAT, PROP_NONE);
1443 RNA_def_property_float_sdna(prop, NULL, "delta");
1444 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1445 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1447 prop= RNA_def_property(srna, "time_duration", PROP_FLOAT, PROP_NONE);
1448 RNA_def_property_float_sdna(prop, NULL, "duration");
1449 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1450 RNA_def_property_ui_text(prop, "Delta", "Time since last step in seconds");
1452 RNA_define_verify_sdna(1); // not in sdna
1455 static void rna_def_window(BlenderRNA *brna)
1460 srna= RNA_def_struct(brna, "Window", NULL);
1461 RNA_def_struct_ui_text(srna, "Window", "Open window");
1462 RNA_def_struct_sdna(srna, "wmWindow");
1464 prop= RNA_def_property(srna, "screen", PROP_POINTER, PROP_NONE);
1465 RNA_def_property_flag(prop, PROP_NEVER_NULL);
1466 RNA_def_property_struct_type(prop, "Screen");
1467 RNA_def_property_ui_text(prop, "Screen", "Active screen showing in the window");
1468 RNA_def_property_flag(prop, PROP_EDITABLE);
1469 RNA_def_property_pointer_funcs(prop, NULL, "rna_Window_screen_set", NULL, NULL);
1470 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
1471 RNA_def_property_update(prop, 0, "rna_Window_screen_update");
1475 static void rna_def_wm_keyconfigs(BlenderRNA *brna, PropertyRNA *cprop)
1483 RNA_def_property_srna(cprop, "KeyConfigurations");
1484 srna= RNA_def_struct(brna, "KeyConfigurations", NULL);
1485 RNA_def_struct_sdna(srna, "wmWindowManager");
1486 RNA_def_struct_ui_text(srna, "KeyConfigs", "Collection of KeyConfigs");
1488 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1489 RNA_def_property_struct_type(prop, "KeyConfig");
1490 RNA_def_property_pointer_funcs(prop, "rna_WindowManager_active_keyconfig_get", "rna_WindowManager_active_keyconfig_set", NULL, NULL);
1491 RNA_def_property_flag(prop, PROP_EDITABLE);
1492 RNA_def_property_ui_text(prop, "Active KeyConfig", "Active wm KeyConfig");
1494 prop= RNA_def_property(srna, "default", PROP_POINTER, PROP_NEVER_NULL);
1495 RNA_def_property_pointer_sdna(prop, NULL, "defaultconf");
1496 RNA_def_property_struct_type(prop, "KeyConfig");
1497 RNA_def_property_ui_text(prop, "Default Key Configuration", "");
1500 func= RNA_def_function(srna, "new", "WM_keyconfig_new_user"); // add_keyconfig
1501 parm= RNA_def_string(func, "name", "", 0, "Name", "");
1502 RNA_def_property_flag(parm, PROP_REQUIRED);
1503 parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Added key configuration.");
1504 RNA_def_function_return(func, parm);
1506 func= RNA_def_function(srna, "remove", "WM_keyconfig_remove"); // remove_keyconfig
1507 parm= RNA_def_pointer(func, "keyconfig", "KeyConfig", "Key Configuration", "Removed key configuration.");
1508 RNA_def_property_flag(parm, PROP_REQUIRED);
1511 static void rna_def_windowmanager(BlenderRNA *brna)
1516 srna= RNA_def_struct(brna, "WindowManager", "ID");
1517 RNA_def_struct_ui_text(srna, "Window Manager", "Window manager datablock defining open windows and other user interface data");
1518 RNA_def_struct_clear_flag(srna, STRUCT_ID_REFCOUNT);
1519 RNA_def_struct_sdna(srna, "wmWindowManager");
1521 prop= RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
1522 RNA_def_property_struct_type(prop, "Operator");
1523 RNA_def_property_ui_text(prop, "Operators", "Operator registry");
1525 prop= RNA_def_property(srna, "windows", PROP_COLLECTION, PROP_NONE);
1526 RNA_def_property_struct_type(prop, "Window");
1527 RNA_def_property_ui_text(prop, "Windows", "Open windows");
1529 prop= RNA_def_property(srna, "keyconfigs", PROP_COLLECTION, PROP_NONE);
1530 RNA_def_property_struct_type(prop, "KeyConfig");
1531 RNA_def_property_ui_text(prop, "Key Configurations", "Registered key configurations");
1532 rna_def_wm_keyconfigs(brna, prop);
1534 prop= RNA_def_property(srna, "clipboard", PROP_STRING, PROP_NONE);
1535 RNA_def_property_string_funcs(prop, "rna_wmClipboard_get", "rna_wmClipboard_length", "rna_wmClipboard_set");
1536 RNA_def_property_ui_text(prop, "Text Clipboard", "");
1541 /* keyconfig.items */
1542 static void rna_def_keymap_items(BlenderRNA *brna, PropertyRNA *cprop)
1545 // PropertyRNA *prop;
1550 RNA_def_property_srna(cprop, "KeyMapItems");
1551 srna= RNA_def_struct(brna, "KeyMapItems", NULL);
1552 RNA_def_struct_sdna(srna, "wmKeyMap");
1553 RNA_def_struct_ui_text(srna, "KeyMap Items", "Collection of keymap items");
1555 func= RNA_def_function(srna, "new", "rna_KeyMap_item_new");
1556 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1557 parm= RNA_def_string(func, "idname", "", 0, "Operator Identifier", "");
1558 RNA_def_property_flag(parm, PROP_REQUIRED);
1559 parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
1560 RNA_def_property_flag(parm, PROP_REQUIRED);
1561 parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
1562 RNA_def_property_flag(parm, PROP_REQUIRED);
1563 RNA_def_boolean(func, "any", 0, "Any", "");
1564 RNA_def_boolean(func, "shift", 0, "Shift", "");
1565 RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
1566 RNA_def_boolean(func, "alt", 0, "Alt", "");
1567 RNA_def_boolean(func, "oskey", 0, "OS Key", "");
1568 RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
1569 parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
1570 RNA_def_function_return(func, parm);
1572 func= RNA_def_function(srna, "new_modal", "rna_KeyMap_item_new_modal");
1573 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS);
1574 parm= RNA_def_string(func, "propvalue", "", 0, "Property Value", "");
1575 RNA_def_property_flag(parm, PROP_REQUIRED);
1576 parm= RNA_def_enum(func, "type", event_type_items, 0, "Type", "");
1577 RNA_def_property_flag(parm, PROP_REQUIRED);
1578 parm= RNA_def_enum(func, "value", event_value_items, 0, "Value", "");
1579 RNA_def_property_flag(parm, PROP_REQUIRED);
1580 RNA_def_boolean(func, "any", 0, "Any", "");
1581 RNA_def_boolean(func, "shift", 0, "Shift", "");
1582 RNA_def_boolean(func, "ctrl", 0, "Ctrl", "");
1583 RNA_def_boolean(func, "alt", 0, "Alt", "");
1584 RNA_def_boolean(func, "oskey", 0, "OS Key", "");
1585 RNA_def_enum(func, "key_modifier", event_type_items, 0, "Key Modifier", "");
1586 parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "Added key map item.");
1587 RNA_def_function_return(func, parm);
1589 func= RNA_def_function(srna, "remove", "WM_keymap_remove_item");
1590 parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1591 RNA_def_property_flag(parm, PROP_REQUIRED);
1593 func= RNA_def_function(srna, "from_id", "WM_keymap_item_find_id");
1594 parm= RNA_def_property(func, "id", PROP_INT, PROP_NONE);
1595 RNA_def_property_flag(parm, PROP_REQUIRED);
1596 RNA_def_property_ui_text(parm, "id", "ID of the item");
1597 parm= RNA_def_pointer(func, "item", "KeyMapItem", "Item", "");
1598 RNA_def_function_return(func, parm);
1602 static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
1605 //PropertyRNA *prop;
1611 RNA_def_property_srna(cprop, "KeyMaps");
1612 srna= RNA_def_struct(brna, "KeyMaps", NULL);
1613 RNA_def_struct_sdna(srna, "wmKeyConfig");
1614 RNA_def_struct_ui_text(srna, "Key Maps", "Collection of keymaps");
1616 func= RNA_def_function(srna, "new", "rna_keymap_new"); // add_keymap
1617 parm= RNA_def_string(func, "name", "", 0, "Name", "");
1618 RNA_def_property_flag(parm, PROP_REQUIRED);
1619 RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
1620 RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1621 RNA_def_boolean(func, "modal", 0, "Modal", "");
1622 parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Added key map.");
1623 RNA_def_function_return(func, parm);
1625 func= RNA_def_function(srna, "find", "rna_keymap_find"); // find_keymap
1626 parm= RNA_def_string(func, "name", "", 0, "Name", "");
1627 RNA_def_property_flag(parm, PROP_REQUIRED);
1628 RNA_def_enum(func, "space_type", space_type_items, SPACE_EMPTY, "Space Type", "");
1629 RNA_def_enum(func, "region_type", region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1630 parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map.");
1631 RNA_def_function_return(func, parm);
1633 func= RNA_def_function(srna, "find_modal", "rna_keymap_find_modal"); // find_keymap_modal
1634 parm= RNA_def_string(func, "name", "", 0, "Operator Name", "");
1635 RNA_def_property_flag(parm, PROP_REQUIRED);
1636 parm= RNA_def_pointer(func, "keymap", "KeyMap", "Key Map", "Corresponding key map.");
1637 RNA_def_function_return(func, parm);
1641 static void rna_def_keyconfig(BlenderRNA *brna)
1644 // FunctionRNA *func;
1645 // PropertyRNA *parm;
1648 static EnumPropertyItem map_type_items[] = {
1649 {KMI_TYPE_KEYBOARD, "KEYBOARD", 0, "Keyboard", ""},
1650 {KMI_TYPE_TWEAK, "TWEAK", 0, "Tweak", ""},
1651 {KMI_TYPE_MOUSE, "MOUSE", 0, "Mouse", ""},
1652 {KMI_TYPE_TEXTINPUT, "TEXTINPUT", 0, "Text Input", ""},
1653 {KMI_TYPE_TIMER, "TIMER", 0, "Timer", ""},
1654 {0, NULL, 0, NULL, NULL}};
1657 srna= RNA_def_struct(brna, "KeyConfig", NULL);
1658 RNA_def_struct_sdna(srna, "wmKeyConfig");
1659 RNA_def_struct_ui_text(srna, "Key Configuration", "Input configuration, including keymaps");
1661 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1662 RNA_def_property_string_sdna(prop, NULL, "idname");
1663 RNA_def_property_ui_text(prop, "Name", "Name of the key configuration");
1664 RNA_def_struct_name_property(srna, prop);
1666 prop= RNA_def_property(srna, "keymaps", PROP_COLLECTION, PROP_NONE);
1667 RNA_def_property_struct_type(prop, "KeyMap");
1668 RNA_def_property_ui_text(prop, "Key Maps", "Key maps configured as part of this configuration");
1669 rna_def_wm_keymaps(brna, prop);
1671 prop= RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
1672 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYCONF_USER);
1673 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1674 RNA_def_property_ui_text(prop, "User Defined", "Indicates that a keyconfig was defined by the user");
1676 RNA_api_keyconfig(srna);
1679 srna= RNA_def_struct(brna, "KeyMap", NULL);
1680 RNA_def_struct_sdna(srna, "wmKeyMap");
1681 RNA_def_struct_ui_text(srna, "Key Map", "Input configuration, including keymaps");
1683 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1684 RNA_def_property_string_sdna(prop, NULL, "idname");
1685 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1686 RNA_def_property_ui_text(prop, "Name", "Name of the key map");
1687 RNA_def_struct_name_property(srna, prop);
1689 prop= RNA_def_property(srna, "space_type", PROP_ENUM, PROP_NONE);
1690 RNA_def_property_enum_sdna(prop, NULL, "spaceid");
1691 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1692 RNA_def_property_enum_items(prop, space_type_items);
1693 RNA_def_property_ui_text(prop, "Space Type", "Optional space type keymap is associated with");
1695 prop= RNA_def_property(srna, "region_type", PROP_ENUM, PROP_NONE);
1696 RNA_def_property_enum_sdna(prop, NULL, "regionid");
1697 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1698 RNA_def_property_enum_items(prop, region_type_items);
1699 RNA_def_property_ui_text(prop, "Region Type", "Optional region type keymap is associated with");
1701 prop= RNA_def_property(srna, "keymap_items", PROP_COLLECTION, PROP_NONE);
1702 RNA_def_property_collection_sdna(prop, NULL, "items", NULL);
1703 RNA_def_property_struct_type(prop, "KeyMapItem");
1704 RNA_def_property_ui_text(prop, "Items", "Items in the keymap, linking an operator to an input event");
1705 rna_def_keymap_items(brna, prop);
1707 prop= RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NEVER_NULL);
1708 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_USER);
1709 RNA_def_property_ui_text(prop, "User Defined", "Keymap is defined by the user");
1711 prop= RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
1712 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_MODAL);
1713 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1714 RNA_def_property_ui_text(prop, "Modal Keymap", "Indicates that a keymap is used for translate modal events for an operator");
1716 prop= RNA_def_property(srna, "show_expanded_items", PROP_BOOLEAN, PROP_NONE);
1717 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_EXPANDED);
1718 RNA_def_property_ui_text(prop, "Items Expanded", "Expanded in the user interface");
1719 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1721 prop= RNA_def_property(srna, "show_expanded_children", PROP_BOOLEAN, PROP_NONE);
1722 RNA_def_property_boolean_sdna(prop, NULL, "flag", KEYMAP_CHILDREN_EXPANDED);
1723 RNA_def_property_ui_text(prop, "Children Expanded", "Children expanded in the user interface");
1724 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1727 RNA_api_keymap(srna);
1730 srna= RNA_def_struct(brna, "KeyMapItem", NULL);
1731 RNA_def_struct_sdna(srna, "wmKeyMapItem");
1732 RNA_def_struct_ui_text(srna, "Key Map Item", "Item in a Key Map");
1734 prop= RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
1735 RNA_def_property_string_sdna(prop, NULL, "idname");
1736 RNA_def_property_ui_text(prop, "Identifier", "Identifier of operator to call on input event");
1737 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length", "rna_wmKeyMapItem_idname_set");
1738 RNA_def_struct_name_property(srna, prop);
1740 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1741 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1742 RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event");
1743 RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_name_get", "rna_wmKeyMapItem_name_length", NULL);
1745 prop= RNA_def_property(srna, "properties", PROP_POINTER, PROP_NONE);
1746 RNA_def_property_struct_type(prop, "OperatorProperties");
1747 RNA_def_property_pointer_funcs(prop, "rna_KeyMapItem_properties_get", NULL, NULL, NULL);
1748 RNA_def_property_ui_text(prop, "Properties", "Properties to set when the operator is called");
1750 prop= RNA_def_property(srna, "map_type", PROP_ENUM, PROP_NONE);
1751 RNA_def_property_enum_sdna(prop, NULL, "maptype");
1752 RNA_def_property_enum_items(prop, map_type_items);
1753 RNA_def_property_enum_funcs(prop, "rna_wmKeyMapItem_map_type_get", "rna_wmKeyMapItem_map_type_set", NULL);
1754 RNA_def_property_ui_text(prop, "Map Type", "Type of event mapping");
1756 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1757 RNA_def_property_enum_sdna(prop, NULL, "type");
1758 RNA_def_property_enum_items(prop, event_type_items);
1759 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_type_itemf");
1760 RNA_def_property_ui_text(prop, "Type", "Type of event");
1762 prop= RNA_def_property(srna, "value", PROP_ENUM, PROP_NONE);
1763 RNA_def_property_enum_sdna(prop, NULL, "val");
1764 RNA_def_property_enum_items(prop, event_value_items);
1765 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_value_itemf");
1766 RNA_def_property_ui_text(prop, "Value", "");
1768 prop= RNA_def_property(srna, "id", PROP_INT, PROP_NONE);
1769 RNA_def_property_int_sdna(prop, NULL, "id");
1770 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1771 RNA_def_property_ui_text(prop, "id", "ID of the item");
1773 prop= RNA_def_property(srna, "any", PROP_BOOLEAN, PROP_NONE);
1774 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_any_getf", "rna_KeyMapItem_any_setf");
1775 RNA_def_property_ui_text(prop, "Any", "Any modifier keys pressed");
1777 prop= RNA_def_property(srna, "shift", PROP_BOOLEAN, PROP_NONE);
1778 RNA_def_property_boolean_sdna(prop, NULL, "shift", 0);
1779 // RNA_def_property_enum_sdna(prop, NULL, "shift");
1780 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
1781 RNA_def_property_ui_text(prop, "Shift", "Shift key pressed");
1783 prop= RNA_def_property(srna, "ctrl", PROP_BOOLEAN, PROP_NONE);
1784 RNA_def_property_boolean_sdna(prop, NULL, "ctrl", 0);
1785 // RNA_def_property_enum_sdna(prop, NULL, "ctrl");
1786 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
1787 RNA_def_property_ui_text(prop, "Ctrl", "Control key pressed");
1789 prop= RNA_def_property(srna, "alt", PROP_BOOLEAN, PROP_NONE);
1790 RNA_def_property_boolean_sdna(prop, NULL, "alt", 0);
1791 // RNA_def_property_enum_sdna(prop, NULL, "alt");
1792 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
1793 RNA_def_property_ui_text(prop, "Alt", "Alt key pressed");
1795 prop= RNA_def_property(srna, "oskey", PROP_BOOLEAN, PROP_NONE);
1796 RNA_def_property_boolean_sdna(prop, NULL, "oskey", 0);
1797 // RNA_def_property_enum_sdna(prop, NULL, "oskey");
1798 // RNA_def_property_enum_items(prop, keymap_modifiers_items);
1799 RNA_def_property_ui_text(prop, "OS Key", "Operating system key pressed");
1801 prop= RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE);
1802 RNA_def_property_enum_sdna(prop, NULL, "keymodifier");
1803 RNA_def_property_enum_items(prop, event_type_items);
1804 RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier");
1806 prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1807 RNA_def_property_boolean_sdna(prop, NULL, "flag", KMI_EXPANDED);
1808 RNA_def_property_ui_text(prop, "Expanded", "Show key map event and property details in the user interface");
1809 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1811 prop= RNA_def_property(srna, "propvalue", PROP_ENUM, PROP_NONE);
1812 RNA_def_property_enum_sdna(prop, NULL, "propvalue");
1813 RNA_def_property_enum_items(prop, keymap_propvalue_items);
1814 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_KeyMapItem_propvalue_itemf");
1815 RNA_def_property_ui_text(prop, "Property Value", "The value this event translates to in a modal keymap");
1817 prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1818 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", KMI_INACTIVE);
1819 RNA_def_property_ui_text(prop, "Active", "Activate or deactivate item");
1820 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_DEHLT, 1);
1822 prop= RNA_def_property(srna, "is_user_defined", PROP_BOOLEAN, PROP_NONE);
1823 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1824 RNA_def_property_ui_text(prop, "User Defined", "Is this keymap item user defined (doesn't just override a builtin item)");
1825 RNA_def_property_boolean_funcs(prop, "rna_KeyMapItem_userdefined_get", NULL);
1827 RNA_api_keymapitem(srna);
1830 void RNA_def_wm(BlenderRNA *brna)
1832 rna_def_operator(brna);
1833 rna_def_operator_utils(brna);
1834 rna_def_operator_filelist_element(brna);
1835 rna_def_macro_operator(brna);
1836 rna_def_operator_type_macro(brna);
1837 rna_def_event(brna);
1838 rna_def_timer(brna);
1839 rna_def_window(brna);
1840 rna_def_windowmanager(brna);
1841 rna_def_keyconfig(brna);
1844 #endif /* RNA_RUNTIME */