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
This commit is contained in:
parent
095b363899
commit
405dd143cf
Notes:
blender-bot
2023-02-13 13:55:09 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #102878, Regression: UI texpaintslot/color attributes/attributes name filtering broken
|
@ -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
|
||||
|
||||
|
|
|
@ -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))]
|
||||
|
||||
for idx, item in enumerate(attrs):
|
||||
# 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(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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue