1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16
17 /** \file
18 * \ingroup RNA
19 */
20
21 #include <stddef.h>
22 #include <stdlib.h>
23
24 #include "RNA_define.h"
25 #include "RNA_enum_types.h"
26
27 #include "rna_internal.h"
28
29 #include "DNA_scene_types.h"
30 #include "DNA_screen_types.h"
31 #include "DNA_workspace_types.h"
32
33 #include "ED_info.h"
34
35 const EnumPropertyItem rna_enum_region_type_items[] = {
36 {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""},
37 {RGN_TYPE_HEADER, "HEADER", 0, "Header", ""},
38 {RGN_TYPE_CHANNELS, "CHANNELS", 0, "Channels", ""},
39 {RGN_TYPE_TEMPORARY, "TEMPORARY", 0, "Temporary", ""},
40 {RGN_TYPE_UI, "UI", 0, "UI", ""},
41 {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""},
42 {RGN_TYPE_TOOL_PROPS, "TOOL_PROPS", 0, "Tool Properties", ""},
43 {RGN_TYPE_PREVIEW, "PREVIEW", 0, "Preview", ""},
44 {RGN_TYPE_HUD, "HUD", 0, "Floating Region", ""},
45 {RGN_TYPE_NAV_BAR, "NAVIGATION_BAR", 0, "Navigation Bar", ""},
46 {RGN_TYPE_EXECUTE, "EXECUTE", 0, "Execute Buttons", ""},
47 {RGN_TYPE_FOOTER, "FOOTER", 0, "Footer", ""},
48 {RGN_TYPE_TOOL_HEADER, "TOOL_HEADER", 0, "Tool Header", ""},
49 {0, NULL, 0, NULL, NULL},
50 };
51
52 #include "ED_screen.h"
53
54 #include "WM_api.h"
55 #include "WM_types.h"
56
57 #ifdef RNA_RUNTIME
58
59 # include "BKE_global.h"
60 # include "BKE_screen.h"
61 # include "BKE_workspace.h"
62
63 # include "DEG_depsgraph.h"
64
65 # include "UI_view2d.h"
66
67 # ifdef WITH_PYTHON
68 # include "BPY_extern.h"
69 # endif
70
rna_Screen_bar_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)71 static void rna_Screen_bar_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
72 {
73 bScreen *screen = (bScreen *)ptr->data;
74 screen->do_draw = true;
75 screen->do_refresh = true;
76 }
77
rna_Screen_redraw_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)78 static void rna_Screen_redraw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
79 {
80 bScreen *screen = (bScreen *)ptr->data;
81
82 /* the settings for this are currently only available from a menu in the TimeLine,
83 * hence refresh=SPACE_ACTION, as timeline is now in there
84 */
85 ED_screen_animation_timer_update(screen, screen->redraws_flag);
86 }
87
rna_Screen_is_animation_playing_get(PointerRNA * UNUSED (ptr))88 static bool rna_Screen_is_animation_playing_get(PointerRNA *UNUSED(ptr))
89 {
90 /* can be NULL on file load, T42619 */
91 wmWindowManager *wm = G_MAIN->wm.first;
92 return wm ? (ED_screen_animation_playing(wm) != NULL) : 0;
93 }
94
rna_Screen_is_scrubbing_get(PointerRNA * ptr)95 static bool rna_Screen_is_scrubbing_get(PointerRNA *ptr)
96 {
97 bScreen *screen = (bScreen *)ptr->data;
98 return screen->scrubbing;
99 }
100
rna_region_alignment_get(PointerRNA * ptr)101 static int rna_region_alignment_get(PointerRNA *ptr)
102 {
103 ARegion *region = ptr->data;
104 return RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
105 }
106
rna_Screen_fullscreen_get(PointerRNA * ptr)107 static bool rna_Screen_fullscreen_get(PointerRNA *ptr)
108 {
109 bScreen *screen = (bScreen *)ptr->data;
110 return (screen->state == SCREENMAXIMIZED);
111 }
112
113 /* UI compatible list: should not be needed, but for now we need to keep EMPTY
114 * at least in the static version of this enum for python scripts. */
rna_Area_type_itemf(bContext * UNUSED (C),PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * r_free)115 static const EnumPropertyItem *rna_Area_type_itemf(bContext *UNUSED(C),
116 PointerRNA *UNUSED(ptr),
117 PropertyRNA *UNUSED(prop),
118 bool *r_free)
119 {
120 /* +1 to skip SPACE_EMPTY */
121 *r_free = false;
122 return rna_enum_space_type_items + 1;
123 }
124
rna_Area_type_get(PointerRNA * ptr)125 static int rna_Area_type_get(PointerRNA *ptr)
126 {
127 ScrArea *area = (ScrArea *)ptr->data;
128 /* Usually 'spacetype' is used. It lags behind a bit while switching area
129 * type though, then we use 'butspacetype' instead (T41435). */
130 return (area->butspacetype == SPACE_EMPTY) ? area->spacetype : area->butspacetype;
131 }
132
rna_Area_type_set(PointerRNA * ptr,int value)133 static void rna_Area_type_set(PointerRNA *ptr, int value)
134 {
135 if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
136 /* Special case: An area can not be set to show the top-bar editor (or
137 * other global areas). However it should still be possible to identify
138 * its type from Python. */
139 return;
140 }
141
142 ScrArea *area = (ScrArea *)ptr->data;
143 area->butspacetype = value;
144 }
145
rna_Area_type_update(bContext * C,PointerRNA * ptr)146 static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
147 {
148 bScreen *screen = (bScreen *)ptr->owner_id;
149 ScrArea *area = (ScrArea *)ptr->data;
150
151 /* Running update without having called 'set', see: T64049 */
152 if (area->butspacetype == SPACE_EMPTY) {
153 return;
154 }
155
156 wmWindowManager *wm = CTX_wm_manager(C);
157 wmWindow *win;
158 /* XXX this call still use context, so we trick it to work in the right context */
159 for (win = wm->windows.first; win; win = win->next) {
160 if (screen == WM_window_get_active_screen(win)) {
161 wmWindow *prevwin = CTX_wm_window(C);
162 ScrArea *prevsa = CTX_wm_area(C);
163 ARegion *prevar = CTX_wm_region(C);
164
165 CTX_wm_window_set(C, win);
166 CTX_wm_area_set(C, area);
167 CTX_wm_region_set(C, NULL);
168
169 ED_area_newspace(C, area, area->butspacetype, true);
170 ED_area_tag_redraw(area);
171
172 /* Unset so that rna_Area_type_get uses spacetype instead. */
173 area->butspacetype = SPACE_EMPTY;
174
175 /* It is possible that new layers becomes visible. */
176 if (area->spacetype == SPACE_VIEW3D) {
177 DEG_on_visible_update(CTX_data_main(C), false);
178 }
179
180 CTX_wm_window_set(C, prevwin);
181 CTX_wm_area_set(C, prevsa);
182 CTX_wm_region_set(C, prevar);
183 break;
184 }
185 }
186 }
187
rna_Area_ui_type_itemf(bContext * C,PointerRNA * UNUSED (ptr),PropertyRNA * UNUSED (prop),bool * r_free)188 static const EnumPropertyItem *rna_Area_ui_type_itemf(bContext *C,
189 PointerRNA *UNUSED(ptr),
190 PropertyRNA *UNUSED(prop),
191 bool *r_free)
192 {
193 EnumPropertyItem *item = NULL;
194 int totitem = 0;
195
196 /* +1 to skip SPACE_EMPTY */
197 for (const EnumPropertyItem *item_from = rna_enum_space_type_items + 1; item_from->identifier;
198 item_from++) {
199 if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
200 continue;
201 }
202
203 SpaceType *st = item_from->identifier[0] ? BKE_spacetype_from_id(item_from->value) : NULL;
204 int totitem_prev = totitem;
205 if (st && st->space_subtype_item_extend != NULL) {
206 st->space_subtype_item_extend(C, &item, &totitem);
207 while (totitem_prev < totitem) {
208 item[totitem_prev++].value |= item_from->value << 16;
209 }
210 }
211 else {
212 RNA_enum_item_add(&item, &totitem, item_from);
213 item[totitem_prev++].value = item_from->value << 16;
214 }
215 }
216 RNA_enum_item_end(&item, &totitem);
217 *r_free = true;
218
219 return item;
220 }
221
rna_Area_ui_type_get(PointerRNA * ptr)222 static int rna_Area_ui_type_get(PointerRNA *ptr)
223 {
224 ScrArea *area = ptr->data;
225 const int area_type = rna_Area_type_get(ptr);
226 const bool area_changing = area->butspacetype != SPACE_EMPTY;
227 int value = area_type << 16;
228
229 /* Area->type can be NULL when not yet initialized (for example when accessed
230 * through the outliner or API when not visible), or it can be wrong while
231 * the area type is changing.
232 * So manually do the lookup in those cases, but do not actually change area->type
233 * since that prevents a proper exit when the area type is changing.
234 * Logic copied from `ED_area_init()`.*/
235 SpaceType *type = area->type;
236 if (type == NULL || area_changing) {
237 type = BKE_spacetype_from_id(area_type);
238 if (type == NULL) {
239 type = BKE_spacetype_from_id(SPACE_VIEW3D);
240 }
241 BLI_assert(type != NULL);
242 }
243 if (type->space_subtype_item_extend != NULL) {
244 value |= area_changing ? area->butspacetype_subtype : type->space_subtype_get(area);
245 }
246 return value;
247 }
248
rna_Area_ui_type_set(PointerRNA * ptr,int value)249 static void rna_Area_ui_type_set(PointerRNA *ptr, int value)
250 {
251 ScrArea *area = ptr->data;
252 const int space_type = value >> 16;
253 SpaceType *st = BKE_spacetype_from_id(space_type);
254
255 rna_Area_type_set(ptr, space_type);
256
257 if (st && st->space_subtype_item_extend != NULL) {
258 area->butspacetype_subtype = value & 0xffff;
259 }
260 }
261
rna_Area_ui_type_update(bContext * C,PointerRNA * ptr)262 static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr)
263 {
264 ScrArea *area = ptr->data;
265 SpaceType *st = BKE_spacetype_from_id(area->butspacetype);
266
267 rna_Area_type_update(C, ptr);
268
269 if ((area->type == st) && (st->space_subtype_item_extend != NULL)) {
270 st->space_subtype_set(area, area->butspacetype_subtype);
271 }
272 area->butspacetype_subtype = 0;
273 }
274
rna_View2D_region_to_view(struct View2D * v2d,float x,float y,float result[2])275 static void rna_View2D_region_to_view(struct View2D *v2d, float x, float y, float result[2])
276 {
277 UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
278 }
279
rna_View2D_view_to_region(struct View2D * v2d,float x,float y,bool clip,int result[2])280 static void rna_View2D_view_to_region(
281 struct View2D *v2d, float x, float y, bool clip, int result[2])
282 {
283 if (clip) {
284 UI_view2d_view_to_region_clip(v2d, x, y, &result[0], &result[1]);
285 }
286 else {
287 UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]);
288 }
289 }
290
rna_Screen_statusbar_info_get(struct bScreen * UNUSED (screen),Main * bmain,bContext * C)291 static const char *rna_Screen_statusbar_info_get(struct bScreen *UNUSED(screen),
292 Main *bmain,
293 bContext *C)
294 {
295 return ED_info_statusbar_string(bmain, CTX_data_scene(C), CTX_data_view_layer(C));
296 }
297
298 #else
299
300 /* Area.spaces */
rna_def_area_spaces(BlenderRNA * brna,PropertyRNA * cprop)301 static void rna_def_area_spaces(BlenderRNA *brna, PropertyRNA *cprop)
302 {
303 StructRNA *srna;
304 PropertyRNA *prop;
305
306 RNA_def_property_srna(cprop, "AreaSpaces");
307 srna = RNA_def_struct(brna, "AreaSpaces", NULL);
308 RNA_def_struct_sdna(srna, "ScrArea");
309 RNA_def_struct_ui_text(srna, "Area Spaces", "Collection of spaces");
310
311 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
312 RNA_def_property_pointer_sdna(prop, NULL, "spacedata.first");
313 RNA_def_property_struct_type(prop, "Space");
314 RNA_def_property_ui_text(prop, "Active Space", "Space currently being displayed in this area");
315 }
316
rna_def_area_api(StructRNA * srna)317 static void rna_def_area_api(StructRNA *srna)
318 {
319 FunctionRNA *func;
320 PropertyRNA *parm;
321
322 RNA_def_function(srna, "tag_redraw", "ED_area_tag_redraw");
323
324 func = RNA_def_function(srna, "header_text_set", "ED_area_status_text");
325 RNA_def_function_ui_description(func, "Set the header status text");
326 parm = RNA_def_string(
327 func, "text", NULL, 0, "Text", "New string for the header, None clears the text");
328 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
329 RNA_def_property_clear_flag(parm, PROP_NEVER_NULL);
330 }
331
rna_def_area(BlenderRNA * brna)332 static void rna_def_area(BlenderRNA *brna)
333 {
334 StructRNA *srna;
335 PropertyRNA *prop;
336
337 srna = RNA_def_struct(brna, "Area", NULL);
338 RNA_def_struct_ui_text(srna, "Area", "Area in a subdivided screen, containing an editor");
339 RNA_def_struct_sdna(srna, "ScrArea");
340
341 prop = RNA_def_property(srna, "spaces", PROP_COLLECTION, PROP_NONE);
342 RNA_def_property_collection_sdna(prop, NULL, "spacedata", NULL);
343 RNA_def_property_struct_type(prop, "Space");
344 RNA_def_property_ui_text(prop,
345 "Spaces",
346 "Spaces contained in this area, the first being the active space "
347 "(NOTE: Useful for example to restore a previously used 3D view space "
348 "in a certain area to get the old view orientation)");
349 rna_def_area_spaces(brna, prop);
350
351 prop = RNA_def_property(srna, "regions", PROP_COLLECTION, PROP_NONE);
352 RNA_def_property_collection_sdna(prop, NULL, "regionbase", NULL);
353 RNA_def_property_struct_type(prop, "Region");
354 RNA_def_property_ui_text(prop, "Regions", "Regions this area is subdivided in");
355
356 prop = RNA_def_property(srna, "show_menus", PROP_BOOLEAN, PROP_NONE);
357 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", HEADER_NO_PULLDOWN);
358 RNA_def_property_ui_text(prop, "Show Menus", "Show menus in the header");
359
360 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
361 RNA_def_property_enum_sdna(prop, NULL, "spacetype");
362 RNA_def_property_enum_items(prop, rna_enum_space_type_items);
363 RNA_def_property_enum_default(prop, SPACE_VIEW3D);
364 RNA_def_property_enum_funcs(
365 prop, "rna_Area_type_get", "rna_Area_type_set", "rna_Area_type_itemf");
366 RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area");
367 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
368 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
369 RNA_def_property_update(prop, 0, "rna_Area_type_update");
370
371 prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE);
372 RNA_def_property_enum_items(prop, DummyRNA_NULL_items); /* in fact dummy */
373 RNA_def_property_enum_default(prop, SPACE_VIEW3D << 16);
374 RNA_def_property_enum_funcs(
375 prop, "rna_Area_ui_type_get", "rna_Area_ui_type_set", "rna_Area_ui_type_itemf");
376 RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area");
377 RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
378 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
379 RNA_def_property_update(prop, 0, "rna_Area_ui_type_update");
380
381 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
382 RNA_def_property_int_sdna(prop, NULL, "totrct.xmin");
383 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
384 RNA_def_property_ui_text(
385 prop, "X Position", "The window relative vertical location of the area");
386
387 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
388 RNA_def_property_int_sdna(prop, NULL, "totrct.ymin");
389 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
390 RNA_def_property_ui_text(
391 prop, "Y Position", "The window relative horizontal location of the area");
392
393 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
394 RNA_def_property_int_sdna(prop, NULL, "winx");
395 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
396 RNA_def_property_ui_text(prop, "Width", "Area width");
397
398 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
399 RNA_def_property_int_sdna(prop, NULL, "winy");
400 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
401 RNA_def_property_ui_text(prop, "Height", "Area height");
402
403 rna_def_area_api(srna);
404 }
405
rna_def_view2d_api(StructRNA * srna)406 static void rna_def_view2d_api(StructRNA *srna)
407 {
408 FunctionRNA *func;
409 PropertyRNA *parm;
410
411 static const float view_default[2] = {0.0f, 0.0f};
412 static const int region_default[2] = {0.0f, 0.0f};
413
414 func = RNA_def_function(srna, "region_to_view", "rna_View2D_region_to_view");
415 RNA_def_function_ui_description(func, "Transform region coordinates to 2D view");
416 parm = RNA_def_float(func, "x", 0, -FLT_MAX, FLT_MAX, "x", "Region x coordinate", -10000, 10000);
417 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
418 parm = RNA_def_float(func, "y", 0, -FLT_MAX, FLT_MAX, "y", "Region y coordinate", -10000, 10000);
419 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
420 parm = RNA_def_float_array(func,
421 "result",
422 2,
423 view_default,
424 -FLT_MAX,
425 FLT_MAX,
426 "Result",
427 "View coordinates",
428 -10000.0f,
429 10000.0f);
430 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
431 RNA_def_function_output(func, parm);
432
433 func = RNA_def_function(srna, "view_to_region", "rna_View2D_view_to_region");
434 RNA_def_function_ui_description(func, "Transform 2D view coordinates to region");
435 parm = RNA_def_float(
436 func, "x", 0.0f, -FLT_MAX, FLT_MAX, "x", "2D View x coordinate", -10000.0f, 10000.0f);
437 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
438 parm = RNA_def_float(
439 func, "y", 0.0f, -FLT_MAX, FLT_MAX, "y", "2D View y coordinate", -10000.0f, 10000.0f);
440 RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
441 RNA_def_boolean(func, "clip", 1, "Clip", "Clip coordinates to the visible region");
442 parm = RNA_def_int_array(func,
443 "result",
444 2,
445 region_default,
446 INT_MIN,
447 INT_MAX,
448 "Result",
449 "Region coordinates",
450 -10000,
451 10000);
452 RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0);
453 RNA_def_function_output(func, parm);
454 }
455
rna_def_view2d(BlenderRNA * brna)456 static void rna_def_view2d(BlenderRNA *brna)
457 {
458 StructRNA *srna;
459 /* PropertyRNA *prop; */
460
461 srna = RNA_def_struct(brna, "View2D", NULL);
462 RNA_def_struct_ui_text(srna, "View2D", "Scroll and zoom for a 2D region");
463 RNA_def_struct_sdna(srna, "View2D");
464
465 /* TODO more View2D properties could be exposed here (read-only) */
466
467 rna_def_view2d_api(srna);
468 }
469
rna_def_region(BlenderRNA * brna)470 static void rna_def_region(BlenderRNA *brna)
471 {
472 StructRNA *srna;
473 PropertyRNA *prop;
474
475 static const EnumPropertyItem alignment_types[] = {
476 {RGN_ALIGN_NONE, "NONE", 0, "None", "Don't use any fixed alignment, fill available space"},
477 {RGN_ALIGN_TOP, "TOP", 0, "Top", ""},
478 {RGN_ALIGN_BOTTOM, "BOTTOM", 0, "Bottom", ""},
479 {RGN_ALIGN_LEFT, "LEFT", 0, "Left", ""},
480 {RGN_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
481 {RGN_ALIGN_HSPLIT, "HORIZONTAL_SPLIT", 0, "Horizontal Split", ""},
482 {RGN_ALIGN_VSPLIT, "VERTICAL_SPLIT", 0, "Vertical Split", ""},
483 {RGN_ALIGN_FLOAT,
484 "FLOAT",
485 0,
486 "Float",
487 "Region floats on screen, doesn't use any fixed alignment"},
488 {RGN_ALIGN_QSPLIT,
489 "QUAD_SPLIT",
490 0,
491 "Quad Split",
492 "Region is split horizontally and vertically"},
493 {0, NULL, 0, NULL, NULL},
494 };
495
496 srna = RNA_def_struct(brna, "Region", NULL);
497 RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area");
498 RNA_def_struct_sdna(srna, "ARegion");
499
500 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
501 RNA_def_property_enum_sdna(prop, NULL, "regiontype");
502 RNA_def_property_enum_items(prop, rna_enum_region_type_items);
503 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
504 RNA_def_property_ui_text(prop, "Region Type", "Type of this region");
505
506 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
507 RNA_def_property_int_sdna(prop, NULL, "winrct.xmin");
508 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
509 RNA_def_property_ui_text(
510 prop, "X Position", "The window relative vertical location of the region");
511
512 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
513 RNA_def_property_int_sdna(prop, NULL, "winrct.ymin");
514 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
515 RNA_def_property_ui_text(
516 prop, "Y Position", "The window relative horizontal location of the region");
517
518 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
519 RNA_def_property_int_sdna(prop, NULL, "winx");
520 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
521 RNA_def_property_ui_text(prop, "Width", "Region width");
522
523 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
524 RNA_def_property_int_sdna(prop, NULL, "winy");
525 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
526 RNA_def_property_ui_text(prop, "Height", "Region height");
527
528 prop = RNA_def_property(srna, "view2d", PROP_POINTER, PROP_NONE);
529 RNA_def_property_pointer_sdna(prop, NULL, "v2d");
530 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
531 RNA_def_property_flag(prop, PROP_NEVER_NULL);
532 RNA_def_property_ui_text(prop, "View2D", "2D view of the region");
533
534 prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
535 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
536 RNA_def_property_enum_items(prop, alignment_types);
537 RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL);
538 RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area");
539
540 RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
541 }
542
rna_def_screen(BlenderRNA * brna)543 static void rna_def_screen(BlenderRNA *brna)
544 {
545 StructRNA *srna;
546 PropertyRNA *prop;
547
548 FunctionRNA *func;
549 PropertyRNA *parm;
550
551 srna = RNA_def_struct(brna, "Screen", "ID");
552 RNA_def_struct_sdna(srna, "Screen"); /* it is actually bScreen but for 2.5 the dna is patched! */
553 RNA_def_struct_ui_text(
554 srna, "Screen", "Screen data-block, defining the layout of areas in a window");
555 RNA_def_struct_ui_icon(srna, ICON_WORKSPACE);
556
557 /* collections */
558 prop = RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE);
559 RNA_def_property_collection_sdna(prop, NULL, "areabase", NULL);
560 RNA_def_property_struct_type(prop, "Area");
561 RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into");
562
563 /* readonly status indicators */
564 prop = RNA_def_property(srna, "is_animation_playing", PROP_BOOLEAN, PROP_NONE);
565 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
566 RNA_def_property_boolean_funcs(prop, "rna_Screen_is_animation_playing_get", NULL);
567 RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active");
568
569 prop = RNA_def_property(srna, "is_scrubbing", PROP_BOOLEAN, PROP_NONE);
570 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
571 RNA_def_property_boolean_funcs(prop, "rna_Screen_is_scrubbing_get", NULL);
572 RNA_def_property_ui_text(
573 prop, "User is Scrubbing", "True when the user is scrubbing through time");
574
575 prop = RNA_def_property(srna, "is_temporary", PROP_BOOLEAN, PROP_NONE);
576 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
577 RNA_def_property_boolean_sdna(prop, NULL, "temp", 1);
578 RNA_def_property_ui_text(prop, "Temporary", "");
579
580 prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
581 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
582 RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
583 RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen");
584
585 /* Status Bar. */
586
587 prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE);
588 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SCREEN_COLLAPSE_STATUSBAR);
589 RNA_def_property_ui_text(prop, "Show Status Bar", "Show Status Bar");
590 RNA_def_property_update(prop, 0, "rna_Screen_bar_update");
591
592 func = RNA_def_function(srna, "statusbar_info", "rna_Screen_statusbar_info_get");
593 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_CONTEXT);
594 parm = RNA_def_string(func, "statusbar_info", NULL, 0, "Status Bar Info", "");
595 RNA_def_function_return(func, parm);
596
597 /* Define Anim Playback Areas */
598 prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
599 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION);
600 RNA_def_property_ui_text(prop, "Top-Left 3D Editor", "");
601 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
602
603 prop = RNA_def_property(srna, "use_play_3d_editors", PROP_BOOLEAN, PROP_NONE);
604 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_3D_WIN);
605 RNA_def_property_ui_text(prop, "All 3D Viewports", "");
606 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
607
608 prop = RNA_def_property(srna, "use_follow", PROP_BOOLEAN, PROP_NONE);
609 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_FOLLOW);
610 RNA_def_property_ui_text(prop, "Follow", "Follow current frame in editors");
611 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
612
613 prop = RNA_def_property(srna, "use_play_animation_editors", PROP_BOOLEAN, PROP_NONE);
614 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_ANIM_WIN);
615 RNA_def_property_ui_text(prop, "Animation Editors", "");
616 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
617
618 prop = RNA_def_property(srna, "use_play_properties_editors", PROP_BOOLEAN, PROP_NONE);
619 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_BUTS_WIN);
620 RNA_def_property_ui_text(prop, "Property Editors", "");
621 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
622
623 prop = RNA_def_property(srna, "use_play_image_editors", PROP_BOOLEAN, PROP_NONE);
624 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_IMAGE_WIN);
625 RNA_def_property_ui_text(prop, "Image Editors", "");
626 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
627
628 prop = RNA_def_property(srna, "use_play_sequence_editors", PROP_BOOLEAN, PROP_NONE);
629 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_SEQ);
630 RNA_def_property_ui_text(prop, "Sequencer Editors", "");
631 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
632
633 prop = RNA_def_property(srna, "use_play_node_editors", PROP_BOOLEAN, PROP_NONE);
634 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_NODES);
635 RNA_def_property_ui_text(prop, "Node Editors", "");
636 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
637
638 prop = RNA_def_property(srna, "use_play_clip_editors", PROP_BOOLEAN, PROP_NONE);
639 RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_CLIPS);
640 RNA_def_property_ui_text(prop, "Clip Editors", "");
641 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
642 }
643
RNA_def_screen(BlenderRNA * brna)644 void RNA_def_screen(BlenderRNA *brna)
645 {
646 rna_def_screen(brna);
647 rna_def_area(brna);
648 rna_def_region(brna);
649 rna_def_view2d(brna);
650 }
651
652 #endif
653