[Bf-blender-cvs] [f787b7f1cad] modifier-panels-ui: Rework UI layouts for Transform Constraints
Hans Goudey
noreply at git.blender.org
Sun Apr 19 07:45:22 CEST 2020
Commit: f787b7f1cad1cdb5b02df4e70c80553b9b08f19d
Author: Hans Goudey
Date: Sun Apr 19 00:45:09 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rBf787b7f1cad1cdb5b02df4e70c80553b9b08f19d
Rework UI layouts for Transform Constraints
Update layouts to 2.8 style, which is generally a huge improvement
for legibility and consistency. Doesn't touch decorators, there are still
issues there.
Also deduplicate some code by using a class for all parent
constraint panel and all constraint subpanels.
===================================================================
M release/scripts/startup/bl_ui/properties_constraint.py
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_constraint.py b/release/scripts/startup/bl_ui/properties_constraint.py
index 82d4c5002ea..91b817792f4 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -58,11 +58,12 @@ class BONE_PT_constraints(Panel):
layout.template_constraints()
-class ConstraintButtonsPanel:
+class ConstraintButtonsPanel(Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_label = ""
bl_context = "constraint"
+ bl_options = {'LIST'}
@staticmethod
def draw_influence(layout, con):
@@ -79,20 +80,10 @@ class ConstraintButtonsPanel:
@staticmethod
def space_template(layout, con, target=True, owner=True):
if target or owner:
-
- split = layout.split(factor=0.2)
-
- split.label(text="Space:")
- row = split.row()
-
if target:
- row.prop(con, "target_space", text="")
-
- if target and owner:
- row.label(icon='ARROW_LEFTRIGHT')
-
+ layout.prop(con, "target_space")
if owner:
- row.prop(con, "owner_space", text="")
+ layout.prop(con, "owner_space")
@staticmethod
def target_template(layout, con, subtargets=True):
@@ -132,49 +123,62 @@ class ConstraintButtonsPanel:
col = split.column()
col.prop(con, "chain_count")
- @staticmethod
- def get_constraint(context, index):
+ def get_constraint(self, context):
+ con = None
if context.pose_bone:
- return context.bose_bone.constraints[index]
+ con = context.bose_bone.constraints[self.list_panel_index]
else:
- return context.active_object.constraints[index]
+ con = context.active_object.constraints[self.list_panel_index]
+ self.layout.context_pointer_set("constraint", con)
+ return con
def draw_header(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
layout.template_constraint_header(con)
-class OBJECT_PT_bChildOfConstraint(ConstraintButtonsPanel, Panel):
+class ConstraintButtonsSubPanel(Panel):
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_label = ""
+ bl_context = "constraint"
+ bl_options = {'LIST_SUBPANEL'}
+
+ def get_constraint(self, context):
+ con = None
+ if context.pose_bone:
+ con = context.bose_bone.constraints[self.list_panel_index]
+ else:
+ con = context.active_object.constraints[self.list_panel_index]
+ self.layout.context_pointer_set("constraint", con)
+ return con
+
+
+class OBJECT_PT_bChildOfConstraint(ConstraintButtonsPanel):
bl_context = "constraint"
- bl_options = {'LIST'}
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
+ layout.use_property_split = True
+ layout.use_property_decorate = True
self.target_template(layout, con)
- split = layout.split()
-
- col = split.column()
- col.label(text="Location:")
- col.prop(con, "use_location_x", text="X")
- col.prop(con, "use_location_y", text="Y")
- col.prop(con, "use_location_z", text="Z")
-
- col = split.column()
- col.label(text="Rotation:")
- col.prop(con, "use_rotation_x", text="X")
- col.prop(con, "use_rotation_y", text="Y")
- col.prop(con, "use_rotation_z", text="Z")
-
- col = split.column()
- col.label(text="Scale:")
- col.prop(con, "use_scale_x", text="X")
- col.prop(con, "use_scale_y", text="Y")
- col.prop(con, "use_scale_z", text="Z")
+ row = layout.row(heading="Location")
+ row.prop(con, "use_location_x", text="X", toggle=True)
+ row.prop(con, "use_location_y", text="Y", toggle=True)
+ row.prop(con, "use_location_z", text="Z", toggle=True)
+ row = layout.row(heading="Rotation")
+ row.prop(con, "use_rotation_x", text="X", toggle=True)
+ row.prop(con, "use_rotation_y", text="Y", toggle=True)
+ row.prop(con, "use_rotation_z", text="Z", toggle=True)
+ row = layout.row(heading="Scale")
+ row.prop(con, "use_scale_x", text="X", toggle=True)
+ row.prop(con, "use_scale_y", text="Y", toggle=True)
+ row.prop(con, "use_scale_z", text="Z", toggle=True)
row = layout.row()
row.operator("constraint.childof_set_inverse")
@@ -183,13 +187,11 @@ class OBJECT_PT_bChildOfConstraint(ConstraintButtonsPanel, Panel):
self.draw_influence(layout, con)
-class OBJECT_PT_bTrackToConstraint(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_bTrackToConstraint(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
self.target_template(layout, con)
@@ -206,13 +208,11 @@ class OBJECT_PT_bTrackToConstraint(ConstraintButtonsPanel, Panel):
self.draw_influence(layout, con)
-class OBJECT_PT_bKinematicConstraint(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_bKinematicConstraint(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
if context.object.pose.ik_solver == 'ITASC':
layout.prop(con, "ik_type")
@@ -260,13 +260,11 @@ class OBJECT_PT_bKinematicConstraint(ConstraintButtonsPanel, Panel):
# HANS-TODO: Find constraint type info name
-class OBJECT_PT_constraints_ik_copy_pose(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_constraints_ik_copy_pose(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
self.target_template(layout, con)
self.ik_template(layout, con)
@@ -306,13 +304,11 @@ class OBJECT_PT_constraints_ik_copy_pose(ConstraintButtonsPanel, Panel):
# HANS-TODO: Find constraint type info name
-class OBJECT_PT_constraints_ik_distance(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_constraints_ik_distance(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
self.target_template(layout, con)
self.ik_template(layout, con)
@@ -326,13 +322,11 @@ class OBJECT_PT_constraints_ik_distance(ConstraintButtonsPanel, Panel):
self.draw_influence(layout, con)
-class OBJECT_PT_bFollowPathConstraint(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_bFollowPathConstraint(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
self.target_template(layout, con)
layout.operator("constraint.followpath_path_animate", text="Animate Path", icon='ANIM_DATA')
@@ -361,179 +355,167 @@ class OBJECT_PT_bFollowPathConstraint(ConstraintButtonsPanel, Panel):
self.draw_influence(layout, con)
-class OBJECT_PT_bRotLimitConstraint(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_bRotLimitConstraint(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
+ layout.use_property_split = True
+ layout.use_property_decorate = True
- split = layout.split()
- col = split.column(align=True)
- col.prop(con, "use_limit_x")
- sub = col.column(align=True)
+ row = layout.row(heading="Limit X", align=True)
+ row.prop(con, "use_limit_x", text="")
+ sub = row.column(align=True)
sub.active = con.use_limit_x
sub.prop(con, "min_x", text="Min")
sub.prop(con, "max_x", text="Max")
- col = split.column(align=True)
- col.prop(con, "use_limit_y")
- sub = col.column(align=True)
+ row = layout.row(heading="Y", align=True)
+ row.prop(con, "use_limit_y", text="")
+ sub = row.column(align=True)
sub.active = con.use_limit_y
sub.prop(con, "min_y", text="Min")
sub.prop(con, "max_y", text="Max")
- col = split.column(align=True)
- col.prop(con, "use_limit_z")
- sub = col.column(align=True)
+ row = layout.row(heading="Z", align=True)
+ row.prop(con, "use_limit_z", text="")
+ sub = row.column(align=True)
sub.active = con.use_limit_z
sub.prop(con, "min_z", text="Min")
sub.prop(con, "max_z", text="Max")
layout.prop(con, "use_transform_limit")
-
- row = layout.row()
- row.label(text="Convert:")
- row.prop(con, "owner_space", text="")
+ layout.prop(con, "owner_space")
self.draw_influence(layout, con)
-class OBJECT_PT_bLocLimitConstraint(ConstraintButtonsPanel, Panel):
- bl_context = "constraint"
- bl_options = {'LIST'}
+class OBJECT_PT_bLocLimitConstraint(ConstraintButtonsPanel):
def draw(self, context):
layout = self.layout
- con = self.get_constraint(context, self.list_panel_index)
+ con = self.get_constraint(context)
+ layout.use_property_split = True
+ layout.use_property_decorate = True
- split = layout.split()
-
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list