static int posemode_exec(bContext *C, wmOperator *UNUSED(op)) { Base *base= CTX_data_active_base(C); if (base->object->type==OB_ARMATURE) { if (base->object==CTX_data_edit_object(C)) { ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); ED_armature_enter_posemode(C, base); } else if (base->object->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); return OPERATOR_FINISHED; } return OPERATOR_PASS_THROUGH; }
static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { Object *ob= (Object *)tselem->id; Base *base= object_in_scene(ob, scene); if(set) { if(scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); if(ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); } else { if(ob->mode & OB_MODE_POSE) return 1; } return 0; }