diff options
author | Jacques Lucke <jacques@blender.org> | 2021-05-17 14:04:44 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-05-17 14:04:44 +0300 |
commit | c0c3e83cec22337f504456bfd3bfc32ca5f64f52 (patch) | |
tree | 2e56209afab467d1ce1095fa811fe377c87acdf0 | |
parent | 7378c6bb8608dd927f2b8a4603a6a0453ad49a90 (diff) |
add support for adding and removing attributes
-rw-r--r-- | release/scripts/startup/bl_ui/properties_data_mesh.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index c8c61bfbe29..f1efb59146f 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -581,6 +581,34 @@ class MESH_UL_attributes(UIList): sub.label(text=data_type.name) +class MESH_MT_add_attribute(Menu): + bl_label = "Add Attribute" + + @staticmethod + def add_standard_attribute(layout, mesh, name, data_type, domain): + exists = mesh.attributes.get(name) is not None + + col = layout.column() + col.enabled = not exists + col.operator_context = 'EXEC_DEFAULT' + + props = col.operator("geometry.attribute_add", text=name) + props.name = name + props.data_type = data_type + props.domain = domain + + def draw(self, context): + layout = self.layout + mesh = context.mesh + + self.add_standard_attribute(layout, mesh, 'scale', 'FLOAT_VECTOR', 'POINT') + + layout.separator() + + layout.operator_context = 'INVOKE_DEFAULT' + layout.operator("geometry.attribute_add", text="Custom...") + + class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel): bl_label = "Attributes" bl_options = {'DEFAULT_CLOSED'} @@ -588,9 +616,12 @@ class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel): def draw(self, context): mesh = context.mesh + layout = self.layout + row = layout.row() - layout.template_list( + col = row.column() + col.template_list( "MESH_UL_attributes", "attributes", mesh, @@ -600,6 +631,11 @@ class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel): rows=3, ) + col = row.column(align=True) + col.menu("MESH_MT_add_attribute", icon='ADD', text="") + col.operator("geometry.attribute_remove", icon='REMOVE', text="") + + classes = ( MESH_MT_vertex_group_context_menu, @@ -610,6 +646,7 @@ classes = ( MESH_UL_uvmaps, MESH_UL_vcols, MESH_UL_attributes, + MESH_MT_add_attribute, DATA_PT_context_mesh, DATA_PT_vertex_groups, DATA_PT_shape_keys, |