[Bf-blender-cvs] [d9f542bbb03] modifier-panels-ui: Initial implementation of constraint panels
Hans Goudey
noreply at git.blender.org
Sat Apr 18 22:12:07 CEST 2020
Commit: d9f542bbb03ef5705dc2a0ae26dc7e90ebb9bfe2
Author: Hans Goudey
Date: Sat Apr 18 15:11:57 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rBd9f542bbb03ef5705dc2a0ae26dc7e90ebb9bfe2
Initial implementation of constraint panels
The layouts are still defined in python, but they are each in a separate
panel. They are named and searched for with the constraint type info
struct names.
This commit does not change the layout for any of the constraints.
===================================================================
M release/scripts/startup/bl_ui/properties_constraint.py
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_panel.c
M source/blender/editors/interface/interface_templates.c
M source/blender/makesrna/intern/rna_ui_api.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 3fc54ff6d12..82d4c5002ea 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -20,31 +20,61 @@
from bpy.types import Panel
-class ConstraintButtonsPanel:
+class OBJECT_PT_constraints(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
+ bl_label = "Object Constraints"
bl_context = "constraint"
+ bl_options = {'LIST_START', 'HIDE_HEADER'}
- def draw_constraint(self, context, con):
+ @classmethod
+ def poll(cls, context):
+ return (context.object)
+
+ def draw(self, context):
layout = self.layout
- box = layout.template_constraint(con)
+ layout.operator_menu_enum("object.constraint_add", "type", text="Add Object Constraint")
- if box:
- # match enum type to our functions, avoids a lookup table.
- getattr(self, con.type)(context, box, con)
+ layout.template_constraints()
- if con.type in {'RIGID_BODY_JOINT', 'NULL'}:
- return
- if con.type in {'IK', 'SPLINE_IK'}:
- # constraint.disable_keep_transform doesn't work well
- # for these constraints.
- box.prop(con, "influence")
- else:
- row = box.row(align=True)
- row.prop(con, "influence")
- row.operator("constraint.disable_keep_transform", text="", icon='CANCEL')
+class BONE_PT_constraints(Panel):
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_label = "Bone Constraints"
+ bl_context = "bone_constraint"
+ bl_options = {'LIST_START', 'HIDE_HEADER'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.pose_bone)
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.operator_menu_enum("pose.constraint_add", "type", text="Add Bone Constraint")
+
+ layout.template_constraints()
+
+
+class ConstraintButtonsPanel:
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_label = ""
+ bl_context = "constraint"
+
+ @staticmethod
+ def draw_influence(layout, con):
+ if con.type in {'IK', 'SPLINE_IK'}:
+ # constraint.disable_keep_transform doesn't work well
+ # for these constraints.
+ layout.prop(con, "influence")
+ else:
+ row = layout.row(align=True)
+ row.prop(con, "influence")
+ row.operator("constraint.disable_keep_transform", text="", icon='CANCEL')
+
@staticmethod
def space_template(layout, con, target=True, owner=True):
@@ -102,7 +132,28 @@ class ConstraintButtonsPanel:
col = split.column()
col.prop(con, "chain_count")
- def CHILD_OF(self, _context, layout, con):
+ @staticmethod
+ def get_constraint(context, index):
+ if context.pose_bone:
+ return context.bose_bone.constraints[index]
+ else:
+ return context.active_object.constraints[index]
+
+ def draw_header(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
+ layout.template_constraint_header(con)
+
+
+class OBJECT_PT_bChildOfConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
split = layout.split()
@@ -129,7 +180,17 @@ class ConstraintButtonsPanel:
row.operator("constraint.childof_set_inverse")
row.operator("constraint.childof_clear_inverse")
- def TRACK_TO(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bTrackToConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
row = layout.row()
@@ -142,7 +203,17 @@ class ConstraintButtonsPanel:
self.space_template(layout, con)
- def IK(self, context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bKinematicConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
if context.object.pose.ik_solver == 'ITASC':
layout.prop(con, "ik_type")
getattr(self, 'IK_' + con.ik_type)(context, layout, con)
@@ -185,7 +256,18 @@ class ConstraintButtonsPanel:
sub.active = con.use_rotation
sub.prop(con, "orient_weight", text="Rotation", slider=True)
- def IK_COPY_POSE(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+# HANS-TODO: Find constraint type info name
+class OBJECT_PT_constraints_ik_copy_pose(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
self.ik_template(layout, con)
@@ -220,7 +302,18 @@ class ConstraintButtonsPanel:
row.prop(con, "lock_rotation_z", text="Z")
split.active = con.use_rotation
- def IK_DISTANCE(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+# HANS-TODO: Find constraint type info name
+class OBJECT_PT_constraints_ik_distance(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
self.ik_template(layout, con)
@@ -230,7 +323,17 @@ class ConstraintButtonsPanel:
row.prop(con, "weight", text="Weight", slider=True)
row.prop(con, "distance", text="Distance", slider=True)
- def FOLLOW_PATH(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bFollowPathConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
layout.operator("constraint.followpath_path_animate", text="Animate Path", icon='ANIM_DATA')
@@ -255,7 +358,17 @@ class ConstraintButtonsPanel:
row.prop(con, "up_axis", text="Up")
row.label()
- def LIMIT_ROTATION(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bRotLimitConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
split = layout.split()
col = split.column(align=True)
@@ -285,7 +398,17 @@ class ConstraintButtonsPanel:
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
- def LIMIT_LOCATION(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bLocLimitConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
split = layout.split()
col = split.column()
@@ -326,7 +449,17 @@ class ConstraintButtonsPanel:
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
- def LIMIT_SCALE(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bSizeLimitConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
split = layout.split()
col = split.column()
@@ -367,7 +500,17 @@ class ConstraintButtonsPanel:
row.label(text="Convert:")
row.prop(con, "owner_space", text="")
- def COPY_ROTATION(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bRotateLikeConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
layout.prop(con, "euler_order", text="Order")
@@ -396,7 +539,17 @@ class ConstraintButtonsPanel:
self.space_template(layout, con)
- def COPY_LOCATION(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bLocateLikeConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
split = layout.split()
@@ -423,7 +576,17 @@ class ConstraintButtonsPanel:
self.space_template(layout, con)
- def COPY_SCALE(self, _context, layout, con):
+ self.draw_influence(layout, con)
+
+
+class OBJECT_PT_bSizeLikeConstraint(ConstraintButtonsPanel, Panel):
+ bl_context = "constraint"
+ bl_options = {'LIST'}
+
+ def draw(self, context):
+ layout = self.layout
+ con = self.get_constraint(context, self.list_panel_index)
+
self.target_template(layout, con)
row = layout.row(align=True)
@@ -442,7 +605,16 @@ class
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list