2.5 Constraints:
authorThomas Dinges <blender@dingto.org>
Sun, 31 May 2009 11:47:45 +0000 (11:47 +0000)
committerThomas Dinges <blender@dingto.org>
Sun, 31 May 2009 11:47:45 +0000 (11:47 +0000)
* Wrapped Action Constraint to Python.

* Some layout tweaks by William Reynish.
* Cleaned up the code a bit.

release/ui/buttons_object_constraint.py
source/blender/editors/interface/interface_templates.c

index 58683146ef0dde63cd4cde6ba573188cb8e2862a..a4ac6dfff863c968808e6ace231bfb16bf1dd53b 100644 (file)
@@ -33,8 +33,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                                self.copy_scale(box, con)
                        #elif con.type == "SCRIPT":
                        #       self.script(box, con)
-                       #elif con.type == "ACTION":
-                       #       self.action(box, con)
+                       elif con.type == "ACTION":
+                               self.action(box, con)
                        elif con.type == "LOCKED_TRACK":
                                self.locked_track(box, con)
                        elif con.type == "LIMIT_DISTANCE":
@@ -87,23 +87,26 @@ class ConstraintButtonsPanel(bpy.types.Panel):
        
        def child_of(self, layout, con):
                self.target_template(layout, con)
+
+               split = layout.split()
                
-               layout.itemL(text="Use Channel(s):")
+               sub = split.column()
+               sub.itemL(text="Location:")
+               sub.itemR(con, "locationx", text="X")
+               sub.itemR(con, "locationy", text="Y")
+               sub.itemR(con, "locationz", text="Z")
                
-               row = layout.row(align=True)
-               row.itemR(con, "locationx", text="Loc X", toggle=True)
-               row.itemR(con, "locationy", text="Loc Y", toggle=True)
-               row.itemR(con, "locationz", text="Loc Z", toggle=True)
-               
-               row = layout.row(align=True)
-               row.itemR(con, "rotationx", text="Rot X", toggle=True)
-               row.itemR(con, "rotationy", text="Rot X", toggle=True)
-               row.itemR(con, "rotationz", text="Rot X", toggle=True)
+               sub = split.column()
+               sub.itemL(text="Rotation:")
+               sub.itemR(con, "rotationx", text="X")
+               sub.itemR(con, "rotationy", text="Y")
+               sub.itemR(con, "rotationz", text="Z")
                
-               row = layout.row(align=True)
-               row.itemR(con, "sizex", text="Scale X", toggle=True)
-               row.itemR(con, "sizey", text="Scale X", toggle=True)
-               row.itemR(con, "sizez", text="Scale X", toggle=True)
+               sub = split.column()
+               sub.itemL(text="Scale:")
+               sub.itemR(con, "sizex", text="X")
+               sub.itemR(con, "sizey", text="Y")
+               sub.itemR(con, "sizez", text="Z")
                
                # Missing
                row = layout.row()
@@ -113,15 +116,13 @@ class ConstraintButtonsPanel(bpy.types.Panel):
        def track_to(self, layout, con):
                self.target_template(layout, con)
                
-               row = layout.row()
-               row.itemL(text="Align:")
-               row.itemR(con, "target_z", toggle=True)
-               
                row = layout.row()
                row.itemL(text="To:")
                row.itemR(con, "track", expand=True)
-               row.itemL(text="Up:")
-               row.itemR(con, "up", expand=True)
+               
+               row = layout.row()
+               row.itemR(con, "up", text="Up")
+               row.itemR(con, "target_z")
                
                self.space_template(layout, con)
                
@@ -137,27 +138,38 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                row = layout.row()
                row.itemL(text="Forward:")
                row.itemR(con, "forward", expand=True)
-               row.itemL(text="Up:")
-               row.itemR(con, "up", expand=True)
+               
+               row = layout.row()
+               row.itemR(con, "up", text="Up")
+               row.itemL()
                
        def limit_rotation(self, layout, con):
-               row = layout.row(align=True)
-               row.itemR(con, "use_limit_x", toggle=True)
-               row.itemR(con, "minimum_x", text="Min")
-               row.itemR(con, "maximum_x", text="Max")
                
-               row = layout.row(align=True)
-               row.itemR(con, "use_limit_y", toggle=True)
-               row.itemR(con, "minimum_y", text="Min")
-               row.itemR(con, "maximum_y", text="Max")
+               split = layout.split()
                
-               row = layout.row(align=True)
-               row.itemR(con, "use_limit_z", toggle=True)
-               row.itemR(con, "minimum_z", text="Min")
-               row.itemR(con, "maximum_z", text="Max")
+               col = split.column()
+               col.itemR(con, "use_limit_x")
+               colsub = col.column()
+               colsub.active = con.use_limit_x
+               colsub.itemR(con, "minimum_x", text="Min")
+               colsub.itemR(con, "maximum_x", text="Max")
+               
+               col = split.column()
+               col.itemR(con, "use_limit_y")
+               colsub = col.column()
+               colsub.active = con.use_limit_y
+               colsub.itemR(con, "minimum_y", text="Min")
+               colsub.itemR(con, "maximum_y", text="Max")
+               
+               col = split.column()
+               col.itemR(con, "use_limit_z")
+               colsub = col.column()
+               colsub.active = con.use_limit_z
+               colsub.itemR(con, "minimum_z", text="Min")
+               colsub.itemR(con, "maximum_z", text="Max")
                
                row = layout.row()
-               row.itemR(con, "limit_transform", toggle=True)
+               row.itemR(con, "limit_transform")
                row.itemL()
                
                row = layout.row()
@@ -168,29 +180,37 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                split = layout.split()
                
                col = split.column()
