diff options
author | Brecht Van Lommel <brecht> | 2020-03-03 19:21:28 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-03-03 19:34:21 +0300 |
commit | 2841b2be3949b7592b50cd2ebd03b9b32a5f2058 (patch) | |
tree | 36b583a61bdf14150b8061d3f349610d781696de /source/blender/makesrna | |
parent | 19785b96c43f6dc19906f4b39a18a656684826b1 (diff) |
IDs: change FILTER_ID_* to 64 bit to make space for new ID types
And change file browser to boolean from bitflag enum, which is only 32 bit.
Differential Revision: https://developer.blender.org/D7004
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 221 |
1 files changed, 124 insertions, 97 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 762c1985fa9..63817137a02 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2329,6 +2329,11 @@ static void rna_FileSelectPrams_filter_glob_set(PointerRNA *ptr, const char *val BLI_path_extension_glob_validate(params->filter_glob); } +static PointerRNA rna_FileSelectParams_filter_id_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_FileSelectIDFilter, ptr->data); +} + static void rna_FileBrowser_FSMenuEntry_path_get(PointerRNA *ptr, char *value) { char *path = ED_fsmenu_entry_get_path(ptr->data); @@ -5328,139 +5333,169 @@ static void rna_def_space_console(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Output", "Command output"); } -static void rna_def_fileselect_params(BlenderRNA *brna) +/* Filter for datablock types in link/append. */ +static void rna_def_fileselect_idfilter(BlenderRNA *brna) { - StructRNA *srna; - PropertyRNA *prop; - - static const EnumPropertyItem file_display_items[] = { - {FILE_VERTICALDISPLAY, - "LIST_VERTICAL", - ICON_LONGDISPLAY, - "Vertical List", - "Display files as a vertical list"}, - {FILE_HORIZONTALDISPLAY, - "LIST_HORIZONTAL", - ICON_SHORTDISPLAY, - "Horizontal List", - "Display files as a horizontal list"}, - {FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, - {0, NULL, 0, NULL, NULL}, + struct IDFilterBoolean { + /* 64 bit, so we can't use bitflag enum. */ + const uint64_t flag; + const char *identifier; + const int icon; + const char *name; + const char *description; }; - static const EnumPropertyItem display_size_items[] = { - {64, "TINY", 0, "Tiny", ""}, - {96, "SMALL", 0, "Small", ""}, - {128, "NORMAL", 0, "Regular", ""}, - {192, "LARGE", 0, "Large", ""}, - {0, NULL, 0, NULL, NULL}, - }; - - static const EnumPropertyItem file_filter_idtypes_items[] = { - {FILTER_ID_AC, "ACTION", ICON_ANIM_DATA, "Actions", "Show/hide Action data-blocks"}, + static const struct IDFilterBoolean booleans[] = { + /* Datablocks */ + {FILTER_ID_AC, "filter_action", ICON_ANIM_DATA, "Actions", "Show Action data-blocks"}, {FILTER_ID_AR, - "ARMATURE", + "filter_armature", ICON_ARMATURE_DATA, "Armatures", - "Show/hide Armature data-blocks"}, - {FILTER_ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brushes", "Show/hide Brushes data-blocks"}, - {FILTER_ID_CA, "CAMERA", ICON_CAMERA_DATA, "Cameras", "Show/hide Camera data-blocks"}, - {FILTER_ID_CF, "CACHEFILE", ICON_FILE, "Cache Files", "Show/hide Cache File data-blocks"}, - {FILTER_ID_CU, "CURVE", ICON_CURVE_DATA, "Curves", "Show/hide Curve data-blocks"}, + "Show Armature data-blocks"}, + {FILTER_ID_BR, "filter_brush", ICON_BRUSH_DATA, "Brushes", "Show Brushes data-blocks"}, + {FILTER_ID_CA, "filter_camera", ICON_CAMERA_DATA, "Cameras", "Show Camera data-blocks"}, + {FILTER_ID_CF, "filter_cachefile", ICON_FILE, "Cache Files", "Show Cache File data-blocks"}, + {FILTER_ID_CU, "filter_curve", ICON_CURVE_DATA, "Curves", "Show Curve data-blocks"}, {FILTER_ID_GD, - "GREASE_PENCIL", + "filter_grease_pencil", ICON_GREASEPENCIL, "Grease Pencil", - "Show/hide Grease pencil data-blocks"}, - {FILTER_ID_GR, "GROUP", ICON_GROUP, "Collections", "Show/hide Collection data-blocks"}, - {FILTER_ID_IM, "IMAGE", ICON_IMAGE_DATA, "Images", "Show/hide Image data-blocks"}, - {FILTER_ID_LA, "LIGHT", ICON_LIGHT_DATA, "Lights", "Show/hide Light data-blocks"}, + "Show Grease pencil data-blocks"}, + {FILTER_ID_GR, "filter_group", ICON_GROUP, "Collections", "Show Collection data-blocks"}, + {FILTER_ID_IM, "filter_image", ICON_IMAGE_DATA, "Images", "Show Image data-blocks"}, + {FILTER_ID_LA, "filter_light", ICON_LIGHT_DATA, "Lights", "Show Light data-blocks"}, {FILTER_ID_LS, - "LINESTYLE", + "filter_linestyle", ICON_LINE_DATA, "Freestyle Linestyles", - "Show/hide Freestyle's Line Style data-blocks"}, - {FILTER_ID_LT, "LATTICE", ICON_LATTICE_DATA, "Lattices", "Show/hide Lattice data-blocks"}, + "Show Freestyle's Line Style data-blocks"}, + {FILTER_ID_LT, "filter_lattice", ICON_LATTICE_DATA, "Lattices", "Show Lattice data-blocks"}, {FILTER_ID_MA, - "MATERIAL", + "filter_material", ICON_MATERIAL_DATA, "Materials", - "Show/hide Material data-blocks"}, - {FILTER_ID_MB, "METABALL", ICON_META_DATA, "Metaballs", "Show/hide Metaball data-blocks"}, + "Show Material data-blocks"}, + {FILTER_ID_MB, "filter_metaball", ICON_META_DATA, "Metaballs", "Show Metaball data-blocks"}, {FILTER_ID_MC, - "MOVIE_CLIP", + "filter_movie_clip", ICON_TRACKER_DATA, "Movie Clips", - "Show/hide Movie Clip data-blocks"}, - {FILTER_ID_ME, "MESH", ICON_MESH_DATA, "Meshes", "Show/hide Mesh data-blocks"}, - {FILTER_ID_MSK, "MASK", ICON_MOD_MASK, "Masks", "Show/hide Mask data-blocks"}, - {FILTER_ID_NT, "NODE_TREE", ICON_NODETREE, "Node Trees", "Show/hide Node Tree data-blocks"}, - {FILTER_ID_OB, "OBJECT", ICON_OBJECT_DATA, "Objects", "Show/hide Object data-blocks"}, + "Show Movie Clip data-blocks"}, + {FILTER_ID_ME, "filter_mesh", ICON_MESH_DATA, "Meshes", "Show Mesh data-blocks"}, + {FILTER_ID_MSK, "filter_mask", ICON_MOD_MASK, "Masks", "Show Mask data-blocks"}, + {FILTER_ID_NT, + "filter_node_tree", + ICON_NODETREE, + "Node Trees", + "Show Node Tree data-blocks"}, + {FILTER_ID_OB, "filter_object", ICON_OBJECT_DATA, "Objects", "Show Object data-blocks"}, {FILTER_ID_PA, - "PARTICLE_SETTINGS", + "filter_particle_settings", ICON_PARTICLE_DATA, "Particles Settings", - "Show/hide Particle Settings data-blocks"}, - {FILTER_ID_PAL, "PALETTE", ICON_COLOR, "Palettes", "Show/hide Palette data-blocks"}, + "Show Particle Settings data-blocks"}, + {FILTER_ID_PAL, "filter_palette", ICON_COLOR, "Palettes", "Show Palette data-blocks"}, {FILTER_ID_PC, - "PAINT_CURVE", + "filter_paint_curve", ICON_CURVE_BEZCURVE, "Paint Curves", - "Show/hide Paint Curve data-blocks"}, + "Show Paint Curve data-blocks"}, {FILTER_ID_LP, - "LIGHT_PROBE", + "filter_light_probe", ICON_OUTLINER_DATA_LIGHTPROBE, "Light Probes", - "Show/hide Light Probe data-blocks"}, - {FILTER_ID_SCE, "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide Scene data-blocks"}, - {FILTER_ID_SPK, "SPEAKER", ICON_SPEAKER, "Speakers", "Show/hide Speaker data-blocks"}, - {FILTER_ID_SO, "SOUND", ICON_SOUND, "Sounds", "Show/hide Sound data-blocks"}, - {FILTER_ID_TE, "TEXTURE", ICON_TEXTURE_DATA, "Textures", "Show/hide Texture data-blocks"}, - {FILTER_ID_TXT, "TEXT", ICON_TEXT, "Texts", "Show/hide Text data-blocks"}, - {FILTER_ID_VF, "FONT", ICON_FONT_DATA, "Fonts", "Show/hide Font data-blocks"}, - {FILTER_ID_WO, "WORLD", ICON_WORLD_DATA, "Worlds", "Show/hide World data-blocks"}, + "Show Light Probe data-blocks"}, + {FILTER_ID_SCE, "filter_scene", ICON_SCENE_DATA, "Scenes", "Show Scene data-blocks"}, + {FILTER_ID_SPK, "filter_speaker", ICON_SPEAKER, "Speakers", "Show Speaker data-blocks"}, + {FILTER_ID_SO, "filter_sound", ICON_SOUND, "Sounds", "Show Sound data-blocks"}, + {FILTER_ID_TE, "filter_texture", ICON_TEXTURE_DATA, "Textures", "Show Texture data-blocks"}, + {FILTER_ID_TXT, "filter_text", ICON_TEXT, "Texts", "Show Text data-blocks"}, + {FILTER_ID_VF, "filter_font", ICON_FONT_DATA, "Fonts", "Show Font data-blocks"}, + {FILTER_ID_WO, "filter_world", ICON_WORLD_DATA, "Worlds", "Show World data-blocks"}, {FILTER_ID_WS, - "WORK_SPACE", + "filter_work_space", ICON_WORKSPACE, "Workspaces", - "Show/hide workspace data-blocks"}, - {0, NULL, 0, NULL, NULL}, - }; + "Show workspace data-blocks"}, - static const EnumPropertyItem file_filter_idcategories_items[] = { - {FILTER_ID_SCE, "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide scenes"}, - {FILTER_ID_AC, "ANIMATION", ICON_ANIM_DATA, "Animations", "Show/hide animation data"}, + /* Categories */ + {FILTER_ID_SCE, "category_scene", ICON_SCENE_DATA, "Scenes", "Show scenes"}, + {FILTER_ID_AC, "category_animation", ICON_ANIM_DATA, "Animations", "Show animation data"}, {FILTER_ID_OB | FILTER_ID_GR, - "OBJECT", + "category_object", ICON_GROUP, "Objects & Collections", - "Show/hide objects and groups"}, + "Show objects and groups"}, {FILTER_ID_AR | FILTER_ID_CU | FILTER_ID_LT | FILTER_ID_MB | FILTER_ID_ME, - "GEOMETRY", + "category_geometry", ICON_MESH_DATA, "Geometry", - "Show/hide meshes, curves, lattice, armatures and metaballs data"}, + "Show meshes, curves, lattice, armatures and metaballs data"}, {FILTER_ID_LS | FILTER_ID_MA | FILTER_ID_NT | FILTER_ID_TE, - "SHADING", + "category_shading", ICON_MATERIAL_DATA, "Shading", - "Show/hide materials, nodetrees, textures and Freestyle's linestyles"}, + "Show materials, nodetrees, textures and Freestyle's linestyles"}, {FILTER_ID_IM | FILTER_ID_MC | FILTER_ID_MSK | FILTER_ID_SO, - "IMAGE", + "category_image", ICON_IMAGE_DATA, "Images & Sounds", - "Show/hide images, movie clips, sounds and masks"}, - {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS, - "ENVIRONMENT", + "Show images, movie clips, sounds and masks"}, + {FILTER_ID_CA | FILTER_ID_LA | FILTER_ID_LP | FILTER_ID_SPK | FILTER_ID_WO | FILTER_ID_WS, + "category_environment", ICON_WORLD_DATA, "Environment", - "Show/hide worlds, lights, cameras and speakers"}, + "Show worlds, lights, cameras and speakers"}, {FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF | FILTER_ID_CF, - "MISC", + "category_misc", ICON_GREASEPENCIL, "Miscellaneous", - "Show/hide other data types"}, + "Show other data types"}, + + {0, NULL, 0, NULL, NULL}}; + + StructRNA *srna = RNA_def_struct(brna, "FileSelectIDFilter", NULL); + RNA_def_struct_sdna(srna, "FileSelectParams"); + RNA_def_struct_nested(brna, srna, "FileSelectParams"); + RNA_def_struct_ui_text( + srna, "File Select ID Filter", "Which ID types to show/hide, when browsing a library"); + + for (int i = 0; booleans[i].identifier; i++) { + PropertyRNA *prop = RNA_def_property(srna, booleans[i].identifier, PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "filter_id", booleans[i].flag); + RNA_def_property_ui_text(prop, booleans[i].name, booleans[i].description); + RNA_def_property_ui_icon(prop, booleans[i].icon, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + } +} + +static void rna_def_fileselect_params(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static const EnumPropertyItem file_display_items[] = { + {FILE_VERTICALDISPLAY, + "LIST_VERTICAL", + ICON_LONGDISPLAY, + "Vertical List", + "Display files as a vertical list"}, + {FILE_HORIZONTALDISPLAY, + "LIST_HORIZONTAL", + ICON_SHORTDISPLAY, + "Horizontal List", + "Display files as a horizontal list"}, + {FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, + {0, NULL, 0, NULL, NULL}, + }; + + static const EnumPropertyItem display_size_items[] = { + {64, "TINY", 0, "Tiny", ""}, + {96, "SMALL", 0, "Small", ""}, + {128, "NORMAL", 0, "Regular", ""}, + {192, "LARGE", 0, "Large", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -5602,21 +5637,12 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_BLENDER, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); - prop = RNA_def_property(srna, "filter_id", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "filter_id"); - RNA_def_property_enum_items(prop, file_filter_idtypes_items); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); + prop = RNA_def_property(srna, "filter_id", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_struct_type(prop, "FileSelectIDFilter"); + RNA_def_property_pointer_funcs(prop, "rna_FileSelectParams_filter_id_get", NULL, NULL, NULL); RNA_def_property_ui_text( prop, "Filter ID Types", "Which ID types to show/hide, when browsing a library"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); - - prop = RNA_def_property(srna, "filter_id_category", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "filter_id"); - RNA_def_property_enum_items(prop, file_filter_idcategories_items); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); - RNA_def_property_ui_text( - prop, "Filter ID Categories", "Which ID categories to show/hide, when browsing a library"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); prop = RNA_def_property(srna, "filter_glob", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "filter_glob"); @@ -6445,6 +6471,7 @@ void RNA_def_space(BlenderRNA *brna) rna_def_space_sequencer(brna); rna_def_space_text(brna); rna_def_fileselect_params(brna); + rna_def_fileselect_idfilter(brna); rna_def_filemenu_entry(brna); rna_def_space_filebrowser(brna); rna_def_space_outliner(brna); |