[Bf-blender-cvs] [9cfb320208b] master: RNA: add Region.data member to access RegionView3D
Campbell Barton
noreply at git.blender.org
Sat Feb 27 06:30:25 CET 2021
Commit: 9cfb320208b655a1d7f177f038179b87d98fb066
Author: Campbell Barton
Date: Sat Feb 27 16:17:01 2021 +1100
Branches: master
https://developer.blender.org/rB9cfb320208b655a1d7f177f038179b87d98fb066
RNA: add Region.data member to access RegionView3D
Without this, the RegionView3D could only be accessed from
`context.region_data`, not the region.
===================================================================
M source/blender/makesrna/intern/rna_screen.c
===================================================================
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");
}
More information about the Bf-blender-cvs
mailing list