diff options
author | Hans Goudey <h.goudey@me.com> | 2022-05-31 14:20:16 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-05-31 14:20:16 +0300 |
commit | 4669178fc3786e1aebb117892d8dc6a2ce4dc955 (patch) | |
tree | 3680859a3b4337bd91669bd9a048afcbe46d6ba3 /release/scripts/startup/bl_ui | |
parent | 39c14f4e84c0813241659c9b56bef5a62d55e6c8 (diff) |
Attributes: Hide internal UI attributes and disallow procedural access
This commit hides "UI attributes" described in T97452 from the UI lists
in mesh, curve, and point cloud properties, and disallow accessing them
in geometry nodes.
Internal UI attributes like selection and hiding values should use the
attribute system for simplicity and performance, but we don't want to
expose those attributes in the attribute panel, which is meant for
regular user interaction. Procedural access may be misleading or cause
problems, as described in the design task above.
These attributes are added by two upcoming patches: D14934, D14685
Differential Revision: https://developer.blender.org/D15069
Diffstat (limited to 'release/scripts/startup/bl_ui')
3 files changed, 33 insertions, 2 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_curves.py b/release/scripts/startup/bl_ui/properties_data_curves.py index 4eefd5a0e0c..cf7117f2c85 100644 --- a/release/scripts/startup/bl_ui/properties_data_curves.py +++ b/release/scripts/startup/bl_ui/properties_data_curves.py @@ -78,6 +78,16 @@ class CURVES_MT_add_attribute(Menu): class CURVES_UL_attributes(UIList): + def filter_items(self, context, data, property): + attributes = getattr(data, property) + flags = [] + indices = [i for i in range(len(attributes))] + + for index, item in enumerate(attributes): + flags.append(self.bitflag_filter_item if item.is_internal else 0) + + return flags, indices + def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index): data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type] domain = attribute.bl_rna.properties['domain'].enum_items[attribute.domain] diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 050bf56966f..d46ba31c960 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -497,6 +497,16 @@ class MESH_UL_attributes(UIList): 'CORNER': "Face Corner", } + def filter_items(self, context, data, property): + attributes = getattr(data, property) + flags = [] + indices = [i for i in range(len(attributes))] + + for index, item in enumerate(attributes): + flags.append(self.bitflag_filter_item if item.is_internal else 0) + + return flags, indices + def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index): data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type] @@ -576,7 +586,7 @@ class ColorAttributesListBase(): 'CORNER': "Face Corner", } - def filter_items(self, _context, data, property): + def filter_items(self, context, data, property): attrs = getattr(data, property) ret = [] idxs = [] @@ -584,7 +594,8 @@ class ColorAttributesListBase(): for idx, item in enumerate(attrs): skip = ( (item.domain not in {"POINT", "CORNER"}) or - (item.data_type not in {"FLOAT_COLOR", "BYTE_COLOR"}) + (item.data_type not in {"FLOAT_COLOR", "BYTE_COLOR"}) or + (not item.is_internal) ) ret.append(self.bitflag_filter_item if not skip else 0) idxs.append(idx) diff --git a/release/scripts/startup/bl_ui/properties_data_pointcloud.py b/release/scripts/startup/bl_ui/properties_data_pointcloud.py index 4f065a9ecfb..88d686b32f9 100644 --- a/release/scripts/startup/bl_ui/properties_data_pointcloud.py +++ b/release/scripts/startup/bl_ui/properties_data_pointcloud.py @@ -67,6 +67,16 @@ class POINTCLOUD_MT_add_attribute(Menu): class POINTCLOUD_UL_attributes(UIList): + def filter_items(self, context, data, property): + attributes = getattr(data, property) + flags = [] + indices = [i for i in range(len(attributes))] + + for index, item in enumerate(attributes): + flags.append(self.bitflag_filter_item if item.is_internal else 0) + + return flags, indices + def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index): data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type] |