[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24614] trunk/blender/release/scripts/ui/ properties_object_constraint.py: Single column UI for constraints

William Reynish william at reynish.com
Tue Nov 17 16:59:55 CET 2009


Revision: 24614
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24614
Author:   billrey
Date:     2009-11-17 16:59:54 +0100 (Tue, 17 Nov 2009)

Log Message:
-----------
Single column UI for constraints

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_object_constraint.py

Modified: trunk/blender/release/scripts/ui/properties_object_constraint.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_object_constraint.py	2009-11-17 15:51:28 UTC (rev 24613)
+++ trunk/blender/release/scripts/ui/properties_object_constraint.py	2009-11-17 15:59:54 UTC (rev 24614)
@@ -19,6 +19,7 @@
 # <pep8 compliant>
 import bpy
 
+narrowui = 180
 
 class ConstraintButtonsPanel(bpy.types.Panel):
     bl_space_type = 'PROPERTIES'
@@ -29,37 +30,52 @@
         layout = self.layout
 
         box = layout.template_constraint(con)
+        col2 = context.region.width > narrowui
 
         if box:
             # match enum type to our functions, avoids a lookup table.
-            getattr(self, con.type)(context, box, con)
+            getattr(self, con.type)(context, box, con, col2)
 
             # show/key buttons here are most likely obsolete now, with
             # keyframing functionality being part of every button
             if con.type not in ('RIGID_BODY_JOINT', 'SPLINE_IK', 'NULL'):
                 box.itemR(con, "influence")
 
-    def space_template(self, layout, con, target=True, owner=True):
+    def space_template(self, layout, con, col2, target=True, owner=True):
         if target or owner:
-            row = layout.row()
+            
+            split = layout.split(percentage=0.2)
 
-            row.itemL(text="Convert:")
-
+            if col2:
+                split.itemL(text="Space:")
+                row = split.row()
+            else:
+                row = layout.row()
+            
+            
             if target:
                 row.itemR(con, "target_space", text="")
 
-            if target and owner:
-                row.itemL(icon='ICON_ARROW_LEFTRIGHT')
-
+            if col2:
+                if target and owner:
+                    row.itemL(icon='ICON_ARROW_LEFTRIGHT')
+            else:
+                row = layout.row()
             if owner:
                 row.itemR(con, "owner_space", text="")
 
-    def target_template(self, layout, con, subtargets=True):
-        layout.itemR(con, "target") # XXX limiting settings for only 'curves' or some type of object
+    def target_template(self, layout, con, col2, subtargets=True):
+        if col2:
+            layout.itemR(con, "target") # XXX limiting settings for only 'curves' or some type of object
+        else:
+            layout.itemR(con, "target", text="")
 
         if con.target and subtargets:
             if con.target.type == 'ARMATURE':
-                layout.item_pointerR(con, "subtarget", con.target.data, "bones", text="Bone")
+                if col2:
+                    layout.item_pointerR(con, "subtarget", con.target.data, "bones", text="Bone")
+                else:
+                    layout.item_pointerR(con, "subtarget", con.target.data, "bones", text="")
 
                 if con.type == 'COPY_LOCATION':
                     row = layout.row()
@@ -68,7 +84,7 @@
             elif con.target.type in ('MESH', 'LATTICE'):
                 layout.item_pointerR(con, "subtarget", con.target, "vertex_groups", text="Vertex Group")
 
-    def ik_template(self, layout, con):
+    def ik_template(self, layout, con, col2):
         # only used for iTaSC
         layout.itemR(con, "pole_target")
 
@@ -89,8 +105,8 @@
         col.itemR(con, "chain_length")
         col.itemR(con, "targetless")
 
-    def CHILD_OF(self, context, layout, con):
-        self.target_template(layout, con)
+    def CHILD_OF(self, context, layout, con, col2):
+        self.target_template(layout, con, col2)
 
         split = layout.split()
 
@@ -112,66 +128,79 @@
         col.itemR(con, "sizey", text="Y")
         col.itemR(con, "sizez", text="Z")
 
-        row = layout.row()
-        row.itemO("constraint.childof_set_inverse")
-        row.itemO("constraint.childof_clear_inverse")
+        split = layout.split()
 
-    def TRACK_TO(self, context, layout, con):
-        self.target_template(layout, con)
+        col = split.column()
+        col.itemO("constraint.childof_set_inverse")
+        
+        if col2:
+            col = split.column()
+        col.itemO("constraint.childof_clear_inverse")
 
+    def TRACK_TO(self, context, layout, con, col2):
+        self.target_template(layout, con, col2)
+
         row = layout.row()
-        row.itemL(text="To:")
+        if col2:
+            row.itemL(text="To:")
         row.itemR(con, "track", expand=True)
 
-        row = layout.row()
-        #row.itemR(con, "up", text="Up", expand=True) # XXX: up and expand don't play nice together
-        row.itemR(con, "up", text="Up")
-        row.itemR(con, "target_z")
+        split = layout.split()
 
-        self.space_template(layout, con)
+        col = split.column()
+        col.itemR(con, "up", text="Up")
+        
+        if col2:
+            col = split.column()
+        col.itemR(con, "target_z")
 