-               sub = col.row(align=True)
-               sub.itemR(con, "use_minimum_x", toggle=True)
-               sub.itemR(con, "minimum_x", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_minimum_y", toggle=True)
-               sub.itemR(con, "minimum_y", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_minimum_z", toggle=True)
-               sub.itemR(con, "minimum_z", text="")
+               col.itemR(con, "use_minimum_x")
+               colsub = col.column()
+               colsub.active = con.use_minimum_x
+               colsub.itemR(con, "minimum_x", text="")
+               col.itemR(con, "use_maximum_x")
+               colsub = col.column()
+               colsub.active = con.use_maximum_x
+               colsub.itemR(con, "maximum_x", text="")
                
                col = split.column()
-               sub = col.row(align=True)
-               sub.itemR(con, "use_maximum_x", toggle=True)
-               sub.itemR(con, "maximum_x", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_maximum_y", toggle=True)
-               sub.itemR(con, "maximum_y", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_maximum_z", toggle=True)
-               sub.itemR(con, "maximum_z", text="")
+               col.itemR(con, "use_minimum_y")
+               colsub = col.column()
+               colsub.active = con.use_minimum_y
+               colsub.itemR(con, "minimum_y", text="")
+               col.itemR(con, "use_maximum_y")
+               colsub = col.column()
+               colsub.active = con.use_maximum_y
+               colsub.itemR(con, "maximum_y", text="")
                
+               col = split.column()
+               col.itemR(con, "use_minimum_z")
+               colsub = col.column()
+               colsub.active = con.use_minimum_z
+               colsub.itemR(con, "minimum_z", text="")
+               col.itemR(con, "use_maximum_z")
+               colsub = col.column()
+               colsub.active = con.use_maximum_z
+               colsub.itemR(con, "maximum_z", text="")
+       
                row = layout.row()
-               row.itemR(con, "limit_transform", toggle=True)
+               row.itemR(con, "limit_transform")
                row.itemL()
                
                row = layout.row()
@@ -199,31 +219,39 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                
        def limit_scale(self, layout, con):
                split = layout.split()
+
+               col = split.column()
+               col.itemR(con, "use_minimum_x")
+               colsub = col.column()
+               colsub.active = con.use_minimum_x
+               colsub.itemR(con, "minimum_x", text="")
+               col.itemR(con, "use_maximum_x")
+               colsub = col.column()
+               colsub.active = con.use_maximum_x
+               colsub.itemR(con, "maximum_x", text="")
                
                col = split.column()
-               sub = col.row(align=True)
-               sub.itemR(con, "use_minimum_x", toggle=True)
-               sub.itemR(con, "minimum_x", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_minimum_y", toggle=True)
-               sub.itemR(con, "minimum_y", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_minimum_z", toggle=True)
-               sub.itemR(con, "minimum_z", text="")
+               col.itemR(con, "use_minimum_y")
+               colsub = col.column()
+               colsub.active = con.use_minimum_y
+               colsub.itemR(con, "minimum_y", text="")
+               col.itemR(con, "use_maximum_y")
+               colsub = col.column()
+               colsub.active = con.use_maximum_y
+               colsub.itemR(con, "maximum_y", text="")
                
                col = split.column()
-               sub = col.row(align=True)
-               sub.itemR(con, "use_maximum_x", toggle=True)
-               sub.itemR(con, "maximum_x", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_maximum_y", toggle=True)
-               sub.itemR(con, "maximum_y", text="")
-               sub = col.row(align=True)
-               sub.itemR(con, "use_maximum_z", toggle=True)
-               sub.itemR(con, "maximum_z", text="")
+               col.itemR(con, "use_minimum_z")
+               colsub = col.column()
+               colsub.active = con.use_minimum_z
+               colsub.itemR(con, "minimum_z", text="")
+               col.itemR(con, "use_maximum_z")
+               colsub = col.column()
+               colsub.active = con.use_maximum_z
+               colsub.itemR(con, "maximum_z", text="")
                
                row = layout.row()
-               row.itemR(con, "limit_transform", toggle=True)
+               row.itemR(con, "limit_transform")
                row.itemL()
                
                row = layout.row()
@@ -233,47 +261,90 @@ class ConstraintButtonsPanel(bpy.types.Panel):
        def copy_rotation(self, layout, con):
                self.target_template(layout, con)
                
-               row = layout.row(align=True)
-               row.itemR(con, "rotate_like_x", text="X", toggle=True)
-               row.itemR(con, "invert_x", text="-", toggle=True)
-               row.itemR(con, "rotate_like_y", text="Y", toggle=True)
-               row.itemR(con, "invert_y", text="-", toggle=True)
-               row.itemR(con, "rotate_like_z", text="Z", toggle=True)
-               row.itemR(con, "invert_z", text="-", toggle=True)
+               split = layout.split()
+               
+               col = split.column()
+               col.itemR(con, "rotate_like_x", text="X")
+               colsub = col.column()
+               colsub.active = con.rotate_like_x
+               colsub.itemR(con, "invert_x", text="Invert")
+               
+               col = split.column()
+               col.itemR(con, "rotate_like_y", text="Y")
+               colsub = col.column()
+               colsub.active = con.rotate_like_y
+               colsub.itemR(con, "invert_y", text="Invert")
+               
+               col = split.column()
+               col.itemR(con, "rotate_like_z", text="Z")
+               colsub = col.column()
+               colsub.active = con.rotate_like_z
+               colsub.itemR(con, "invert_z", text="Invert")
 
-               layout.itemR(con, "offset", toggle=True)
+               layout.itemR(con, "offset")
                
                self.space_template(layout, con)
                
        def copy_location(self, layout, con):
                self.target_template(layout, con)
                
-               row = layout.row(align=True)
-               row.itemR(con, "locate_like_x", text="X", toggle=True)
-               row.itemR(con, "invert_x", text="-", toggle=True)
-               row.itemR(con, "locate_like_y", text="Y", toggle=True)
-               row.itemR(con, "invert_y", text="-", toggle=True)
-               row.itemR(con, "locate_like_z", text="Z", toggle=True)
-               row.itemR(con, "invert_z", text="-", toggle=True)
-
-               layout.itemR(con, "offset", toggle=True)
+               split = layout.split()
                
+               col = split.column()
+               col.itemR(con, "locate_like_x", text="X")
+               colsub = col.column()
+               colsub.active = con.locate_like_x
+               colsub.itemR(con, "invert_x", text="Invert")
+               
+               col = split.column()
+               col.itemR(con, "locate_like_y", text="Y")
+               colsub = col.column()
+               colsub.active = con.locate_like_y
+               colsub.itemR(con, "invert_y", text="Invert")
+               
+               col = split.column()
+               col.itemR(con, "locate_like_z", text="Z")
+               colsub = col.column()
+               colsub.active = con.locate_like_z
+               colsub.itemR(con, "invert_z", text="Invert")
+
+               layout.itemR(con, "offset")
+                       
                self.space_template(layout, con)
                
        def copy_scale(self, layout, con):
                self.target_template(layout, con)
                
                row = layout.row(align=True)
-               row.itemR(con, "size_like_x", text="X", toggle=True)
-               row.itemR(con, "size_like_y", text="Y", toggle=True)
-               row.itemR(con, "size_like_z", text="Z", toggle=True)
+               row.itemR(con, "size_like_x", text="X")
+               row.itemR(con, "size_like_y", text="Y")
+               row.itemR(con, "size_like_z", text="Z")
 
-               layout.itemR(con, "offset", toggle=True)
+               layout.itemR(con, "offset")
                
                self.space_template(layout, con)
                
-       #def sctipt(self, layout, con):
-       #def action(self, layout, con):
+       #def script(self, layout, con):
+       
+       def action(self, layout, con):
+               self.target_template(layout, con)
+               
+               layout.itemR(con, "action")
+               layout.itemR(con, "transform_channel")
+
+               split = layout.split()
+       
+               col = split.column(align=True)
+               col.itemR(con, "start_frame", text="Start")
+               col.itemR(con, "end_frame", text="End")
+               
+               col = split.column(align=True)
+               col.itemR(con, "minimum", text="Min")
+               col.itemR(con, "maximum", text="Max")
+               
+               row = layout.row()
+               row.itemL(text="Convert:")
+               row.itemR(con, "owner_space", text="")
        
        def locked_track(self, layout, con):
                self.target_template(layout, con)
@@ -281,6 +352,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                row = layout.row()
                row.itemL(text="To:")
                row.itemR(con, "track", expand=True)
+               
+               row = layout.row()
                row.itemL(text="Lock:")
                row.itemR(con, "locked", expand=True)
                
@@ -312,8 +385,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                self.target_template(layout, con)
                
                row = layout.row()
-               row.itemR(con, "sticky", toggle=True)
-               row.itemR(con, "use_rotation", toggle=True)
+               row.itemR(con, "sticky")
+               row.itemR(con, "use_rotation")
                
                layout.itemR(con, "offset")
                
@@ -331,15 +404,12 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                row.itemR(con, "main_axis", expand=True)
                
                row = layout.row()
-               row.itemL(text="Options")
-               row.itemR(con, "cyclic", toggle=True)
+               row.itemR(con, "cyclic")
                
        def transform(self, layout, con):
                self.target_template(layout, con)
                
-               row = layout.row()
-               row.itemR(con, "extrapolate_motion", text="Extrapolate")
-               row.itemL()
+               layout.itemR(con, "extrapolate_motion", text="Extrapolate")
                
                split = layout.split()
                
@@ -362,6 +432,8 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                sub.itemR(con, "from_min_z", text="")
                sub.itemR(con, "from_max_z", text="")
                
+               split = layout.split()
+               
                col = split.column()
                col.itemL(text="Destination:")
                col.row().itemR(con, "map_to", expand=True)
@@ -391,9 +463,9 @@ class ConstraintButtonsPanel(bpy.types.Panel):
                
                if con.shrinkwrap_type == "PROJECT":
                        row = layout.row(align=True)
-                       row.itemR(con, "axis_x", toggle=True)
-                       row.itemR(con, "axis_y", toggle=True)
-                       row.itemR(con, "axis_z", toggle=True)
+                       row.itemR(con, "axis_x")
+                       row.itemR(con, "axis_y")
+                       row.itemR(con, "axis_z")
                
 class OBJECT_PT_constraints(ConstraintButtonsPanel):
        __idname__ = "OBJECT_PT_constraints"
index f622113d6f5c4ff8d5f11bf5012c807d6f27b147..987b7eef4d6bf2425926972445813fcef7c1d540 100644 (file)
@@ -1128,61 +1128,6 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con)
                        }
                        break;
 #endif /* DISABLE_PYTHON */
-               case CONSTRAINT_TYPE_ACTION:
-                       {
-                               bActionConstraint *data = con->data;
-                               float minval, maxval;
-                               
-                               uiDefBut(block, LABEL, B_CONSTRAINT_TEST, "Target:", xco+65, yco-24, 50, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); 
-                               
-                               /* Draw target parameters */
-                               uiBlockBeginAlign(block);
-                                       uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "OB:", xco+120, yco-24, 135, 18, &data->tar, "Target Object"); 
-                                       
-                                       if (is_armature_target(data->tar)) {
-                                               but= uiDefBut(block, TEX, B_CONSTRAINT_CHANGETARGET, "BO:", xco+120, yco-42,135,18, &data->subtarget, 0, 24, 0, 0, "Subtarget Bone");
-                                               uiButSetCompleteFunc(but, autocomplete_bone, (void *)data->tar);
-                                       }
-                                       else {
-                                               strcpy(data->subtarget, "");
-                                       }
-                               
-                               uiBlockEndAlign(block);
-                               
-                               /* Draw action/type buttons */
-                               uiBlockBeginAlign(block);
-                                       uiDefIDPoinBut(block, test_actionpoin_but, ID_AC, B_CONSTRAINT_TEST, "AC:",     xco+((width/2)-117), yco-64, 78, 18, &data->act, "Action containing the keyed motion for this bone"); 
-                                       uiDefButS(block, MENU, B_CONSTRAINT_TEST, "Key on%t|Loc X%x20|Loc Y%x21|Loc Z%x22|Rot X%x0|Rot Y%x1|Rot Z%x2|Size X%x10|Size Y%x11|Size Z%x12", xco+((width/2)-117), yco-84, 78, 18, &data->type, 0, 24, 0, 0, "Specify which transformation channel from the target is used to key the action");
-                               uiBlockEndAlign(block);
-                               
-                               /* Draw start/end frame buttons */
-                               uiBlockBeginAlign(block);
-                                       uiDefButI(block, NUM, B_CONSTRAINT_TEST, "Start:", xco+((width/2)-36), yco-64, 78, 18, &data->start, 1, MAXFRAME, 0.0, 0.0, "Starting frame of the keyed motion"); 
-                                       uiDefButI(block, NUM, B_CONSTRAINT_TEST, "End:", xco+((width/2)-36), yco-84, 78, 18, &data->end, 1, MAXFRAME, 0.0, 0.0, "Ending frame of the keyed motion"); 
-                               uiBlockEndAlign(block);
-                               
-                               /* Draw minimum/maximum transform range buttons */
-                               uiBlockBeginAlign(block);
-                                       if (data->type < 10) { /* rotation */
-                                               minval = -180.0f;
-                                               maxval = 180.0f;
-                                       }
-                                       else if (data->type < 20) { /* scaling */
-                                               minval = 0.0001f;
-                                               maxval = 1000.0f;
-                                       }
-                                       else { /* location */
-                                               minval = -1000.0f;
-                                               maxval = 1000.0f;
-                                       }
-                                       uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Min:", xco+((width/2)+45), yco-64, 78, 18, &data->min, minval, maxval, 0, 0, "Minimum value for target channel range");
-                                       uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Max:", xco+((width/2)+45), yco-84, 78, 18, &data->max, minval, maxval, 0, 0, "Maximum value for target channel range");
-                               uiBlockEndAlign(block);
-                               
-                               /* constraint space settings */
-                               draw_constraint_spaceselect(block, con, xco, yco-104, -1, is_armature_target(data->tar));
-                       }
-                       break;
                /*case CONSTRAINT_TYPE_CHILDOF:
                        {
                                // Inverse options