[Bf-blender-cvs] [eaa44afe703] master: UI: Drag and Drop Constraints, Layout Updates

Hans Goudey noreply at git.blender.org
Fri Jun 19 18:40:53 CEST 2020


Commit: eaa44afe703eeb785f4590719b39392b66d6a312
Author: Hans Goudey
Date:   Fri Jun 19 12:40:48 2020 -0400
Branches: master
https://developer.blender.org/rBeaa44afe703eeb785f4590719b39392b66d6a312

UI: Drag and Drop Constraints, Layout Updates

This patch implements the list panel system D7490 for constraints.
In this case the panels are still defined in Python.

The layouts are also updated to use subpanels and the a more organized
single column layout. There may be more tweaks necessary for the
layouts.

Reviewed By: Severin, billreynish, Mets

Differential Revision: https://developer.blender.org/D7499

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

M	release/scripts/startup/bl_ui/properties_constraint.py
M	source/blender/blenkernel/BKE_constraint.h
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_panel.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..04d43c28c27 100644
--- a/release/scripts/startup/bl_ui/properties_constraint.py
+++ b/release/scripts/startup/bl_ui/properties_constraint.py
@@ -20,894 +20,753 @@
 from bpy.types import Panel
 
 
-class ConstraintButtonsPanel:
+class ObjectConstraintPanel(Panel):
+    bl_context = "constraint"
+
+    @classmethod
+    def poll(cls, context):
+        return (context.object)
+
+
+class BoneConstraintPanel(Panel):
+    bl_context = "bone_constraint"
+
+    @classmethod
+    def poll(cls, context):
+        return (context.pose_bone)
+
+
+class OBJECT_PT_constraints(ObjectConstraintPanel):
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
-    bl_context = "constraint"
+    bl_label = "Object Constraints"
+    bl_options = {'HIDE_HEADER'}
 
-    def draw_constraint(self, context, con):
+    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(use_bone_constraints=False)
 
-            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(BoneConstraintPanel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_label = "Bone Constraints"
+    bl_options = {'HIDE_HEADER'}
 
-    @staticmethod
-    def space_template(layout, con, target=True, owner=True):
-        if target or owner:
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator_menu_enum("pose.constraint_add", "type", text="Add Bone Constraint")
 
-            split = layout.split(factor=0.2)
+        layout.template_constraints(use_bone_constraints=True)
 
-            split.label(text="Space:")
-            row = split.row()
 
-            if target:
-                row.prop(con, "target_space", text="")
+# Parent class for constraint panels, with templates and drawing methods
+# shared between the bone and object constraint panels
+class ConstraintButtonsPanel(Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_label = ""
+    bl_options = {'INSTANCED', 'HEADER_LAYOUT_EXPAND', 'DRAW_BOX'}
 
-            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):
-        layout.prop(con, "target")  # XXX limiting settings for only 'curves' or some type of object
+        col = layout.column()
+        col.prop(con, "target")  # XXX limiting settings for only 'curves' or some type of object
 
         if con.target and subtargets:
             if con.target.type == 'ARMATURE':
-                layout.prop_search(con, "subtarget", con.target.data, "bones", text="Bone")
+                col.prop_search(con, "subtarget", con.target.data, "bones", text="Bone")
 
                 if hasattr(con, "head_tail"):
-                    row = layout.row(align=True)
-                    row.label(text="Head/Tail:")
+                    row = col.row(align=True, heading="Head/Tail")
+                    row.use_property_decorate = False
                     row.prop(con, "head_tail", text="")
                     # XXX icon, and only when bone has segments?
                     row.prop(con, "use_bbone_shape", text="", icon='IPO_BEZIER')
             elif con.target.type in {'MESH', 'LATTICE'}:
-                layout.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
+                col.prop_search(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
 
-    @staticmethod
-    def ik_template(layout, con):
-        # only used for iTaSC
-        layout.prop(con, "pole_target")
+    def get_constraint(self, context):
+        con = None
+        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)
+        return con
 
-        if con.pole_target and con.pole_target.type == 'ARMATURE':
-            layout.prop_search(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
+    def draw_header(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
 
-        if con.pole_target:
-            row = layout.row()
-            row.label()
-            row.prop(con, "pole_angle")
+        layout.template_constraint_header(con)
 
-        split = layout.split(factor=0.33)
-        col = split.column()
-        col.prop(con, "use_tail")
-        col.prop(con, "use_stretch")
+    # Drawing methods for specific constraints. (Shared by object and bone constraint panels)
 
-        col = split.column()
-        col.prop(con, "chain_count")
+    def draw_childof(self, context):
+        layout = self.layout
+        con = self.get_constraint(context)
+        layout.use_property_split = True
+        layout.use_property_decorate = True
 
-    def CHILD_OF(self, _context, layout, con):
         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.use_property_decorate = False
+        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.label(icon='BLANK1')
+
+        row = layout.row(heading="Rotation")
+        row.use_property_decorate = False
+        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.label(icon='BLANK1')
+
+        row = layout.row(heading="Scale")
+        row.use_property_decorate = False
+        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.label(icon='BLANK1')
 
         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)
-
-        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")
-
-        self.space_template(layout, con)
-
-    def IK(self, context, layout, con):
-        if context.object.pose.ik_solver == 'ITASC':
-            layout.prop(con, "ik_type")
-            getattr(self, 'IK_' + con.ik_type)(context, layout, con)
-        else:
-            # Standard IK constraint
-            self.target_template(layout, con)
-            layout.prop(con, "pole_target")
-
-            if con.pole_target and con.pole_target.type == 'ARMATURE':
-                layout.prop_search(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
-
-            if con.pole_target:
-                row = layout.row()
-                row.prop(con, "pole_angle")
-                row.label()
-
-            split = layout.split()
-            col = split.column()
-            col.prop(con, "iterations")
-            col.prop(con, "chain_count")
-
-            col = split.column()
-            col.prop(con, "use_tail")
-            col.prop(con, "use_stretch")
-
-            layout.label(text="Weight:")
+        self.draw_influence(layout, con)
 
-            split = layout.split()
-            col = split.column()
-            row = col.row(align=True)
-            row.prop(con, "use_location", text="")
-            sub = row.row(align=True)
-            sub.active = con.use_location
-            sub.prop(con, "weight", text="Position", slider=True)
-
-            col = split.column()
-            row = col.row(align=True)
-            row.prop(con, "

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list