Blender V5.0
rna_screen.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 <cstddef>
10#include <cstdlib>
11
12#include "DNA_space_types.h"
13
14#include "RNA_define.hh"
15#include "RNA_enum_types.hh"
16
17#include "rna_internal.hh"
18
19#include "DNA_screen_types.h"
20
22 {RGN_TYPE_WINDOW, "WINDOW", 0, "Window", ""},
23 {RGN_TYPE_HEADER, "HEADER", 0, "Header", ""},
24 {RGN_TYPE_CHANNELS, "CHANNELS", 0, "Channels", ""},
25 {RGN_TYPE_TEMPORARY, "TEMPORARY", 0, "Temporary", ""},
26 {RGN_TYPE_UI, "UI", 0, "Sidebar", ""},
27 {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""},
28 {RGN_TYPE_TOOL_PROPS, "TOOL_PROPS", 0, "Tool Properties", ""},
29 {RGN_TYPE_ASSET_SHELF, "ASSET_SHELF", 0, "Asset Shelf", ""},
30 {RGN_TYPE_ASSET_SHELF_HEADER, "ASSET_SHELF_HEADER", 0, "Asset Shelf Header", ""},
31 {RGN_TYPE_PREVIEW, "PREVIEW", 0, "Preview", ""},
32 {RGN_TYPE_HUD, "HUD", 0, "Floating Region", ""},
33 {RGN_TYPE_NAV_BAR, "NAVIGATION_BAR", 0, "Navigation Bar", ""},
34 {RGN_TYPE_EXECUTE, "EXECUTE", 0, "Execute Buttons", ""},
35 {RGN_TYPE_FOOTER, "FOOTER", 0, "Footer", ""},
36 {RGN_TYPE_TOOL_HEADER, "TOOL_HEADER", 0, "Tool Header", ""},
37 {RGN_TYPE_XR, "XR", 0, "XR", ""},
38 {0, nullptr, 0, nullptr, nullptr},
39};
40
42 {-1, "UNSUPPORTED", 0, "Not Supported", "This region does not support panel categories"},
43 {0, nullptr, 0, nullptr, nullptr},
44};
45
46#include "UI_interface_c.hh"
47
48#include "WM_api.hh"
49#include "WM_types.hh"
50
51#ifdef RNA_RUNTIME
52
53# include "RNA_access.hh"
54
55# include "BKE_global.hh"
56# include "BKE_screen.hh"
57# include "BKE_workspace.hh"
58
59# include "DEG_depsgraph.hh"
60
61# include "ED_info.hh"
62# include "ED_node.hh"
63# include "ED_screen.hh"
64
65# include "UI_view2d.hh"
66
67# include "BLT_translation.hh"
68
69# ifdef WITH_PYTHON
70# include "BPY_extern.hh"
71# endif
72
73static void rna_Screen_bar_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
74{
75 bScreen *screen = (bScreen *)ptr->data;
76 screen->do_draw = true;
77 screen->do_refresh = true;
78}
79
80static void rna_Screen_redraw_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
81{
82 bScreen *screen = (bScreen *)ptr->data;
83
84 /* the settings for this are currently only available from a menu in the TimeLine,
85 * hence refresh=SPACE_ACTION, as timeline is now in there
86 */
87 ED_screen_animation_timer_update(screen, screen->redraws_flag);
88}
89
90static bool rna_Screen_is_animation_playing_get(PointerRNA * /*ptr*/)
91{
92 /* can be nullptr on file load, #42619 */
93 wmWindowManager *wm = static_cast<wmWindowManager *>(G_MAIN->wm.first);
94 return wm ? (ED_screen_animation_playing(wm) != nullptr) : 0;
95}
96
97static bool rna_Screen_is_scrubbing_get(PointerRNA *ptr)
98{
99 bScreen *screen = (bScreen *)ptr->data;
100 return screen->scrubbing;
101}
102
103static int rna_Region_alignment_get(PointerRNA *ptr)
104{
105 ARegion *region = static_cast<ARegion *>(ptr->data);
106 return RGN_ALIGN_ENUM_FROM_MASK(region->alignment);
107}
108
109static bool rna_Screen_fullscreen_get(PointerRNA *ptr)
110{
111 bScreen *screen = (bScreen *)ptr->data;
112 return (screen->state == SCREENMAXIMIZED || screen->state == SCREENFULL);
113}
114
115static int rna_Area_type_get(PointerRNA *ptr)
116{
117 ScrArea *area = (ScrArea *)ptr->data;
118 /* Usually 'spacetype' is used. It lags behind a bit while switching area
119 * type though, then we use 'butspacetype' instead (#41435). */
120 return (area->butspacetype == SPACE_EMPTY) ? area->spacetype : area->butspacetype;
121}
122
123static void rna_Area_type_set(PointerRNA *ptr, int value)
124{
125 if (ELEM(value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
126 /* Special case: An area can not be set to show the top-bar editor (or
127 * other global areas). However it should still be possible to identify
128 * its type from Python. */
129 return;
130 }
131
132 ScrArea *area = (ScrArea *)ptr->data;
133 /* Empty areas are locked. */
134 if ((value == SPACE_EMPTY) || (area->spacetype == SPACE_EMPTY)) {
135 return;
136 }
137
138 area->butspacetype = value;
139}
140
141static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
142{
143 bScreen *screen = (bScreen *)ptr->owner_id;
144 ScrArea *area = (ScrArea *)ptr->data;
145
146 /* Running update without having called 'set', see: #64049 */
147 if (area->butspacetype == SPACE_EMPTY) {
148 return;
149 }
150
152 wmWindow *win;
153 /* XXX this call still use context, so we trick it to work in the right context */
154 for (win = static_cast<wmWindow *>(wm->windows.first); win; win = win->next) {
155 if (screen == WM_window_get_active_screen(win)) {
156 wmWindow *prevwin = CTX_wm_window(C);
157 ScrArea *prevsa = CTX_wm_area(C);
158 ARegion *prevar = CTX_wm_region(C);
159
160 CTX_wm_window_set(C, win);
161 CTX_wm_area_set(C, area);
162 CTX_wm_region_set(C, nullptr);
163
164 ED_area_newspace(C, area, area->butspacetype, true);
165 ED_area_tag_redraw(area);
166
167 /* Unset so that rna_Area_type_get uses spacetype instead. */
168 area->butspacetype = SPACE_EMPTY;
169
170 /* It is possible that new layers becomes visible. */
171 if (area->spacetype == SPACE_VIEW3D) {
173 }
174 else if (area->spacetype == SPACE_NODE) {
176 }
177
178 CTX_wm_window_set(C, prevwin);
179 CTX_wm_area_set(C, prevsa);
180 CTX_wm_region_set(C, prevar);
181 break;
182 }
183 }
184
185 /* The set of visible geometry nodes gizmos depends on the visible node editors. So if a node
186 * editor becomes visible/invisible, the gizmos have to be updated. */
188}
189
190static const EnumPropertyItem *rna_Area_ui_type_itemf(bContext *C,
192 PropertyRNA * /*prop*/,
193 bool *r_free)
194{
195 EnumPropertyItem *item = nullptr;
196 int totitem = 0;
197
198 ScrArea *area = (ScrArea *)ptr->data;
200 if (area->spacetype != SPACE_EMPTY) {
201 item_from += 1; /* +1 to skip SPACE_EMPTY */
202 }
203
204 for (; item_from->identifier; item_from++) {
205 if (ELEM(item_from->value, SPACE_TOPBAR, SPACE_STATUSBAR)) {
206 continue;
207 }
208
209 SpaceType *st = item_from->identifier[0] ? BKE_spacetype_from_id(item_from->value) : nullptr;
210 int totitem_prev = totitem;
211 if (st && st->space_subtype_item_extend != nullptr) {
212 st->space_subtype_item_extend(C, &item, &totitem);
213 while (totitem_prev < totitem) {
214 item[totitem_prev++].value |= item_from->value << 16;
215 }
216 }
217 else {
218 RNA_enum_item_add(&item, &totitem, item_from);
219 item[totitem_prev++].value = item_from->value << 16;
220 }
221 }
222 RNA_enum_item_end(&item, &totitem);
223 *r_free = true;
224
225 return item;
226}
227
228static int rna_Area_ui_type_get(PointerRNA *ptr)
229{
230 ScrArea *area = static_cast<ScrArea *>(ptr->data);
231 /* This is for the Python API which may inspect empty areas. */
232 if (UNLIKELY(area->spacetype == SPACE_EMPTY)) {
233 return SPACE_EMPTY;
234 }
235 const int area_type = rna_Area_type_get(ptr);
236 const bool area_changing = area->butspacetype != SPACE_EMPTY;
237 int value = area_type << 16;
238
239 /* Area->type can be nullptr when not yet initialized (for example when accessed
240 * through the outliner or API when not visible), or it can be wrong while
241 * the area type is changing.
242 * So manually do the lookup in those cases, but do not actually change area->type
243 * since that prevents a proper exit when the area type is changing.
244 * Logic copied from `ED_area_init()`. */
245 SpaceType *type = area->type;
246 if (type == nullptr || area_changing) {
247 type = BKE_spacetype_from_id(area_type);
248 if (type == nullptr) {
250 }
251 BLI_assert(type != nullptr);
252 }
253 if (type->space_subtype_item_extend != nullptr) {
254 value |= area_changing ? area->butspacetype_subtype : type->space_subtype_get(area);
255 }
256 return value;
257}
258
259static void rna_Area_ui_type_set(PointerRNA *ptr, int value)
260{
261 ScrArea *area = static_cast<ScrArea *>(ptr->data);
262 const int space_type = value >> 16;
263 /* Empty areas are locked. */
264 if ((space_type == SPACE_EMPTY) || (area->spacetype == SPACE_EMPTY)) {
265 return;
266 }
267 SpaceType *st = BKE_spacetype_from_id(space_type);
268
269 rna_Area_type_set(ptr, space_type);
270
271 if (st && st->space_subtype_item_extend != nullptr) {
272 area->butspacetype_subtype = value & 0xffff;
273 }
274}
275
276static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr)
277{
278 ScrArea *area = static_cast<ScrArea *>(ptr->data);
279
280 rna_Area_type_update(C, ptr);
281
283}
284
285static PointerRNA rna_Region_data_get(PointerRNA *ptr)
286{
287 bScreen *screen = (bScreen *)ptr->owner_id;
288 ARegion *region = static_cast<ARegion *>(ptr->data);
289
290 if (region->regiondata != nullptr) {
291 if (region->regiontype == RGN_TYPE_WINDOW) {
292 /* We could make this static, it won't change at run-time. */
294 if (region->runtime->type == BKE_regiontype_from_id(st, region->regiontype)) {
296 &screen->id, &RNA_RegionView3D, region->regiondata);
297 return newptr;
298 }
299 }
300 }
301 return PointerRNA_NULL;
302}
303
304static int rna_Region_active_panel_category_editable_get(const PointerRNA *ptr,
305 const char **r_info)
306{
307 ARegion *region = static_cast<ARegion *>(ptr->data);
308 if (BLI_listbase_is_empty(&region->runtime->panels_category)) {
309 if (r_info) {
310 *r_info = N_("This region does not support panel categories");
311 }
312 return 0;
313 }
314 return PROP_EDITABLE;
315}
316
317static int rna_Region_active_panel_category_get(PointerRNA *ptr)
318{
319 ARegion *region = static_cast<ARegion *>(ptr->data);
320 const char *idname = UI_panel_category_active_get(region, false);
321 return UI_panel_category_index_find(region, idname);
322}
323
324static void rna_Region_active_panel_category_set(PointerRNA *ptr, int value)
325{
326 BLI_assert(rna_Region_active_panel_category_editable_get(ptr, nullptr));
327
328 ARegion *region = static_cast<ARegion *>(ptr->data);
330}
331
332static const EnumPropertyItem *rna_Region_active_panel_category_itemf(bContext * /*C*/,
334 PropertyRNA * /*prop*/,
335 bool *r_free)
336{
337 ARegion *region = static_cast<ARegion *>(ptr->data);
338
339 if (!rna_Region_active_panel_category_editable_get(ptr, nullptr)) {
340 *r_free = false;
342 }
343
344 EnumPropertyItem *items = nullptr;
345 EnumPropertyItem item = {0, "", 0, "", ""};
346 int totitems = 0;
347 int category_index;
349 PanelCategoryDyn *, pc_dyn, &region->runtime->panels_category, category_index)
350 {
351 item.value = category_index;
352 item.identifier = pc_dyn->idname;
353 item.name = pc_dyn->idname;
354 RNA_enum_item_add(&items, &totitems, &item);
355 }
356
357 RNA_enum_item_end(&items, &totitems);
358 *r_free = true;
359 return items;
360}
361
362static void rna_View2D_region_to_view(View2D *v2d, float x, float y, float result[2])
363{
364 UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
365}
366
367static void rna_View2D_view_to_region(View2D *v2d, float x, float y, bool clip, int result[2])
368{
369 if (clip) {
371 }
372 else {
373 UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]);
374 }
375}
376
377static const char *rna_Screen_statusbar_info_get(bScreen * /*screen*/, Main *bmain, bContext *C)
378{
380}
381
382static void rna_Region_tag_refresh_ui(ARegion *region, ReportList *reports)
383{
384 if (region->regiontype != RGN_TYPE_TEMPORARY) {
385 BKE_report(reports, RPT_ERROR, "Only supported for \"TEMPORARY\" type regions (pop-ups)");
386 return;
387 }
389}
390
391#else
392
393/* Area.spaces */
395{
396 StructRNA *srna;
397 PropertyRNA *prop;
398
399 RNA_def_property_srna(cprop, "AreaSpaces");
400 srna = RNA_def_struct(brna, "AreaSpaces", nullptr);
401 RNA_def_struct_sdna(srna, "ScrArea");
402 RNA_def_struct_ui_text(srna, "Area Spaces", "Collection of spaces");
403
404 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
405 RNA_def_property_pointer_sdna(prop, nullptr, "spacedata.first");
406 RNA_def_property_struct_type(prop, "Space");
407 RNA_def_property_ui_text(prop, "Active Space", "Space currently being displayed in this area");
408}
409
410static void rna_def_area_api(StructRNA *srna)
411{
412 FunctionRNA *func;
413 PropertyRNA *parm;
414
415 RNA_def_function(srna, "tag_redraw", "ED_area_tag_redraw");
416
417 func = RNA_def_function(srna, "header_text_set", "ED_area_status_text");
418 RNA_def_function_ui_description(func, "Set the header status text");
419 parm = RNA_def_string(
420 func, "text", nullptr, 0, "Text", "New string for the header, None clears the text");
423}
424
425static void rna_def_area(BlenderRNA *brna)
426{
427 StructRNA *srna;
428 PropertyRNA *prop;
429
430 srna = RNA_def_struct(brna, "Area", nullptr);
431 RNA_def_struct_ui_text(srna, "Area", "Area in a subdivided screen, containing an editor");
432 RNA_def_struct_sdna(srna, "ScrArea");
433
434 prop = RNA_def_property(srna, "spaces", PROP_COLLECTION, PROP_NONE);
435 RNA_def_property_collection_sdna(prop, nullptr, "spacedata", nullptr);
436 RNA_def_property_struct_type(prop, "Space");
438 "Spaces",
439 "Spaces contained in this area, the first being the active space "
440 "(NOTE: Useful for example to restore a previously used 3D view space "
441 "in a certain area to get the old view orientation)");
442 rna_def_area_spaces(brna, prop);
443
444 prop = RNA_def_property(srna, "regions", PROP_COLLECTION, PROP_NONE);
445 RNA_def_property_collection_sdna(prop, nullptr, "regionbase", nullptr);
446 RNA_def_property_struct_type(prop, "Region");
447 RNA_def_property_ui_text(prop, "Regions", "Regions this area is subdivided in");
448
449 prop = RNA_def_property(srna, "show_menus", PROP_BOOLEAN, PROP_NONE);
451 RNA_def_property_ui_text(prop, "Show Menus", "Show menus in the header");
452
453 /* Note on space type use of #SPACE_EMPTY, this is not visible to the user,
454 * and script authors should be able to assign this value, however the value may be set
455 * and needs to be read back by script authors.
456 *
457 * This happens when an area is full-screen (when #ScrArea.full is set).
458 * in this case reading the empty value is needed, but it should never be set, see: #87187. */
459 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
460 RNA_def_property_enum_sdna(prop, nullptr, "spacetype");
463 RNA_def_property_enum_funcs(prop, "rna_Area_type_get", "rna_Area_type_set", nullptr);
464 RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area");
467 RNA_def_property_update(prop, 0, "rna_Area_type_update");
468
469 prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE);
473 prop, "rna_Area_ui_type_get", "rna_Area_ui_type_set", "rna_Area_ui_type_itemf");
474 RNA_def_property_ui_text(prop, "Editor Type", "Current editor type for this area");
477 RNA_def_property_update(prop, 0, "rna_Area_ui_type_update");
478
479 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
480 RNA_def_property_int_sdna(prop, nullptr, "totrct.xmin");
483 prop, "X Position", "The window relative vertical location of the area");
484
485 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
486 RNA_def_property_int_sdna(prop, nullptr, "totrct.ymin");
489 prop, "Y Position", "The window relative horizontal location of the area");
490
491 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
492 RNA_def_property_int_sdna(prop, nullptr, "winx");
494 RNA_def_property_ui_text(prop, "Width", "Area width");
495
496 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
497 RNA_def_property_int_sdna(prop, nullptr, "winy");
499 RNA_def_property_ui_text(prop, "Height", "Area height");
500
501 rna_def_area_api(srna);
502}
503
505{
506 FunctionRNA *func;
507 PropertyRNA *parm;
508
509 static const float view_default[2] = {0.0f, 0.0f};
510 static const int region_default[2] = {0, 0};
511
512 func = RNA_def_function(srna, "region_to_view", "rna_View2D_region_to_view");
513 RNA_def_function_ui_description(func, "Transform region coordinates to 2D view");
514 parm = RNA_def_float(func, "x", 0, -FLT_MAX, FLT_MAX, "x", "Region x coordinate", -10000, 10000);
516 parm = RNA_def_float(func, "y", 0, -FLT_MAX, FLT_MAX, "y", "Region y coordinate", -10000, 10000);
518 parm = RNA_def_float_array(func,
519 "result",
520 2,
521 view_default,
522 -FLT_MAX,
523 FLT_MAX,
524 "Result",
525 "View coordinates",
526 -10000.0f,
527 10000.0f);
529 RNA_def_function_output(func, parm);
530
531 func = RNA_def_function(srna, "view_to_region", "rna_View2D_view_to_region");
532 RNA_def_function_ui_description(func, "Transform 2D view coordinates to region");
533 parm = RNA_def_float(
534 func, "x", 0.0f, -FLT_MAX, FLT_MAX, "x", "2D View x coordinate", -10000.0f, 10000.0f);
536 parm = RNA_def_float(
537 func, "y", 0.0f, -FLT_MAX, FLT_MAX, "y", "2D View y coordinate", -10000.0f, 10000.0f);
539 RNA_def_boolean(func, "clip", true, "Clip", "Clip coordinates to the visible region");
540 parm = RNA_def_int_array(func,
541 "result",
542 2,
543 region_default,
544 INT_MIN,
545 INT_MAX,
546 "Result",
547 "Region coordinates",
548 -10000,
549 10000);
551 RNA_def_function_output(func, parm);
552}
553
554static void rna_def_view2d(BlenderRNA *brna)
555{
556 StructRNA *srna;
557 // PropertyRNA *prop;
558
559 srna = RNA_def_struct(brna, "View2D", nullptr);
560 RNA_def_struct_ui_text(srna, "View2D", "Scroll and zoom for a 2D region");
561 RNA_def_struct_sdna(srna, "View2D");
562
563 /* TODO: more View2D properties could be exposed here (read-only). */
564
565 rna_def_view2d_api(srna);
566}
567
569{
570 FunctionRNA *func;
571 // PropertyRNA *parm;
572
573 RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
574
575 /* Wrap #ED_region_tag_refresh_ui (with some additional checks). */
576 func = RNA_def_function(srna, "tag_refresh_ui", "rna_Region_tag_refresh_ui");
578}
579
580static void rna_def_region(BlenderRNA *brna)
581{
582 StructRNA *srna;
583 PropertyRNA *prop;
584
585 static const EnumPropertyItem alignment_types[] = {
586 {RGN_ALIGN_NONE, "NONE", 0, "None", "Don't use any fixed alignment, fill available space"},
587 {RGN_ALIGN_TOP, "TOP", 0, "Top", ""},
588 {RGN_ALIGN_BOTTOM, "BOTTOM", 0, "Bottom", ""},
589 {RGN_ALIGN_LEFT, "LEFT", 0, "Left", ""},
590 {RGN_ALIGN_RIGHT, "RIGHT", 0, "Right", ""},
591 {RGN_ALIGN_HSPLIT, "HORIZONTAL_SPLIT", 0, "Horizontal Split", ""},
592 {RGN_ALIGN_VSPLIT, "VERTICAL_SPLIT", 0, "Vertical Split", ""},
594 "FLOAT",
595 0,
596 "Float",
597 "Region floats on screen, does not use any fixed alignment"},
599 "QUAD_SPLIT",
600 0,
601 "Quad Split",
602 "Region is split horizontally and vertically"},
603 {0, nullptr, 0, nullptr, nullptr},
604 };
605
606 srna = RNA_def_struct(brna, "Region", nullptr);
607 RNA_def_struct_ui_text(srna, "Region", "Region in a subdivided screen area");
608 RNA_def_struct_sdna(srna, "ARegion");
609
610 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
611 RNA_def_property_enum_sdna(prop, nullptr, "regiontype");
614 RNA_def_property_ui_text(prop, "Region Type", "Type of this region");
615
616 prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
617 RNA_def_property_int_sdna(prop, nullptr, "winrct.xmin");
620 prop, "X Position", "The window relative vertical location of the region");
621
622 prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
623 RNA_def_property_int_sdna(prop, nullptr, "winrct.ymin");
626 prop, "Y Position", "The window relative horizontal location of the region");
627
628 prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
629 RNA_def_property_int_sdna(prop, nullptr, "winx");
631 RNA_def_property_ui_text(prop, "Width", "Region width");
632
633 prop = RNA_def_property(srna, "height", PROP_INT, PROP_UNSIGNED);
634 RNA_def_property_int_sdna(prop, nullptr, "winy");
636 RNA_def_property_ui_text(prop, "Height", "Region height");
637
638 prop = RNA_def_property(srna, "view2d", PROP_POINTER, PROP_NONE);
639 RNA_def_property_pointer_sdna(prop, nullptr, "v2d");
642 RNA_def_property_ui_text(prop, "View2D", "2D view of the region");
643
644 prop = RNA_def_property(srna, "alignment", PROP_ENUM, PROP_NONE);
646 RNA_def_property_enum_items(prop, alignment_types);
647 RNA_def_property_enum_funcs(prop, "rna_Region_alignment_get", nullptr, nullptr);
648 RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area");
649
650 prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
653 prop, "Region Data", "Region specific data (the type depends on the region type)");
654 RNA_def_property_struct_type(prop, "AnyType");
655 RNA_def_property_pointer_funcs(prop, "rna_Region_data_get", nullptr, nullptr, nullptr);
656
657 prop = RNA_def_property(srna, "active_panel_category", PROP_ENUM, PROP_NONE);
658 RNA_def_property_editable_func(prop, "rna_Region_active_panel_category_editable_get");
661 "rna_Region_active_panel_category_get",
662 "rna_Region_active_panel_category_set",
663 "rna_Region_active_panel_category_itemf");
665 prop,
666 "Active Panel Category",
667 "The current active panel category, may be Null if the region does not "
668 "support this feature (NOTE: these categories are generated at runtime, so list may be "
669 "empty at initialization, before any drawing took place)");
670
671 rna_def_region_api(srna);
672}
673
674static void rna_def_screen(BlenderRNA *brna)
675{
676 StructRNA *srna;
677 PropertyRNA *prop;
678
679 FunctionRNA *func;
680 PropertyRNA *parm;
681
682 srna = RNA_def_struct(brna, "Screen", "ID");
683 RNA_def_struct_sdna(srna, "Screen"); /* Actually #bScreen but for 2.5 the DNA is patched! */
685 srna, "Screen", "Screen data-block, defining the layout of areas in a window");
686 RNA_def_struct_ui_icon(srna, ICON_WORKSPACE);
687
688 /* collections */
689 prop = RNA_def_property(srna, "areas", PROP_COLLECTION, PROP_NONE);
690 RNA_def_property_collection_sdna(prop, nullptr, "areabase", nullptr);
691 RNA_def_property_struct_type(prop, "Area");
692 RNA_def_property_ui_text(prop, "Areas", "Areas the screen is subdivided into");
693
694 /* readonly status indicators */
695 prop = RNA_def_property(srna, "is_animation_playing", PROP_BOOLEAN, PROP_NONE);
697 RNA_def_property_boolean_funcs(prop, "rna_Screen_is_animation_playing_get", nullptr);
698 RNA_def_property_ui_text(prop, "Animation Playing", "Animation playback is active");
699
700 prop = RNA_def_property(srna, "is_scrubbing", PROP_BOOLEAN, PROP_NONE);
702 RNA_def_property_boolean_funcs(prop, "rna_Screen_is_scrubbing_get", nullptr);
704 prop, "User is Scrubbing", "True when the user is scrubbing through time");
705
706 prop = RNA_def_property(srna, "is_temporary", PROP_BOOLEAN, PROP_NONE);
708 RNA_def_property_boolean_sdna(prop, nullptr, "temp", 1);
709 RNA_def_property_ui_text(prop, "Temporary", "");
710
711 prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
713 RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", nullptr);
714 RNA_def_property_ui_text(prop, "Maximize", "An area is maximized, filling this screen");
715
716 /* Status Bar. */
717
718 prop = RNA_def_property(srna, "show_statusbar", PROP_BOOLEAN, PROP_NONE);
720 RNA_def_property_ui_text(prop, "Show Status Bar", "Show status bar");
721 RNA_def_property_update(prop, 0, "rna_Screen_bar_update");
722
723 func = RNA_def_function(srna, "statusbar_info", "rna_Screen_statusbar_info_get");
725 parm = RNA_def_string(func, "statusbar_info", nullptr, 0, "Status Bar Info", "");
726 RNA_def_function_return(func, parm);
727
728 /* Define Anim Playback Areas */
729 prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
730 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_REGION);
731 RNA_def_property_ui_text(prop, "Top-Left 3D Editor", "");
732 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
733
734 prop = RNA_def_property(srna, "use_play_3d_editors", PROP_BOOLEAN, PROP_NONE);
735 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_ALL_3D_WIN);
736 RNA_def_property_ui_text(prop, "All 3D Viewports", "");
737 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
738
739 prop = RNA_def_property(srna, "use_follow", PROP_BOOLEAN, PROP_NONE);
740 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_FOLLOW);
741 RNA_def_property_ui_text(prop, "Follow", "Follow current frame in editors");
742 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
743
744 prop = RNA_def_property(srna, "use_play_animation_editors", PROP_BOOLEAN, PROP_NONE);
745 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_ALL_ANIM_WIN);
746 RNA_def_property_ui_text(prop, "Animation Editors", "");
747 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
748
749 prop = RNA_def_property(srna, "use_play_properties_editors", PROP_BOOLEAN, PROP_NONE);
750 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_ALL_BUTS_WIN);
751 RNA_def_property_ui_text(prop, "Property Editors", "");
752 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
753
754 prop = RNA_def_property(srna, "use_play_image_editors", PROP_BOOLEAN, PROP_NONE);
755 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_ALL_IMAGE_WIN);
756 RNA_def_property_ui_text(prop, "Image Editors", "");
757 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
758
759 prop = RNA_def_property(srna, "use_play_sequence_editors", PROP_BOOLEAN, PROP_NONE);
760 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_SEQ);
761 RNA_def_property_ui_text(prop, "Sequencer Editors", "");
762 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
763
764 prop = RNA_def_property(srna, "use_play_node_editors", PROP_BOOLEAN, PROP_NONE);
765 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_NODES);
766 RNA_def_property_ui_text(prop, "Node Editors", "");
767 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
768
769 prop = RNA_def_property(srna, "use_play_clip_editors", PROP_BOOLEAN, PROP_NONE);
770 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_CLIPS);
771 RNA_def_property_ui_text(prop, "Clip Editors", "");
772 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
773
774 prop = RNA_def_property(srna, "use_play_spreadsheet_editors", PROP_BOOLEAN, PROP_NONE);
775 RNA_def_property_boolean_sdna(prop, nullptr, "redraws_flag", TIME_SPREADSHEETS);
776 RNA_def_property_ui_text(prop, "Spreadsheet Editors", "");
777 RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
778}
779
781{
782 rna_def_screen(brna);
783 rna_def_area(brna);
784 rna_def_region(brna);
785 rna_def_view2d(brna);
786}
787
788#endif
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
void CTX_wm_window_set(bContext *C, wmWindow *win)
Main * CTX_data_main(const bContext *C)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
#define G_MAIN
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
SpaceType * BKE_spacetype_from_id(int spaceid)
Definition screen.cc:257
ARegionType * BKE_regiontype_from_id(const SpaceType *st, int regionid)
Definition screen.cc:267
#define BLI_assert(a)
Definition BLI_assert.h:46
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
#define UNLIKELY(x)
#define ELEM(...)
void DEG_tag_on_visible_update(Main *bmain, bool do_time)
@ HEADER_NO_PULLDOWN
#define RGN_ALIGN_ENUM_FROM_MASK(align)
@ RGN_ALIGN_BOTTOM
@ RGN_ALIGN_LEFT
@ RGN_ALIGN_TOP
@ RGN_ALIGN_RIGHT
@ RGN_ALIGN_HSPLIT
@ RGN_ALIGN_VSPLIT
@ RGN_ALIGN_NONE
@ RGN_ALIGN_FLOAT
@ RGN_ALIGN_QSPLIT
@ SCREENFULL
@ SCREENMAXIMIZED
@ RGN_TYPE_CHANNELS
@ RGN_TYPE_TOOL_HEADER
@ RGN_TYPE_EXECUTE
@ RGN_TYPE_UI
@ RGN_TYPE_TEMPORARY
@ RGN_TYPE_ASSET_SHELF_HEADER
@ RGN_TYPE_WINDOW
@ RGN_TYPE_ASSET_SHELF
@ RGN_TYPE_HUD
@ RGN_TYPE_PREVIEW
@ RGN_TYPE_NAV_BAR
@ RGN_TYPE_FOOTER
@ RGN_TYPE_HEADER
@ RGN_TYPE_XR
@ RGN_TYPE_TOOLS
@ RGN_TYPE_TOOL_PROPS
@ SCREEN_COLLAPSE_STATUSBAR
@ TIME_SEQ
@ TIME_ALL_IMAGE_WIN
@ TIME_ALL_BUTS_WIN
@ TIME_FOLLOW
@ TIME_REGION
@ TIME_ALL_3D_WIN
@ TIME_SPREADSHEETS
@ TIME_CLIPS
@ TIME_NODES
@ TIME_ALL_ANIM_WIN
@ SPACE_STATUSBAR
@ SPACE_TOPBAR
@ SPACE_NODE
@ SPACE_EMPTY
@ SPACE_VIEW3D
const char * ED_info_statusbar_string(Main *bmain, Scene *scene, ViewLayer *view_layer)
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:693
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:647
void ED_area_newspace(bContext *C, ScrArea *area, int type, bool skip_region_exit)
Definition area.cc:2699
bScreen * ED_screen_animation_playing(const wmWindowManager *wm)
void ED_area_tag_refresh(ScrArea *area)
Definition area.cc:722
void ED_screen_animation_timer_update(bScreen *screen, int redraws)
ParameterFlag
Definition RNA_types.hh:544
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_USE_MAIN
Definition RNA_types.hh:912
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:913
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
PropertyFlag
Definition RNA_types.hh:300
@ PROP_THICK_WRAP
Definition RNA_types.hh:423
@ PROP_CONTEXT_UPDATE
Definition RNA_types.hh:407
@ PROP_ANIMATABLE
Definition RNA_types.hh:319
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_UNSIGNED
Definition RNA_types.hh:249
#define C
Definition RandGen.cpp:29
int UI_panel_category_index_find(ARegion *region, const char *idname)
void UI_panel_category_index_active_set(ARegion *region, const int index)
const char * UI_panel_category_active_get(ARegion *region, bool set_fallback)
bool UI_view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1702
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1668
void UI_view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
Definition view2d.cc:1723
#define NC_NODE
Definition WM_types.hh:394
#define ND_SPACE_TIME
Definition WM_types.hh:531
#define ND_NODE_GIZMO
Definition WM_types.hh:516
#define NC_SPACE
Definition WM_types.hh:392
void snode_set_context(const bContext &C)
Definition node_edit.cc:682
const PointerRNA PointerRNA_NULL
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const int *default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:26
static void rna_def_view2d(BlenderRNA *brna)
static void rna_def_area(BlenderRNA *brna)
static const EnumPropertyItem rna_enum_region_panel_category_items[]
Definition rna_screen.cc:41
static void rna_def_view2d_api(StructRNA *srna)
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:21
static void rna_def_region(BlenderRNA *brna)
static void rna_def_area_spaces(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_area_api(StructRNA *srna)
void RNA_def_screen(BlenderRNA *brna)
static void rna_def_screen(BlenderRNA *brna)
static void rna_def_region_api(StructRNA *srna)
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:73
#define FLT_MAX
Definition stdcycles.h:14
void * regiondata
ARegionRuntimeHandle * runtime
const char * identifier
Definition RNA_types.hh:657
const char * name
Definition RNA_types.hh:661
void * first
short butspacetype_subtype
struct SpaceType * type
int(* space_subtype_get)(ScrArea *area)
void(* space_subtype_item_extend)(bContext *C, EnumPropertyItem **item, int *totitem)
struct wmWindow * next
#define N_(msgid)
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4238
bScreen * WM_window_get_active_screen(const wmWindow *win)