Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-02-07 20:55:54 +0300
committerHans Goudey <h.goudey@me.com>2022-02-07 20:56:48 +0300
commitfe1816f67fbc6aaf383ec77847d668367335d093 (patch)
treeb89fc16a38a498c8b8ca96f9c50ee1a765d167fe /release/scripts/startup/bl_ui/properties_data_curves.py
parentb8c764c5d1fa241a284b985936a96efe0ee23a0f (diff)
Curves: Rename "Hair" types, variables, and functions to "Curves"
Based on discussions from T95355 and T94193, the plan is to use the name "Curves" to describe the data-block container for multiple curves. Eventually this will replace the existing "Curve" data-block. However, it will be a while before the curve data-block can be replaced so in order to distinguish the two curve types in the UI, "Hair Curves" will be used, but eventually changed back to "Curves". This patch renames "hair-related" files, functions, types, and variable names to this convention. A deep rename is preferred to keep code consistent and to avoid any "hair" terminology from leaking, since the new data-block is meant for all curve types, not just hair use cases. The downside of this naming is that the difference between "Curve" and "Curves" has become important. That was considered during design discussons and deemed acceptable, especially given the non-permanent nature of the somewhat common conflict. Some points of interest: - All DNA compatibility is lost, just like rBf59767ff9729. - I renamed `ID_HA` to `ID_CV` so there is no complete mismatch. - `hair_curves` is used where necessary to distinguish from the existing "curves" plural. - I didn't rename any of the cycles/rendering code function names, since that is also used by the old hair particle system. Differential Revision: https://developer.blender.org/D14007
Diffstat (limited to 'release/scripts/startup/bl_ui/properties_data_curves.py')
-rw-r--r--release/scripts/startup/bl_ui/properties_data_curves.py142
1 files changed, 142 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/properties_data_curves.py b/release/scripts/startup/bl_ui/properties_data_curves.py
new file mode 100644
index 00000000000..0b4bf0283ed
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_data_curves.py
@@ -0,0 +1,142 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import Menu, Panel, UIList
+from rna_prop_ui import PropertyPanel
+
+
+class DataButtonsPanel:
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_context = "data"
+
+ @classmethod
+ def poll(cls, context):
+ engine = context.scene.render.engine
+ return hasattr(context, 'curves') and context.curves and (engine in cls.COMPAT_ENGINES)
+
+
+class DATA_PT_context_curves(DataButtonsPanel, Panel):
+ bl_label = ""
+ bl_options = {'HIDE_HEADER'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+ def draw(self, context):
+ layout = self.layout
+
+ ob = context.object
+ curves = context.curves
+ space = context.space_data
+
+ if ob:
+ layout.template_ID(ob, "data")
+ elif curves:
+ layout.template_ID(space, "pin_id")
+
+
+class CURVES_MT_add_attribute(Menu):
+ bl_label = "Add Attribute"
+
+ @staticmethod
+ def add_standard_attribute(layout, curves, name, data_type, domain):
+ exists = curves.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
+ curves = context.curves
+
+ self.add_standard_attribute(layout, curves, 'radius', 'FLOAT', 'POINT')
+ self.add_standard_attribute(layout, curves, 'color', 'FLOAT_COLOR', 'POINT')
+
+ layout.separator()
+
+ layout.operator_context = 'INVOKE_DEFAULT'
+ layout.operator("geometry.attribute_add", text="Custom...")
+
+
+class CURVES_UL_attributes(UIList):
+ 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]
+
+ split = layout.split(factor=0.5)
+ split.emboss = 'NONE'
+ row = split.row()
+ row.prop(attribute, "name", text="")
+ sub = split.split()
+ sub.alignment = 'RIGHT'
+ sub.active = False
+ sub.label(text=domain.name)
+ sub.label(text=data_type.name)
+
+
+class DATA_PT_CURVES_attributes(DataButtonsPanel, Panel):
+ bl_label = "Attributes"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+ def draw(self, context):
+ curves = context.curves
+
+ layout = self.layout
+ row = layout.row()
+
+ col = row.column()
+ col.template_list(
+ "CURVES_UL_attributes",
+ "attributes",
+ curves,
+ "attributes",
+ curves.attributes,
+ "active_index",
+ rows=3,
+ )
+
+ col = row.column(align=True)
+ col.menu("CURVES_MT_add_attribute", icon='ADD', text="")
+ col.operator("geometry.attribute_remove", icon='REMOVE', text="")
+
+
+class DATA_PT_custom_props_curves(DataButtonsPanel, PropertyPanel, Panel):
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+ _context_path = "object.data"
+ _property_type = bpy.types.Curves if hasattr(bpy.types, "Curves") else None
+
+
+classes = (
+ DATA_PT_context_curves,
+ DATA_PT_CURVES_attributes,
+ DATA_PT_custom_props_curves,
+ CURVES_MT_add_attribute,
+ CURVES_UL_attributes,
+)
+
+if __name__ == "__main__": # only for live edit.
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)