-    def IK(self, context, layout, con):
+        self.space_template(layout, con, col2)
+
+    def IK(self, context, layout, con, col2):
         if context.object.pose.ik_solver == "ITASC":
             layout.itemR(con, "ik_type")
             getattr(self, 'IK_' + con.ik_type)(context, layout, con)
         else:
             # Legacy IK constraint
-            self.target_template(layout, con)
-            layout.itemR(con, "pole_target")
-
+            self.target_template(layout, con, col2)
+            if col2:
+                layout.itemR(con, "pole_target")
+            else:
+                layout.itemR(con, "pole_target", text="")
             if con.pole_target and con.pole_target.type == 'ARMATURE':
-                layout.item_pointerR(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
+                if col2:
+                    layout.item_pointerR(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
+                else:
+                    layout.item_pointerR(con, "pole_subtarget", con.pole_target.data, "bones", text="")
 
             if con.pole_target:
                 row = layout.row()
-                row.itemL()
                 row.itemR(con, "pole_angle")
+                if col2:
+                    row.itemL()
 
             split = layout.split()
             col = split.column()
-            col.itemR(con, "tail")
-            col.itemR(con, "stretch")
-
-            col = split.column()
             col.itemR(con, "iterations")
             col.itemR(con, "chain_length")
 
-            split = layout.split()
-            col = split.column()
-            col.itemL()
-            col.itemR(con, "targetless")
-            col.itemR(con, "rotation")
-
-            col = split.column()
             col.itemL(text="Weight:")
             col.itemR(con, "weight", text="Position", slider=True)
             sub = col.column()
             sub.active = con.rotation
             sub.itemR(con, "orient_weight", text="Rotation", slider=True)
+            
+            if col2:
+                col = split.column()
+            col.itemR(con, "tail")
+            col.itemR(con, "stretch")
+            col.itemS()
+            col.itemR(con, "targetless")
+            col.itemR(con, "rotation")
 
-    def IK_COPY_POSE(self, context, layout, con):
-        self.target_template(layout, con)
-        self.ik_template(layout, con)
+    def IK_COPY_POSE(self, context, layout, con, col2):
+        self.target_template(layout, con, col2)
+        self.ik_template(layout, con, col2)
 
         row = layout.row()
         row.itemL(text="Axis Ref:")
@@ -204,17 +233,17 @@
         row.itemR(con, "rot_lock_z", text="Z")
         split.active = con.rotation
 
-    def IK_DISTANCE(self, context, layout, con):
-        self.target_template(layout, con)
-        self.ik_template(layout, con)
+    def IK_DISTANCE(self, context, layout, con, col2):
+        self.target_template(layout, con, col2)
+        self.ik_template(layout, con, col2)
 
         layout.itemR(con, "limit_mode")
         row = layout.row()
         row.itemR(con, "weight", text="Weight", slider=True)
         row.itemR(con, "distance", text="Distance", slider=True)
 
-    def FOLLOW_PATH(self, context, layout, con):
-        self.target_template(layout, con)
+    def FOLLOW_PATH(self, context, layout, con, col2):
+        self.target_template(layout, con, col2)
 
         split = layout.split()
 
@@ -222,7 +251,8 @@
         col.itemR(con, "use_curve_follow")
         col.itemR(con, "use_curve_radius")
 
-        col = split.column()
+        if col2:
+            col = split.column()
         col.itemR(con, "use_fixed_position")
         if con.use_fixed_position:
             col.itemR(con, "offset_factor", text="Offset")
@@ -230,32 +260,36 @@
             col.itemR(con, "offset")
 
         row = layout.row()
-        row.itemL(text="Forward:")
+        if col2:
+            row.itemL(text="Forward:")
         row.itemR(con, "forward", expand=True)
 
         row = layout.row()
         row.itemR(con, "up", text="Up")
-        row.itemL()
+        if col2:
+            row.itemL()
 
-    def LIMIT_ROTATION(self, context, layout, con):
+    def LIMIT_ROTATION(self, context, layout, con, col2):
 
         split = layout.split()
 
-        col = split.column()
+        col = split.column(align=True)
         col.itemR(con, "use_limit_x")
         sub = col.column()
         sub.active = con.use_limit_x
         sub.itemR(con, "minimum_x", text="Min")
         sub.itemR(con, "maximum_x", text="Max")
 
-        col = split.column()
+        if col2:
+            col = split.column(align=True)
         col.itemR(con, "use_limit_y")
         sub = col.column()
         sub.active = con.use_limit_y
         sub.itemR(con, "minimum_y", text="Min")
         sub.itemR(con, "maximum_y", text="Max")
 
-        col = split.column()
+        if col2:
+            col = split.column(align=True)
         col.itemR(con, "use_limit_z")
         sub = col.column()
         sub.active = con.use_limit_z
@@ -264,13 +298,15 @@
 
         row = layout.row()
         row.itemR(con, "limit_transform")
-        row.itemL()
+        if col2:
+            row.itemL()
 
         row = layout.row()
-        row.itemL(text="Convert:")
+        if col2:
+            row.itemL(text="Convert:")
         row.itemR(con, "owner_space", text="")
 
-    def LIMIT_LOCATION(self, context, layout, con):
+    def LIMIT_LOCATION(self, context, layout, con, col2):
         split = layout.split()
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list