diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-05-08 08:22:52 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-05-08 08:22:52 +0300 |
commit | 469d43b1dbc54d2afcbfe104a2d8ca9c03df9b81 (patch) | |
tree | 380520b1c0566a8f2687b42156c0cd82ff9a4e97 | |
parent | bf593a8631e84a258d1c8e5e7b198b458811c11b (diff) |
WM: publish Object.mode changes on mode switching
-rw-r--r-- | source/blender/editors/object/object_edit.c | 79 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 7 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 4 |
5 files changed, 63 insertions, 37 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index d051e42cb32..4b13419f425 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -108,8 +108,10 @@ #include "UI_interface.h" #include "UI_resources.h" + #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "object_intern.h" // own include @@ -450,6 +452,7 @@ void ED_object_editmode_enter(bContext *C, int flag) static int editmode_toggle_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); const int mode_flag = OB_MODE_EDIT; const bool is_mode_set = (CTX_data_edit_object(C) != NULL); Scene *scene = CTX_data_scene(C); @@ -489,6 +492,8 @@ static int editmode_toggle_exec(bContext *C, wmOperator *op) ED_space_image_uv_sculpt_update(CTX_wm_manager(C), scene); + WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); + return OPERATOR_FINISHED; } @@ -528,6 +533,7 @@ void OBJECT_OT_editmode_toggle(wmOperatorType *ot) static int posemode_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Base *base = CTX_data_active_base(C); Object *obact = base->object; const int mode_flag = OB_MODE_POSE; @@ -539,51 +545,54 @@ static int posemode_exec(bContext *C, wmOperator *op) } } - if (obact->type == OB_ARMATURE) { - if (obact == CTX_data_edit_object(C)) { - ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO); - is_mode_set = false; - } + if (obact->type != OB_ARMATURE) { + return OPERATOR_PASS_THROUGH; + } - if (is_mode_set) { - bool ok = ED_object_posemode_exit(C, obact); - if (ok) { - struct Main *bmain = CTX_data_main(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) + if (obact == CTX_data_edit_object(C)) { + ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO); + is_mode_set = false; + } + + if (is_mode_set) { + bool ok = ED_object_posemode_exit(C, obact); + if (ok) { + struct Main *bmain = CTX_data_main(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) + { + if ((ob != obact) && + (ob->type == OB_ARMATURE) && + (ob->mode & mode_flag)) { - if ((ob != obact) && - (ob->type == OB_ARMATURE) && - (ob->mode & mode_flag)) - { - ED_object_posemode_exit_ex(bmain, ob); - } + ED_object_posemode_exit_ex(bmain, ob); } - FOREACH_SELECTED_OBJECT_END; } + FOREACH_SELECTED_OBJECT_END; } - else { - bool ok = ED_object_posemode_enter(C, obact); - if (ok) { - struct Main *bmain = CTX_data_main(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) + } + else { + bool ok = ED_object_posemode_enter(C, obact); + if (ok) { + struct Main *bmain = CTX_data_main(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + FOREACH_SELECTED_OBJECT_BEGIN(view_layer, ob) + { + if ((ob != obact) && + (ob->type == OB_ARMATURE) && + (ob->mode == OB_MODE_OBJECT) && + (!ID_IS_LINKED(ob))) { - if ((ob != obact) && - (ob->type == OB_ARMATURE) && - (ob->mode == OB_MODE_OBJECT) && - (!ID_IS_LINKED(ob))) - { - ED_object_posemode_enter_ex(bmain, ob); - } + ED_object_posemode_enter_ex(bmain, ob); } - FOREACH_SELECTED_OBJECT_END; } + FOREACH_SELECTED_OBJECT_END; } - return OPERATOR_FINISHED; } - - return OPERATOR_PASS_THROUGH; + + WM_msg_publish_rna_prop(mbus, &obact->id, obact, Object, mode); + + return OPERATOR_FINISHED; } void OBJECT_OT_posemode_toggle(wmOperatorType *ot) diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 5c476df3dd3..d343264c2c9 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -80,6 +80,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "RNA_access.h" #include "RNA_define.h" @@ -4433,6 +4434,7 @@ static int particle_edit_toggle_poll(bContext *C) static int particle_edit_toggle_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); @@ -4469,6 +4471,8 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 3207b4f6a0a..cbf755d26b5 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -73,6 +73,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "RNA_access.h" #include "RNA_define.h" @@ -1057,6 +1058,7 @@ static int texture_paint_toggle_poll(bContext *C) static int texture_paint_toggle_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_TEXTURE_PAINT; @@ -1130,10 +1132,10 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) toggle_paint_cursor(C, 1); } - // ED_workspace_object_mode_sync_from_object(wm, workspace, ob); - WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); + WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index d5991ac67d4..196505c9542 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -68,6 +68,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "ED_object.h" #include "ED_mesh.h" @@ -1217,6 +1218,7 @@ void ED_object_wpaintmode_exit(struct bContext *C) */ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_WEIGHT_PAINT; const bool is_mode_set = (ob->mode & mode_flag) != 0; @@ -1248,6 +1250,8 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); + WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + return OPERATOR_FINISHED; } @@ -2349,6 +2353,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) */ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_VERTEX_PAINT; const bool is_mode_set = (ob->mode & mode_flag) != 0; @@ -2379,6 +2384,8 @@ static int vpaint_mode_toggle_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); + WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 5f5fa044f1e..048555d3fcc 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -76,6 +76,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "WM_message.h" #include "ED_sculpt.h" #include "ED_object.h" @@ -5795,6 +5796,7 @@ void ED_object_sculptmode_exit(bContext *C) static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) { + struct wmMsgBus *mbus = CTX_wm_message_bus(C); Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); @@ -5816,6 +5818,8 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); + WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); + return OPERATOR_FINISHED; } |