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