2.5 - 'Reset' buttons for Limit Distance and Stretch To Constraints
authorJoshua Leung <aligorith@gmail.com>
Sun, 26 Jul 2009 11:57:27 +0000 (11:57 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 26 Jul 2009 11:57:27 +0000 (11:57 +0000)
release/ui/buttons_data_armature.py
release/ui/buttons_object_constraint.py
source/blender/editors/object/editconstraint.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_ops.c

index b2c135e4a9bbb20745bb38aa6fb645d907196ab8..51113226dac0d137cf03f84129dab14312ca8211 100644 (file)
@@ -96,20 +96,24 @@ class DATA_PT_bone_groups(DataButtonsPanel):
                row.template_list(pose, "bone_groups", pose, "active_bone_group_index")
                
                col = row.column(align=True)
+               col.active = (ob.proxy == None)
                col.itemO("pose.group_add", icon="ICON_ZOOMIN", text="")
                col.itemO("pose.group_remove", icon="ICON_ZOOMOUT", text="")
                
                group = pose.active_bone_group
                if group:
                        col = layout.column()
+                       col.active= (ob.proxy == None)
                        col.itemR(group, "name")
                        
                        split = layout.split(0.5)
+                       split.active= (ob.proxy == None)
                        split.itemR(group, "color_set")
                        if group.color_set:
                                split.template_triColorSet(group, "colors")
                
                row = layout.row(align=True)
+               row.active= (ob.proxy == None)
                
                row.itemO("pose.group_assign", text="Assign")
                row.itemO("pose.group_remove", text="Remove") #row.itemO("pose.bone_group_remove_from", text="Remove")
index 8d531df9e19179b562b26e1946fff6fc7dfcf9a3..1766513a952261c5b78a2ab740e95ed550bec30c 100644 (file)
@@ -379,26 +379,29 @@ class ConstraintButtonsPanel(bpy.types.Panel):
        def limit_distance(self, layout, con):
                self.target_template(layout, con)
                
-               layout.itemR(con, "distance")
+               col = layout.column(align=True);
+               col.itemR(con, "distance")
+               col.itemO("constraint.limitdistance_reset")
                
                row = layout.row()
                row.itemL(text="Clamp Region:")
                row.itemR(con, "limit_mode", text="")
-               #Missing: Recalculate Button
                
        def stretch_to(self, layout, con):
                self.target_template(layout, con)
                
-               row = layout.row()
-               row.itemR(con, "original_length", text="Rest Length")
-               row.itemR(con, "bulge", text="Volume Variation")
+               col = layout.column(align=True)
+               col.itemR(con, "original_length", text="Rest Length")
+               col.itemO("constraint.stretchto_reset")
+               
+               col = layout.column()
+               col.itemR(con, "bulge", text="Volume Variation")
                
                row = layout.row()
                row.itemL(text="Volume:")
                row.itemR(con, "volume", expand=True)
                row.itemL(text="Plane:")
                row.itemR(con, "keep_axis", expand=True)
-               #Missing: Recalculate Button
                
        def floor(self, layout, con):
                self.target_template(layout, con)
index 437beda324bef9aa31b077b8e7e690d23b905ea6..9e8205e58abf76195b74a79b9ddf19755b6caee5 100644 (file)
@@ -462,6 +462,58 @@ void object_test_constraints (Object *owner)
 
 /* ********************** CONSTRAINT-SPECIFIC STUFF ********************* */
 
+/* ---------- Distance-Dependent Constraints ---------- */
+/* StretchTo, Limit Distance */
+
+static int stretchto_reset_exec (bContext *C, wmOperator *op)
+{
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_StretchToConstraint);
+       
+       /* just set original length to 0.0, which will cause a reset on next recalc */
+       RNA_float_set(&ptr, "original_length", 0.0f);
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
+       return OPERATOR_FINISHED;
+}
+
+void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Reset Original Length";
+       ot->idname= "CONSTRAINT_OT_stretchto_reset";
+       ot->description= "Reset original length of bone for Stretch To Constraint.";
+       
+       ot->exec= stretchto_reset_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+
+static int limitdistance_reset_exec (bContext *C, wmOperator *op)
+{
+       PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_LimitDistanceConstraint);
+       
+       /* just set distance to 0.0, which will cause a reset on next recalc */
+       RNA_float_set(&ptr, "distance", 0.0f);
+       
+       WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
+       return OPERATOR_FINISHED;
+}
+
+void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Reset Distance";
+       ot->idname= "CONSTRAINT_OT_limitdistance_reset";
+       ot->description= "Reset limiting distance for Limit Distance Constraint.";
+       
+       ot->exec= limitdistance_reset_exec;
+       
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /* ------------- Child-Of Constraint ------------------ */
 
 /* ChildOf Constraint - set inverse callback */
index da1dd4585556b0efc66a2a03fde27caefd36cd4b..29076d9f32ab304ab6fad88dab8ce8e43218f93c 100644 (file)
@@ -120,6 +120,8 @@ void CONSTRAINT_OT_delete(struct wmOperatorType *ot);
 void CONSTRAINT_OT_move_up(struct wmOperatorType *ot);
 void CONSTRAINT_OT_move_down(struct wmOperatorType *ot);
 
+void CONSTRAINT_OT_stretchto_reset(struct wmOperatorType *ot);
+void CONSTRAINT_OT_limitdistance_reset(struct wmOperatorType *ot);
 void CONSTRAINT_OT_childof_set_inverse(struct wmOperatorType *ot);
 void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot);
 
index 27d481ef5098818e41ada50c5f4681c9fe0fe84f..c54a8cef8dcd9a2ef73842ca70edfe2789634326 100644 (file)
@@ -125,6 +125,8 @@ void ED_operatortypes_object(void)
        WM_operatortype_append(CONSTRAINT_OT_delete);
        WM_operatortype_append(CONSTRAINT_OT_move_up);
        WM_operatortype_append(CONSTRAINT_OT_move_down);
+       WM_operatortype_append(CONSTRAINT_OT_stretchto_reset);
+       WM_operatortype_append(CONSTRAINT_OT_limitdistance_reset);
        WM_operatortype_append(CONSTRAINT_OT_childof_set_inverse);
        WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse);