Commit: 08d687e8cdaf15a087bfab42ae9b731742d1ce72 Author: Philipp Oeser Date: Fri Dec 2 12:50:00 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB08d687e8cdaf15a087bfab42ae9b731742d1ce72
Fix: UI: broken texpaintslot/color attributes/attributes name filtering rB8b7cd1ed2a17 broke this for the paint slots rB4669178fc378 broke this for regular attributes Name filtering in UI Lists works when: - [one] the items to be filtered have a name property -- see how `uilist_filter_items_default` gets the `namebuf` - [two] custom python filter functions (`filter_items`) implement it themselves -- if you use `filter_items` and dont do name filtering there, the default name filtering wont be used So, two problems with rB8b7cd1ed2a17: - [1] items to be listed changed from `texture_paint_images` to `texture_paint_slots` -- the former has name_property defined, the later lacks this - [2] the new `ColorAttributesListBase` defined a `filter_items` function, but did not implement name filtering And the problem with rB4669178fc378: - it added `filter_items` functions, but did not implement name filtering. These are all corrected now. Fixes T102878 Maniphest Tasks: T102878 Differential Revision: https://developer.blender.org/D16676 =================================================================== M release/scripts/startup/bl_ui/properties_data_curves.py M release/scripts/startup/bl_ui/properties_data_mesh.py M release/scripts/startup/bl_ui/properties_data_pointcloud.py M source/blender/makesrna/intern/rna_material.c =================================================================== diff --git a/release/scripts/startup/bl_ui/properties_data_curves.py b/release/scripts/startup/bl_ui/properties_data_curves.py index f71296e98f9..1a353d8d9d5 100644 --- a/release/scripts/startup/bl_ui/properties_data_curves.py +++ b/release/scripts/startup/bl_ui/properties_data_curves.py @@ -88,8 +88,16 @@ class CURVES_UL_attributes(UIList): flags = [] indices = [i for i in range(len(attributes))] - for item in attributes: - flags.append(0 if item.is_internal else self.bitflag_filter_item) + # Filtering by name + if self.filter_name: + flags = bpy.types.UI_UL_list.filter_items_by_name( + self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert) + if not flags: + flags = [self.bitflag_filter_item] * len(attributes) + + # Filtering internal attributes + for idx, item in enumerate(attributes): + flags[idx] = 0 if item.is_internal else flags[idx] return flags, indices diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index ee10203908f..0eb9557b989 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -535,8 +535,16 @@ class MESH_UL_attributes(UIList): flags = [] indices = [i for i in range(len(attributes))] - for item in attributes: - flags.append(0 if item.is_internal else self.bitflag_filter_item) + # Filtering by name + if self.filter_name: + flags = bpy.types.UI_UL_list.filter_items_by_name( + self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert) + if not flags: + flags = [self.bitflag_filter_item] * len(attributes) + + # Filtering internal attributes + for idx, item in enumerate(attributes): + flags[idx] = 0 if item.is_internal else flags[idx] return flags, indices @@ -624,20 +632,26 @@ class ColorAttributesListBase(): } def filter_items(self, _context, data, property): - attrs = getattr(data, property) - ret = [] - idxs = [] + attributes = getattr(data, property) + flags = [] + indices = [i for i in range(len(attributes))] + + # Filtering by name + if self.filter_name: + flags = bpy.types.UI_UL_list.filter_items_by_name( + self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert) + if not flags: + flags = [self.bitflag_filter_item] * len(attributes) - for idx, item in enumerate(attrs): + for idx, item in enumerate(attributes): skip = ( (item.domain not in {"POINT", "CORNER"}) or (item.data_type not in {"FLOAT_COLOR", "BYTE_COLOR"}) or item.is_internal ) - ret.append(0 if skip else self.bitflag_filter_item) - idxs.append(idx) + flags[idx] = 0 if skip else flags[idx] - return ret, idxs + return flags, indices class MESH_UL_color_attributes(UIList, ColorAttributesListBase): diff --git a/release/scripts/startup/bl_ui/properties_data_pointcloud.py b/release/scripts/startup/bl_ui/properties_data_pointcloud.py index 6e12a3e8fb2..09639e9d69b 100644 --- a/release/scripts/startup/bl_ui/properties_data_pointcloud.py +++ b/release/scripts/startup/bl_ui/properties_data_pointcloud.py @@ -70,8 +70,16 @@ class POINTCLOUD_UL_attributes(UIList): flags = [] indices = [i for i in range(len(attributes))] - for item in attributes: - flags.append(0 if item.is_internal else self.bitflag_filter_item) + # Filtering by name + if self.filter_name: + flags = bpy.types.UI_UL_list.filter_items_by_name( + self.filter_name, self.bitflag_filter_item, attributes, "name", reverse=self.use_filter_invert) + if not flags: + flags = [self.bitflag_filter_item] * len(attributes) + + # Filtering internal attributes + for idx, item in enumerate(attributes): + flags[idx] = 0 if item.is_internal else flags[idx] return flags, indices diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 837bf9888f4..bc5a8294245 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1052,6 +1052,7 @@ static void rna_def_tex_slot(BlenderRNA *brna) RNA_def_property_string_funcs( prop, "rna_TexPaintSlot_name_get", "rna_TexPaintSlot_name_length", NULL); RNA_def_property_ui_text(prop, "Name", "Name of the slot"); + RNA_def_struct_name_property(srna, prop); prop = RNA_def_property(srna, "icon_value", PROP_INT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs