Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-02-27 08:17:01 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-02-27 08:30:07 +0300
commit9cfb320208b655a1d7f177f038179b87d98fb066 (patch)
treeea480bd7d7078353a1bcb0e8ea272f630edb3d9d
parentf7933d0744df44c132f8b07b2cb2a8dea13fb30b (diff)
RNA: add Region.data member to access RegionView3D
Without this, the RegionView3D could only be accessed from `context.region_data`, not the region.
-rw-r--r--source/blender/makesrna/intern/rna_screen.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_screen.c b/source/blender/makesrna/intern/rna_screen.c
index 784172b3ac9..6cf1d7a923b 100644
--- a/source/blender/makesrna/intern/rna_screen.c
+++ b/source/blender/makesrna/intern/rna_screen.c
@@ -56,6 +56,8 @@ const EnumPropertyItem rna_enum_region_type_items[] = {
#ifdef RNA_RUNTIME
+# include "RNA_access.h"
+
# include "BKE_global.h"
# include "BKE_screen.h"
# include "BKE_workspace.h"
@@ -274,6 +276,25 @@ static void rna_Area_ui_type_update(bContext *C, PointerRNA *ptr)
ED_area_tag_refresh(area);
}
+static PointerRNA rna_Region_data_get(PointerRNA *ptr)
+{
+ bScreen *screen = (bScreen *)ptr->owner_id;
+ ARegion *region = ptr->data;
+
+ if (region->regiondata != NULL) {
+ if (region->regiontype == RGN_TYPE_WINDOW) {
+ /* We could make this static, it wont change at run-time. */
+ SpaceType *st = BKE_spacetype_from_id(SPACE_VIEW3D);
+ if (region->type == BKE_regiontype_from_id(st, region->regiontype)) {
+ PointerRNA newptr;
+ RNA_pointer_create(&screen->id, &RNA_RegionView3D, region->regiondata, &newptr);
+ return newptr;
+ }
+ }
+ }
+ return PointerRNA_NULL;
+}
+
static void rna_View2D_region_to_view(struct View2D *v2d, float x, float y, float result[2])
{
UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
@@ -539,6 +560,13 @@ static void rna_def_region(BlenderRNA *brna)
RNA_def_property_enum_funcs(prop, "rna_region_alignment_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Alignment", "Alignment of the region within the area");
+ prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_ui_text(
+ prop, "Region Data", "Region specific data (the type depends on the region type)");
+ RNA_def_property_struct_type(prop, "AnyType");
+ RNA_def_property_pointer_funcs(prop, "rna_Region_data_get", NULL, NULL, NULL);
+
RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
}