diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-09-23 22:50:56 +0400 |
commit | a42ba82f638e481d7fd3c3ed2ba05c331ef6717e (patch) | |
tree | 81a2b9221799707b49b74a5df8bb3ff964ba78bd /source/blender/editors/armature/poseobject.c | |
parent | 7afbdff1b6c348227e652e1c3071ab7ba7c91c44 (diff) | |
parent | a73dd3476e7d180d3320afc04d218ce22f2f3bfc (diff) |
Merged changes in the trunk up to revision 50829.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/pipeline.c
Also addressed code inconsistency due to changes in the trunk revision 50628 (color
management with OCIO) and 50806 (UV project material). OCIO-related changes are marked
OCIO_TODO as in some other files modified in revision 50628.
Diffstat (limited to 'source/blender/editors/armature/poseobject.c')
-rw-r--r-- | source/blender/editors/armature/poseobject.c | 111 |
1 files changed, 40 insertions, 71 deletions
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index e9424a08b0c..2f5eaabc12b 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -74,12 +74,30 @@ #include "ED_mesh.h" #include "ED_screen.h" #include "ED_object.h" +#include "ED_util.h" /* clipboard */ #include "UI_interface.h" #include "UI_resources.h" #include "armature_intern.h" +/* matches logic with ED_operator_posemode_context() */ +Object *ED_pose_object_from_context(bContext *C) +{ + ScrArea *sa = CTX_wm_area(C); + Object *ob; + + /* since this call may also be used from the buttons window, we need to check for where to get the object */ + if (sa && sa->spacetype == SPACE_BUTS) { + ob = ED_object_context(C); + } + else { + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + } + + return ob; +} + /* This function is used to process the necessary updates for */ void ED_armature_enter_posemode(bContext *C, Base *base) { @@ -727,7 +745,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) short changed = 0; /* sanity check */ - if (ELEM(NULL, ob, ob->pose)) + if (ob->pose == NULL) return OPERATOR_CANCELLED; /* selection types @@ -1049,7 +1067,7 @@ static void pose_copy_menu(Scene *scene) /* Global copy/paste buffer for pose - cleared on start/end session + before every copy operation */ static bPose *g_posebuf = NULL; -void free_posebuf(void) +void ED_clipboard_posebuf_free(void) { if (g_posebuf) { bPoseChannel *pchan; @@ -1225,7 +1243,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op) } /* free existing pose buffer */ - free_posebuf(); + ED_clipboard_posebuf_free(); /* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */ set_pose_keys(ob); @@ -1330,15 +1348,8 @@ void POSE_OT_paste(wmOperatorType *ot) static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + Object *ob = ED_pose_object_from_context(C); + /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; @@ -1361,7 +1372,7 @@ void POSE_OT_group_add(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_add_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1370,14 +1381,7 @@ void POSE_OT_group_add(wmOperatorType *ot) static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object */ if (ob == NULL) @@ -1401,7 +1405,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_remove_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1412,8 +1416,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* invoke callback which presents a list of bone-groups for the user to choose from */ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); bPose *pose; uiPopupMenu *pup; @@ -1421,12 +1424,6 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( bActionGroup *grp; int i; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1465,17 +1462,10 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED( /* Assign selected pchans to the bone group that the user selects */ static int pose_group_assign_exec(bContext *C, wmOperator *op) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); bPose *pose; short done = FALSE; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1517,7 +1507,7 @@ void POSE_OT_group_assign(wmOperatorType *ot) /* api callbacks */ ot->invoke = pose_groups_menu_invoke; ot->exec = pose_group_assign_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1529,16 +1519,9 @@ void POSE_OT_group_assign(wmOperatorType *ot) static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; + Object *ob = ED_pose_object_from_context(C); short done = FALSE; - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -1572,7 +1555,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_unassign_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1580,7 +1563,7 @@ void POSE_OT_group_unassign(wmOperatorType *ot) static int group_move_exec(bContext *C, wmOperator *op) { - Object *ob = ED_object_context(C); + Object *ob = ED_pose_object_from_context(C); bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; bActionGroup *grp; @@ -1653,7 +1636,7 @@ void POSE_OT_group_move(wmOperatorType *ot) /* api callbacks */ ot->exec = group_move_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1678,7 +1661,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = ED_object_context(C); + Object *ob = ED_pose_object_from_context(C); bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; tSortActionGroup *agrp_array; @@ -1737,7 +1720,7 @@ void POSE_OT_group_sort(wmOperatorType *ot) /* api callbacks */ ot->exec = group_sort_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1765,14 +1748,7 @@ static void pose_group_select(bContext *C, Object *ob, int select) static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1795,7 +1771,7 @@ void POSE_OT_group_select(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_select_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1803,14 +1779,7 @@ void POSE_OT_group_select(wmOperatorType *ot) static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa = CTX_wm_area(C); - Object *ob; - - /* since this call may also be used from the buttons window, we need to check for where to get the object */ - if (sa->spacetype == SPACE_BUTS) - ob = ED_object_context(C); - else - ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1833,7 +1802,7 @@ void POSE_OT_group_deselect(wmOperatorType *ot) /* api callbacks */ ot->exec = pose_group_deselect_exec; - ot->poll = ED_operator_posemode; + ot->poll = ED_operator_posemode_context; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; |