[Bf-blender-cvs] [405dd143cf2] blender-v3.3-release: Fix: UI: broken texpaintslot/color attributes/attributes name filtering
Philipp Oeser
noreply at git.blender.org
Thu Jan 12 22:26:58 CET 2023
Commit: 405dd143cf22b3798060f8c2c706c1a51b828491
Author: Philipp Oeser
Date: Fri Dec 2 12:50:00 2022 +0100
Branches: blender-v3.3-release
https://developer.blender.org/rB405dd143cf22b3798060f8c2c706c1a51b828491
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 c07fabd9554..4d4c3ce88ad 100644
--- a/release/scripts/startup/bl_ui/properties_data_curves.py
+++ b/release/scripts/startup/bl_ui/properties_data_curves.py
@@ -82,8 +82,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 617065fe156..e0a2c246d6d 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -521,8 +521,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
@@ -609,20 +617,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 2ecba7a826d..2e6976dfdc7 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);
More information about the Bf-blender-cvs
mailing list