[Bf-blender-cvs] [5c19f236358] modifier-panels-ui: Patch 3

Hans Goudey noreply at git.blender.org
Mon Apr 27 23:38:23 CEST 2020


Commit: 5c19f236358eaef559e66a66a05d05fe0fee4a76
Author: Hans Goudey
Date:   Wed Apr 22 17:22:31 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rB5c19f236358eaef559e66a66a05d05fe0fee4a76

Patch 3

===================================================================

M	release/scripts/startup/bl_ui/properties_constraint.py
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/draw/engines/overlay/overlay_extra.c
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/object/object_constraint.c
M	source/blender/editors/object/object_intern.h
M	source/blender/editors/object/object_ops.c
M	source/blender/makesdna/DNA_constraint_types.h
M	source/blender/makesrna/intern/rna_constraint.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..ebc41645b11 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -20,49 +20,72 @@
 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'}
 
-    @staticmethod
-    def space_template(layout, con, target=True, owner=True):
-        if target or owner:
+    @classmethod
+    def poll(cls, context):
+        return (context.pose_bone)
 
-            split = layout.split(factor=0.2)
+    def draw(self, context):
+        layout = self.layout
 
-            split.label(text="Space:")
-            row = split.row()
+        layout.operator_menu_enum("pose.constraint_add", "type", text="Add Bone Constraint")
 
-            if target:
-                row.prop(con, "target_space", text="")
+        layout.template_constraints()
+
+
+class ConstraintButtonsPanel(Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_label = ""
+    bl_context = "constraint"
+    bl_options = {'LIST', 'HEADER_LAYOUT_EXPAND'}
 
-            if target and owner:
-                row.label(icon='ARROW_LEFTRIGHT')
+    @staticmethod
+    def draw_influence(layout, con):
+        layout.separator()
+        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):
+        if target or owner:
+            layout.separator()
+            if target:
+                layout.prop(con, "target_space", text="Target")
             if owner:
-                row.prop(con, "owner_space", text="")
+                layout.prop(con, "owner_space", text="Owner")
 
     @staticmethod
     def target_template(layout, con, subtargets=True):
@@ -102,47 +125,95 @@ class ConstraintButtonsPanel:
         col = split.column()
         col.prop(con, "chain_count")
 
-    def CHILD_OF(self, _context, layout, con):
-        self.target_template(layout, con)
+    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
 
-        split = layout.split()
+    def draw_header(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
 
-        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")
+        layout.template_constraint_header(con)
 
-        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")
+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"
+
+    def draw(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+        layout.use_property_split = True
+        layout.use_property_decorate = True
+        
+        self.target_template(layout, con)
+
+        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")
         row.operator("constraint.childof_clear_inverse")
 
-    def TRACK_TO(self, _context, layout, con):
-        self.target_template(layout, con)
+        self.draw_influence(layout, con)
 
-        row = layout.row()
-        row.label(text="To:")
-        row.prop(con, "track_axis", expand=True)
 
-        row = layout.row()
-        row.prop(con, "up_axis", text="Up")
-        row.prop(con, "use_target_z")
+class OBJECT_PT_bTrackToConstraint(ConstraintButtonsPanel):
+
+    def draw(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+        layout.use_property_split = True
+        layout.use_property_decorate = True
+
+        self.target_template(layout, con)
+
+        layout.prop(con, "track_axis", expand=True)
+        layout.prop(con, "up_axis", text="Up", expand=True)
+        layout.prop(con, "use_target_z")
 
         self.space_template(layout, con)
 
-    def IK(self, context, layout, con):
+        self.draw_influence(layout, con)
+
+# No option to add this in the UI ?
+class OBJECT_PT_bKinematicConstraint(ConstraintButtonsPanel):
+
+    def draw(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+
         if context.object.pose.ik_solver == 'ITASC':
             layout.prop(con, "ik_type")
             getattr(self, 'IK_' + con.ik_type)(context, layout, con)
@@ -185,7 +256,16 @@ 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)
+
+
+# Unreachable in UI
+class OBJECT_PT_constraints_ik_copy_pose(ConstraintButtonsPanel):
+
+    def draw(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+        
         self.target_template(layout, con)
         self.ik_template(layout, con)
 
@@ -220,7 +300,16 @@ 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)
+
+
+# Not currently accessible in UI
+class OBJECT_PT_constraints_ik_distance(ConstraintButtonsPanel):
+
+    def draw(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+
         self.target_template(layout, con)
         self.ik_template(layout, con)
 
@@ -230,344 +319,428 @@ 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.target_template(layout, con)
-        layout.operator("constraint.followpath_path_animate", text="Animate Path", icon='ANIM_DATA')
+        self.draw_influence(layout, con)
 
-        split = layout.split()
 
-        col = split.column()
-        col.prop(con, "use_curve_follow")
-        col.prop(con, "use_curve_radius")
+class OBJECT_PT_bFollowPathConstraint(ConstraintButtonsPanel):
 
-        col = split.column()
-        col.prop(con, "use_fixed_location")
+    def draw(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+        layout.use_property_split = True
+        layout.use_property_decorate = True
+
+        layout.prop(con, "use_curve_follow")
+        layout.prop(con, "use_curve_radius")
+
+        layout.prop(con, "use_fixed_location")
         if con.use_fixed_location:
-      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list