Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/properties_constraint.py
| Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | def target_template(layout, con, subtargets=True): | ||||
| sub.prop(con, "head_tail") | sub.prop(con, "head_tail") | ||||
| # XXX icon, and only when bone has segments? | # XXX icon, and only when bone has segments? | ||||
| sub.prop(con, "use_bbone_shape", text="", icon='IPO_BEZIER') | sub.prop(con, "use_bbone_shape", text="", icon='IPO_BEZIER') | ||||
| row.prop_decorator(con, "head_tail") | row.prop_decorator(con, "head_tail") | ||||
| elif con.target.type in {'MESH', 'LATTICE'}: | elif con.target.type in {'MESH', 'LATTICE'}: | ||||
| col.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group") | col.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group") | ||||
| def get_constraint(self, context): | def get_constraint(self, context): | ||||
| con = None | con = self.custom_data | ||||
Severin: I think this is fine, for objects we use `object.data`, but `custom_data` makes more sense to… | |||||
| if context.pose_bone: | |||||
| con = context.pose_bone.constraints[self.list_panel_index] | |||||
| else: | |||||
| con = context.object.constraints[self.list_panel_index] | |||||
| self.layout.context_pointer_set("constraint", con) | self.layout.context_pointer_set("constraint", con) | ||||
| return con | return con | ||||
| def draw_header(self, context): | def draw_header(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| con = self.get_constraint(context) | con = self.get_constraint(context) | ||||
| layout.template_constraint_header(con) | layout.template_constraint_header(con) | ||||
| ▲ Show 20 Lines • Show All 828 Lines • ▼ Show 20 Lines | |||||
| # Parent class for constraint subpanels | # Parent class for constraint subpanels | ||||
| class ConstraintButtonsSubPanel(Panel): | class ConstraintButtonsSubPanel(Panel): | ||||
| bl_space_type = 'PROPERTIES' | bl_space_type = 'PROPERTIES' | ||||
| bl_region_type = 'WINDOW' | bl_region_type = 'WINDOW' | ||||
| bl_label = "" | bl_label = "" | ||||
| bl_options = {'DRAW_BOX'} | bl_options = {'DRAW_BOX'} | ||||
| def get_constraint(self, context): | def get_constraint(self, context): | ||||
| con = None | con = self.custom_data | ||||
| if context.pose_bone: | |||||
| con = context.pose_bone.constraints[self.list_panel_index] | |||||
| else: | |||||
| con = context.object.constraints[self.list_panel_index] | |||||
| self.layout.context_pointer_set("constraint", con) | self.layout.context_pointer_set("constraint", con) | ||||
| return con | return con | ||||
| def draw_transform_from(self, context): | def draw_transform_from(self, context): | ||||
| layout = self.layout | layout = self.layout | ||||
| con = self.get_constraint(context) | con = self.get_constraint(context) | ||||
| layout.prop(con, "map_from", expand=True) | layout.prop(con, "map_from", expand=True) | ||||
| ▲ Show 20 Lines • Show All 677 Lines • Show Last 20 Lines | |||||
I think this is fine, for objects we use object.data, but custom_data makes more sense to me in this context. I'm not totally sure though, there may be better ways to go about this. @Campbell Barton (campbellbarton) any opinion?