[Bf-blender-cvs] [997ff54d309] master: Fix: UI: broken texpaintslot/color attributes/attributes name filtering
Philipp Oeser
noreply at git.blender.org
Tue Dec 6 11:12:06 CET 2022
Commit: 997ff54d309fece665de3de65b40c2f093df96f0
Author: Philipp Oeser
Date: Fri Dec 2 12:50:00 2022 +0100
Branches: master
https://developer.blender.org/rB997ff54d309fece665de3de65b40c2f093df96f0
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 e4473cf461f..e390b9cb6d4 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -537,8 +537,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
@@ -626,20 +634,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 a2fbd81593b..1141d7e75a4 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -1033,6 +1033,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);
More information about the Bf-blender-cvs
mailing list