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:
authorJulian Eisel <julian@blender.org>2020-12-08 15:47:37 +0300
committerJulian Eisel <julian@blender.org>2020-12-08 16:39:31 +0300
commit95b3c4c966f9baeb6f73b84568b7f03287e1a350 (patch)
tree2784106b67cc09bacb8b09865c03ebf337b98baa /source/blender/makesrna/intern
parent2a4fe88c13a1cb5bd79787e17eeaafec01c4d294 (diff)
File Browser: Refactor access to the selection parameters struct
* Avoid direct access to `SpaceFile.params`, use a getter instead. This matters because once the asset-browser changes are in, there will be an alternative selection parameter object. The getter can return the correct one. * Rename the function to ensure the parameters. The old name `ED_fileselect_get_params()` wasn't a mere getter, it would create the parameters if necessary. Now we have an actual getter, so better be clear. * In some instances, I replaced the old "get" function with the new mere getter. So the ensure logic is called less often. However, in these cases we should be able to assume the selection parameters were created already as part of the editor creation routine. The term "active" in the new function names may seem a bit odd in the current context, but that is a preparation for the Asset Browser merge as well. Like said, there will be two file selection parameter objects in the space.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_space.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index ff77819aae1..65ea155ffba 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2467,6 +2467,18 @@ static PointerRNA rna_FileSelectParams_filter_id_get(PointerRNA *ptr)
return rna_pointer_inherit_refine(ptr, &RNA_FileSelectIDFilter, ptr->data);
}
+static PointerRNA rna_FileBrowser_params_get(PointerRNA *ptr)
+{
+ SpaceFile *sfile = ptr->data;
+ FileSelectParams *params = ED_fileselect_get_active_params(sfile);
+
+ if (params) {
+ return rna_pointer_inherit_refine(ptr, &RNA_FileSelectParams, params);
+ }
+
+ return rna_pointer_inherit_refine(ptr, NULL, NULL);
+}
+
static void rna_FileBrowser_FSMenuEntry_path_get(PointerRNA *ptr, char *value)
{
char *path = ED_fsmenu_entry_get_path(ptr->data);
@@ -6043,7 +6055,8 @@ static void rna_def_space_filebrowser(BlenderRNA *brna)
rna_def_space_generic_show_region_toggles(srna, (1 << RGN_TYPE_TOOLS) | (1 << RGN_TYPE_UI));
prop = RNA_def_property(srna, "params", PROP_POINTER, PROP_NONE);
- RNA_def_property_pointer_sdna(prop, NULL, "params");
+ RNA_def_property_struct_type(prop, "FileSelectParams");
+ RNA_def_property_pointer_funcs(prop, "rna_FileBrowser_params_get", NULL, NULL, NULL);
RNA_def_property_ui_text(
prop, "Filebrowser Parameter", "Parameters and Settings for the Filebrowser");