Commit: 32339a56f11ac1392c4b8d8651ff452a2a5511cc
Author: Campbell Barton
Date:   Wed Apr 11 08:53:59 2018 +0200
Branches: master
https://developer.blender.org/rB32339a56f11ac1392c4b8d8651ff452a2a5511cc

Cleanup: minor changes to pose-mode switching API

Prepare for multi-object pose mode

===================================================================

M       source/blender/editors/armature/pose_edit.c
M       source/blender/editors/include/ED_armature.h
M       source/blender/editors/object/object_edit.c
M       source/blender/editors/space_outliner/outliner_select.c

===================================================================

diff --git a/source/blender/editors/armature/pose_edit.c 
b/source/blender/editors/armature/pose_edit.c
index 2f536ebff6e..f1ae006f958 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -81,33 +81,40 @@ Object *ED_pose_object_from_context(bContext *C)
 }
 
 /* This function is used to process the necessary updates for */
-void ED_armature_enter_posemode(bContext *C, Base *base)
+bool ED_object_posemode_enter_ex(Base *base)
 {
-       ReportList *reports = CTX_wm_reports(C);
        Object *ob = base->object;
-       
-       if (ID_IS_LINKED(ob)) {
-               BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
-               return;
-       }
+       BLI_assert(!ID_IS_LINKED(ob));
+       bool ok = false;
        
        switch (ob->type) {
                case OB_ARMATURE:
                        ob->restore_mode = ob->mode;
                        ob->mode |= OB_MODE_POSE;
-                       
-                       WM_event_add_notifier(C, NC_SCENE | ND_MODE | 
NS_MODE_POSE, NULL);
-                       
+                       ok = true;
+
                        break;
                default:
-                       return;
+                       break;
        }
-       
-       /* XXX: disabled as this would otherwise cause a nasty loop... */
-       //ED_object_mode_toggle(C, ob->mode);
+
+       return ok;
+}
+bool ED_object_posemode_enter(bContext *C, Base *base)
+{
+       ReportList *reports = CTX_wm_reports(C);
+       if (ID_IS_LINKED(base->object)) {
+               BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
+               return false;
+       }
+       bool ok = ED_object_posemode_enter_ex(base);
+       if (ok) {
+               WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, 
NULL);
+       }
+       return ok;
 }
 
-void ED_armature_exit_posemode(bContext *C, Base *base)
+void ED_object_posemode_exit(bContext *C, Base *base)
 {
        if (base) {
                Object *ob = base->object;
diff --git a/source/blender/editors/include/ED_armature.h 
b/source/blender/editors/include/ED_armature.h
index 241bcbea4af..2089f81b0d7 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -195,8 +195,9 @@ void ED_armature_ebone_listbase_free(struct ListBase *lb);
 void ED_armature_ebone_listbase_copy(struct ListBase *lb_dst, struct ListBase 
*lb_src);
 
 /* poseobject.c */
-void ED_armature_exit_posemode(struct bContext *C, struct Base *base);
-void ED_armature_enter_posemode(struct bContext *C, struct Base *base);
+void ED_object_posemode_exit(struct bContext *C, struct Base *base);
+bool ED_object_posemode_enter_ex(struct Base *base);
+bool ED_object_posemode_enter(struct bContext *C, struct Base *base);
 void ED_pose_de_selectall(struct Object *ob, int select_mode, const bool 
ignore_visibility);
 void ED_pose_bone_select(struct Object *ob, struct bPoseChannel *pchan, bool 
select);
 void ED_pose_recalculate_paths(struct Scene *scene, struct Object *ob);
diff --git a/source/blender/editors/object/object_edit.c 
b/source/blender/editors/object/object_edit.c
index 803b183fea1..0eda9668c47 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -703,7 +703,7 @@ static int posemode_exec(bContext *C, wmOperator *op)
        Base *base = CTX_data_active_base(C);
        Object *ob = base->object;
        const int mode_flag = OB_MODE_POSE;
-       const bool is_mode_set = (ob->mode & mode_flag) != 0;
+       bool is_mode_set = (ob->mode & mode_flag) != 0;
        
        if (!is_mode_set) {
                if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
@@ -714,12 +714,15 @@ static int posemode_exec(bContext *C, wmOperator *op)
        if (ob->type == OB_ARMATURE) {
                if (ob == CTX_data_edit_object(C)) {
                        ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO);
-                       ED_armature_enter_posemode(C, base);
+                       is_mode_set = false;
+               }
+
+               if (is_mode_set) {
+                       ED_object_posemode_exit(C, base);
+               }
+               else {
+                       ED_object_posemode_enter(C, base);
                }
-               else if (is_mode_set)
-                       ED_armature_exit_posemode(C, base);
-               else
-                       ED_armature_enter_posemode(C, base);
                
                return OPERATOR_FINISHED;
        }
diff --git a/source/blender/editors/space_outliner/outliner_select.c 
b/source/blender/editors/space_outliner/outliner_select.c
index 305afc206c4..ec234f0c08b 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -718,9 +718,9 @@ static eOLDrawState tree_element_active_pose(
                        ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR 
| EM_DO_UNDO);
                
                if (ob->mode & OB_MODE_POSE)
-                       ED_armature_exit_posemode(C, base);
+                       ED_object_posemode_exit(C, base);
                else 
-                       ED_armature_enter_posemode(C, base);
+                       ED_object_posemode_enter(C, base);
        }
        else {
                if (ob->mode & OB_MODE_POSE) {

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to