PyAPI: expose the popup region in the context

Expose the region used for a temporary popup to the context so it's
possible for scripts to access the popup-region they're being drawn in.

Note that the internal naming is currently "menu" which is misleading
as these are used for all kinds of dialogs & popups. The RNA member is
called `region_popup` in this commit,
we could consider changing the name internally too.

Needed so it's possible for scripts to access the splash screen
so it can be refreshed, see: #120612.
This commit is contained in:
Campbell Barton
2024-05-09 12:49:36 +10:00
parent fa27d2fe65
commit 742a8b47cd

View File

@@ -120,6 +120,13 @@ static PointerRNA rna_Context_region_data_get(PointerRNA *ptr)
return PointerRNA_NULL;
}
static PointerRNA rna_Context_menu_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
PointerRNA newptr = RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Region, CTX_wm_menu(C));
return newptr;
}
static PointerRNA rna_Context_gizmo_group_get(PointerRNA *ptr)
{
bContext *C = (bContext *)ptr->data;
@@ -273,6 +280,13 @@ void RNA_def_context(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "Region");
RNA_def_property_pointer_funcs(prop, "rna_Context_region_get", nullptr, nullptr, nullptr);
prop = RNA_def_property(srna, "region_popup", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Region");
RNA_def_property_pointer_funcs(prop, "rna_Context_menu_get", nullptr, nullptr, nullptr);
RNA_def_property_ui_text(
prop, "Popup Region", "The temporary region for pop-ups (including menus and pop-overs)");
prop = RNA_def_property(srna, "region_data", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "RegionView3D");