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