Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-11 16:54:17 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-11 16:54:17 +0400
commit0096a3dee2082d5dd15278a2e5627b6446f18e0a (patch)
tree30d27b624d546a9f52b1a9e38c1f0b48f07af1eb /source/blender/editors/object
parent10d14e72599e891ce253e37826ce6ed3c0aecd8d (diff)
2.5 - Made more operators for constraint buttons
* Move Up/Down and Delete are now operators * Made TrackTo constraint use expanded enum toggles for up axis too. --> BUG ALERT: specifying name and expand in the arguments to itemR doesn't work (name gets skipped)
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r--source/blender/editors/object/editconstraint.c142
-rw-r--r--source/blender/editors/object/object_intern.h4
-rw-r--r--source/blender/editors/object/object_ops.c3
3 files changed, 93 insertions, 56 deletions
diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c
index 4c9a0bf4c67..7be4697d0c8 100644
--- a/source/blender/editors/object/editconstraint.c
+++ b/source/blender/editors/object/editconstraint.c
@@ -81,7 +81,6 @@ static int pupmenu() {return 0;}
/* -------------- Get Active Constraint Data ---------------------- */
-
/* if object in posemode, active bone constraints, else object constraints */
ListBase *get_active_constraints (Object *ob)
{
@@ -841,7 +840,6 @@ void ED_object_constraint_rename(Object *ob, bConstraint *con, char *oldname)
bConstraint *tcon;
ListBase *conlist= NULL;
int from_object= 0;
- char *channame="";
/* get context by searching for con (primitive...) */
for (tcon= ob->constraints.first; tcon; tcon= tcon->next) {
@@ -851,7 +849,6 @@ void ED_object_constraint_rename(Object *ob, bConstraint *con, char *oldname)
if (tcon) {
conlist= &ob->constraints;
- channame= "Object";
from_object= 1;
}
else if (ob->pose) {
@@ -868,7 +865,6 @@ void ED_object_constraint_rename(Object *ob, bConstraint *con, char *oldname)
if (tcon) {
conlist= &pchan->constraints;
- channame= pchan->name;
}
}
@@ -878,7 +874,7 @@ void ED_object_constraint_rename(Object *ob, bConstraint *con, char *oldname)
}
/* first make sure it's a unique name within context */
- unique_constraint_name (con, conlist);
+ unique_constraint_name(con, conlist);
}
@@ -901,77 +897,111 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con)
if(con==origcon) con->flag |= CONSTRAINT_ACTIVE;
else con->flag &= ~CONSTRAINT_ACTIVE;
}
-
- /* make sure ipowin and buttons shows it */
- if(ob->ipowin==ID_CO) {
- // XXX allqueue(REDRAWIPO, ID_CO);
- // XXX allspace(REMAKEIPO, 0);
- // XXX allqueue(REDRAWNLA, 0);
- }
- // XXX allqueue(REDRAWBUTSOBJECT, 0);
}
-int ED_object_constraint_delete(ReportList *reports, Object *ob, bConstraint *con)
+static int constraint_delete_exec (bContext *C, wmOperator *op)
{
- bConstraintChannel *chan;
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
+ Object *ob= ptr.id.data;
+ bConstraint *con= ptr.data;
ListBase *lb;
- /* remove ipo channel */
- lb= NULL; // XXX get_active_constraint_channels(ob, 0);
- if(lb) {
- chan = NULL; // XXX get_constraint_channel(lb, con->name);
- if(chan) {
- if(chan->ipo) chan->ipo->id.us--;
- BLI_freelinkN(lb, chan);
- }
- }
-
/* remove constraint itself */
lb= get_active_constraints(ob);
free_constraint_data(con);
BLI_freelinkN(lb, con);
ED_object_constraint_set_active(ob, NULL);
+ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
- return 1;
+ return OPERATOR_FINISHED;
}
-int ED_object_constraint_move_down(ReportList *reports, Object *ob, bConstraint *constr)
+void CONSTRAINT_OT_delete (wmOperatorType *ot)
{
- bConstraint *con;
- ListBase *conlist;
-
- if(constr->next) {
- conlist = get_active_constraints(ob);
- for(con= conlist->first; con; con= con->next) {
- if(con==constr) {
- BLI_remlink(conlist, con);
- BLI_insertlink(conlist, con->next, con);
- return 1;
- }
- }
+ /* identifiers */
+ ot->name= "Delete Constraint";
+ ot->idname= "CONSTRAINT_OT_delete";
+ ot->description= "Remove constraitn from constraint stack.";
+
+ /* callbacks */
+ ot->exec= constraint_delete_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int constraint_move_down_exec (bContext *C, wmOperator *op)
+{
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
+ Object *ob= ptr.id.data;
+ bConstraint *con= ptr.data;
+
+ if (con->next) {
+ ListBase *conlist= get_active_constraints(ob);
+ bConstraint *nextCon= con->next;
+
+ /* insert the nominated constraint after the one that used to be after it */
+ BLI_remlink(conlist, con);
+ BLI_insertlinkafter(conlist, nextCon, con);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+
+ return OPERATOR_FINISHED;
}
+
+ return OPERATOR_CANCELLED;
+}
- return 0;
+void CONSTRAINT_OT_move_down (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Move Constraint Down";
+ ot->idname= "CONSTRAINT_OT_move_down";
+ ot->description= "Move constraint down constraint stack.";
+
+ /* callbacks */
+ ot->exec= constraint_move_down_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-int ED_object_constraint_move_up(ReportList *reports, Object *ob, bConstraint *constr)
+
+static int constraint_move_up_exec (bContext *C, wmOperator *op)
{
- bConstraint *con;
- ListBase *conlist;
-
- if(constr->prev) {
- conlist = get_active_constraints(ob);
- for(con= conlist->first; con; con= con->next) {
- if(con==constr) {
- BLI_remlink(conlist, con);
- BLI_insertlink(conlist, con->prev->prev, con);
- return 1;
- }
- }
+ PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
+ Object *ob= ptr.id.data;
+ bConstraint *con= ptr.data;
+
+ if (con->prev) {
+ ListBase *conlist= get_active_constraints(ob);
+ bConstraint *prevCon= con->prev;
+
+ /* insert the nominated constraint before the one that used to be before it */
+ BLI_remlink(conlist, con);
+ BLI_insertlinkbefore(conlist, prevCon, con);
+
+ WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+
+ return OPERATOR_FINISHED;
}
+
+ return OPERATOR_CANCELLED;
+}
- return 0;
+void CONSTRAINT_OT_move_up (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Move Constraint Up";
+ ot->idname= "CONSTRAINT_OT_move_up";
+ ot->description= "Move constraint up constraint stack.";
+
+ /* callbacks */
+ ot->exec= constraint_move_up_exec;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
/***************************** OPERATORS ****************************/
@@ -1015,10 +1045,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op)
case CONSTRAINT_TYPE_RIGIDBODYJOINT:
{
bRigidBodyJointConstraint *data;
-
+
/* set selected first object as target - moved from new_constraint_data */
data = (bRigidBodyJointConstraint*)con->data;
-
+
CTX_DATA_BEGIN(C, Object*, selob, selected_objects) {
if(selob != ob) {
data->tar= selob;
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index 0ad5bd7d08e..76ce8857c2c 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -101,6 +101,10 @@ void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot);
/* editconstraint.c */
void OBJECT_OT_constraint_add(struct wmOperatorType *ot);
+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_childof_set_inverse(struct wmOperatorType *ot);
void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 66dd1b8fbb9..9a0ce23a970 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -111,6 +111,9 @@ void ED_operatortypes_object(void)
WM_operatortype_append(OBJECT_OT_modifier_mdef_bind);
WM_operatortype_append(OBJECT_OT_constraint_add);
+ 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_childof_set_inverse);
WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse);