Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_constraint.py
| Show All 15 Lines | |||||
| # | # | ||||
| # ##### END GPL LICENSE BLOCK ##### | # ##### END GPL LICENSE BLOCK ##### | ||||
| # <pep8 compliant> | # <pep8 compliant> | ||||
| import bpy | import bpy | ||||
| from bpy.types import Panel | from bpy.types import Panel | ||||
| def target_is_bbone(con): | |||||
| try: | |||||
| return con.target.data.bones[con.subtarget].bbone_segments > 1 | |||||
| except KeyError: | |||||
| return False | |||||
| def should_show_head_tail(con): | |||||
| if con.type not in {'CHILD_OF', 'COPY_ROTATION', 'COPY_SCALE'}: | |||||
| return True | |||||
| return con.head_tail > 0 or con.use_bbone_shape or target_is_bbone(con) | |||||
| class ConstraintButtonsPanel: | class ConstraintButtonsPanel: | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_context = "constraint" | bl_context = "constraint" | ||||
| def draw_constraint(self, context, con): | def draw_constraint(self, context, con): | ||||
| layout = self.layout | layout = self.layout | ||||
| Show All 27 Lines | class ConstraintButtonsPanel: | ||||
| @staticmethod | @staticmethod | ||||
| def target_template(layout, con, subtargets=True): | def target_template(layout, con, subtargets=True): | ||||
| layout.prop(con, "target") # XXX limiting settings for only 'curves' or some type of object | layout.prop(con, "target") # XXX limiting settings for only 'curves' or some type of object | ||||
| if con.target and subtargets: | if con.target and subtargets: | ||||
| if con.target.type == 'ARMATURE': | if con.target.type == 'ARMATURE': | ||||
| layout.prop_search(con, "subtarget", con.target.data, "bones", text="Bone") | layout.prop_search(con, "subtarget", con.target.data, "bones", text="Bone") | ||||
| if hasattr(con, "head_tail"): | if hasattr(con, "head_tail") and should_show_head_tail(con): | ||||
| row = layout.row(align=True) | row = layout.row(align=True) | ||||
| row.label(text="Head/Tail:") | row.label(text="Head/Tail:") | ||||
| row.prop(con, "head_tail", text="") | row.prop(con, "head_tail", text="") | ||||
| row.prop(con, "use_bbone_shape", text="", icon='IPO_BEZIER') # XXX icon, and only when bone has segments? | row.prop(con, "use_bbone_shape", text="", icon='IPO_BEZIER') # XXX icon, and only when bone has segments? | ||||
| elif con.target.type in {'MESH', 'LATTICE'}: | elif con.target.type in {'MESH', 'LATTICE'}: | ||||
| layout.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group") | layout.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group") | ||||
| @staticmethod | @staticmethod | ||||
| ▲ Show 20 Lines • Show All 878 Lines • Show Last 20 Lines | |||||