Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_space.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 2,610 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static uint64_t rna_FileAssetSelectParams_asset_category_get(PointerRNA *ptr) | static uint64_t rna_FileAssetSelectParams_asset_category_get(PointerRNA *ptr) | ||||
| { | { | ||||
| FileSelectParams *params = ptr->data; | FileSelectParams *params = ptr->data; | ||||
| return params->filter_id; | return params->filter_id; | ||||
| } | } | ||||
| static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr) | |||||
| { | |||||
| const FileDirEntry *entry = ptr->data; | |||||
| /* Note that the owning ID of the RNA pointer (`ptr->owner_id`) has to be set carefully: | |||||
| * Local IDs (`entry->id`) own their asset metadata themselves. Asset metadata from other blend | |||||
sybren: This comment is a bit hard to follow. How's this?
Local IDs (`entry->id`) own their own… | |||||
Done Inline ActionsI think this can be made even clearer, so extended your proposal a bit. Severin: I think this can be made even clearer, so extended your proposal a bit. | |||||
| * files are owned by the file browser (`entry`). Only if this is set correctly, we can tell from | |||||
| * the metadata RNA pointer if the metadata is stored locally and can thus be edited or not. */ | |||||
| if (entry->id) { | |||||
| PointerRNA id_ptr; | |||||
| RNA_id_pointer_create(entry->id, &id_ptr); | |||||
| return rna_pointer_inherit_refine(&id_ptr, &RNA_AssetMetaData, entry->asset_data); | |||||
| } | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_AssetMetaData, entry->asset_data); | |||||
| } | |||||
| static int rna_FileBrowser_FileSelectEntry_name_editable(PointerRNA *ptr, const char **r_info) | |||||
| { | |||||
| const FileDirEntry *entry = ptr->data; | |||||
| /* This actually always returns 0 (the name is never editable) but we want to get a disabled | |||||
| * message returned to `r_info` in some cases. */ | |||||
| if (entry->asset_data) { | |||||
| PointerRNA asset_data_ptr = rna_FileBrowser_FileSelectEntry_asset_data_get(ptr); | |||||
Done Inline ActionsWhy bother with two return statements if the same value is always returned, by design? sybren: Why bother with two return statements if the same value is always returned, by design? | |||||
| /* Get disabled hint from asset metadata polling. */ | |||||
| rna_AssetMetaData_editable(&asset_data_ptr, r_info); | |||||
| } | |||||
| return 0; | |||||
| } | |||||
| static void rna_FileBrowser_FileSelectEntry_name_get(PointerRNA *ptr, char *value) | static void rna_FileBrowser_FileSelectEntry_name_get(PointerRNA *ptr, char *value) | ||||
| { | { | ||||
| const FileDirEntry *entry = ptr->data; | const FileDirEntry *entry = ptr->data; | ||||
| strcpy(value, entry->name); | strcpy(value, entry->name); | ||||
| } | } | ||||
| static int rna_FileBrowser_FileSelectEntry_name_length(PointerRNA *ptr) | static int rna_FileBrowser_FileSelectEntry_name_length(PointerRNA *ptr) | ||||
| { | { | ||||
| Show All 40 Lines | |||||
| } | } | ||||
| static int rna_FileBrowser_FileSelectEntry_preview_icon_id_get(PointerRNA *ptr) | static int rna_FileBrowser_FileSelectEntry_preview_icon_id_get(PointerRNA *ptr) | ||||
| { | { | ||||
| const FileDirEntry *entry = ptr->data; | const FileDirEntry *entry = ptr->data; | ||||
| return ED_file_icon(entry); | return ED_file_icon(entry); | ||||
| } | } | ||||
| static PointerRNA rna_FileBrowser_FileSelectEntry_asset_data_get(PointerRNA *ptr) | |||||
| { | |||||
| const FileDirEntry *entry = ptr->data; | |||||
| return rna_pointer_inherit_refine(ptr, &RNA_AssetMetaData, entry->asset_data); | |||||
| } | |||||
| static StructRNA *rna_FileBrowser_params_typef(PointerRNA *ptr) | static StructRNA *rna_FileBrowser_params_typef(PointerRNA *ptr) | ||||
| { | { | ||||
| SpaceFile *sfile = ptr->data; | SpaceFile *sfile = ptr->data; | ||||
| FileSelectParams *params = ED_fileselect_get_active_params(sfile); | FileSelectParams *params = ED_fileselect_get_active_params(sfile); | ||||
| if (params == ED_fileselect_get_file_params(sfile)) { | if (params == ED_fileselect_get_file_params(sfile)) { | ||||
| return &RNA_FileSelectParams; | return &RNA_FileSelectParams; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,566 Lines • ▼ Show 20 Lines | |||||
| static void rna_def_fileselect_entry(BlenderRNA *brna) | static void rna_def_fileselect_entry(BlenderRNA *brna) | ||||
| { | { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| StructRNA *srna = RNA_def_struct(brna, "FileSelectEntry", NULL); | StructRNA *srna = RNA_def_struct(brna, "FileSelectEntry", NULL); | ||||
| RNA_def_struct_sdna(srna, "FileDirEntry"); | RNA_def_struct_sdna(srna, "FileDirEntry"); | ||||
| RNA_def_struct_ui_text(srna, "File Select Entry", "A file viewable in the File Browser"); | RNA_def_struct_ui_text(srna, "File Select Entry", "A file viewable in the File Browser"); | ||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | ||||
| RNA_def_property_editable_func(prop, "rna_FileBrowser_FileSelectEntry_name_editable"); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_string_funcs(prop, | RNA_def_property_string_funcs(prop, | ||||
| "rna_FileBrowser_FileSelectEntry_name_get", | "rna_FileBrowser_FileSelectEntry_name_get", | ||||
| "rna_FileBrowser_FileSelectEntry_name_length", | "rna_FileBrowser_FileSelectEntry_name_length", | ||||
| NULL); | NULL); | ||||
| RNA_def_property_ui_text(prop, "Name", ""); | RNA_def_property_ui_text(prop, "Name", ""); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_struct_name_property(srna, prop); | RNA_def_struct_name_property(srna, prop); | ||||
| prop = RNA_def_property(srna, "relative_path", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "relative_path", PROP_STRING, PROP_NONE); | ||||
| RNA_def_property_string_funcs(prop, | RNA_def_property_string_funcs(prop, | ||||
| "rna_FileBrowser_FileSelectEntry_relative_path_get", | "rna_FileBrowser_FileSelectEntry_relative_path_get", | ||||
| "rna_FileBrowser_FileSelectEntry_relative_path_length", | "rna_FileBrowser_FileSelectEntry_relative_path_length", | ||||
| NULL); | NULL); | ||||
| RNA_def_property_ui_text(prop, | RNA_def_property_ui_text(prop, | ||||
| ▲ Show 20 Lines • Show All 1,524 Lines • Show Last 20 Lines | |||||
This comment is a bit hard to follow. How's this?
Local IDs (entry->id) own their own metadata, which can be edited. Asset metadata from other blend files are owned by the file browser (entry), and are not editable.