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:
authorCampbell Barton <ideasman42@gmail.com>2020-10-30 12:56:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-30 12:56:45 +0300
commit841517ca81058fca15e1a693f0646b0e1bbafe0c (patch)
tree80c4adcf3dbc77a2d12068770395482dab5e32bb /source/blender/editors/space_outliner/outliner_select.c
parentff73dc244cfffaa279062afbf7f52d7873289f1f (diff)
parent3624c0600747d9ebde1d55f1811f810ba08c6d17 (diff)
Merge branch 'blender-v2.91-release'
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_select.c')
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c93
1 files changed, 63 insertions, 30 deletions
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index c818aa8caa9..2e63b3d405e 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -85,63 +85,96 @@
#include "outliner_intern.h"
+/**
+ * \note changes to selection are by convention and not essential.
+ */
static void do_outliner_item_editmode_toggle(bContext *C, Scene *scene, Base *base)
{
Main *bmain = CTX_data_main(C);
Object *ob = base->object;
+ bool changed = false;
if (BKE_object_is_in_editmode(ob)) {
- ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
+ changed = ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA);
+ if (changed) {
+ ED_object_base_select(base, BA_DESELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
+ }
}
else {
- ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_NO_CONTEXT);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
+ changed = ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_NO_CONTEXT);
+ if (changed) {
+ ED_object_base_select(base, BA_SELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL);
+ }
+ }
+
+ if (changed) {
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ ED_outliner_select_sync_from_object_tag(C);
}
}
-static void do_outliner_item_posemode_toggle(bContext *C, Base *base)
+/**
+ * \note changes to selection are by convention and not essential.
+ */
+static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *base)
{
Main *bmain = CTX_data_main(C);
Object *ob = base->object;
if (ID_IS_LINKED(ob)) {
BKE_report(CTX_wm_reports(C), RPT_WARNING, "Cannot pose libdata");
+ return;
}
- else if (ob->mode & OB_MODE_POSE) {
- ED_object_posemode_exit_ex(bmain, ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
+
+ bool changed = false;
+ if (ob->mode & OB_MODE_POSE) {
+ changed = ED_object_posemode_exit_ex(bmain, ob);
+ if (changed) {
+ ED_object_base_select(base, BA_DESELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
+ }
}
else {
- ED_object_posemode_enter_ex(bmain, ob);
- WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
+ changed = ED_object_posemode_enter_ex(bmain, ob);
+ if (changed) {
+ ED_object_base_select(base, BA_SELECT);
+ WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
+ }
+ }
+
+ if (changed) {
+ DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
+ ED_outliner_select_sync_from_object_tag(C);
}
}
-/* Swap the current active object from the interaction mode with the given base. */
+/**
+ * Swap the current active object from the interaction mode with the given base.
+ *
+ * \note Changes to selection _are_ needed in this case,
+ * since entering the object mode uses the selection.
+ *
+ * If we didn't want to touch selection we could add an option to the operators
+ * not to do multi-object editing.
+ */
static void do_outliner_item_mode_toggle_generic(bContext *C, TreeViewContext *tvc, Base *base)
{
- Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
const int active_mode = tvc->obact->mode;
- /* Return all objects to object mode. */
- FOREACH_OBJECT_BEGIN (tvc->view_layer, ob_iter) {
- ED_object_mode_generic_exit(bmain, depsgraph, tvc->scene, ob_iter);
- }
- FOREACH_OBJECT_END;
- WM_toolsystem_update_from_context_view3d(C);
-
- Base *base_active = BKE_view_layer_base_find(tvc->view_layer, tvc->obact);
- if (base_active != base) {
- ED_object_base_select(base_active, BA_DESELECT);
- ED_object_base_activate(C, base);
- ED_object_base_select(base, BA_SELECT);
+ if (ED_object_mode_set(C, OB_MODE_OBJECT)) {
+ Base *base_active = BKE_view_layer_base_find(tvc->view_layer, tvc->obact);
+ if (base_active != base) {
+ BKE_view_layer_base_deselect_all(tvc->view_layer);
+ BKE_view_layer_base_select_and_set_active(tvc->view_layer, base);
+ DEG_id_tag_update(&tvc->scene->id, ID_RECALC_SELECT);
- /* XXX: Must add undo step between activation and setting mode to prevent an assert. */
- ED_undo_push(C, "outliner mode toggle");
- ED_object_mode_set(C, active_mode);
- ED_outliner_select_sync_from_object_tag(C);
+ /* XXX: Must add undo step between activation and setting mode to prevent an assert. */
+ ED_undo_push(C, "outliner mode toggle");
+ ED_object_mode_set(C, active_mode);
+ ED_outliner_select_sync_from_object_tag(C);
+ }
}
}
@@ -169,7 +202,7 @@ void outliner_item_mode_toggle(bContext *C,
do_outliner_item_editmode_toggle(C, tvc->scene, base);
}
else if (tvc->ob_pose && ob->type == OB_ARMATURE) {
- do_outliner_item_posemode_toggle(C, base);
+ do_outliner_item_posemode_toggle(C, tvc->scene, base);
}
}
}