diff options
author | Nathan Craddock <nzcraddock@gmail.com> | 2020-08-19 00:14:48 +0300 |
---|---|---|
committer | Nathan Craddock <nzcraddock@gmail.com> | 2020-08-19 00:14:48 +0300 |
commit | 347af6aa9d099af884f30fd38fe8a709db276a32 (patch) | |
tree | 42f9f335350b231f41073b48ea01cff0d46af350 | |
parent | a336b0c3a1cded0b5b1e4a8f24306fdad7dda1b7 (diff) |
Cleanup: Outliner mode toggle warnings
Remove warnings from unused parameters.
3 files changed, 35 insertions, 141 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0725c721315..372a54a0b65 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1916,7 +1916,7 @@ static void outliner_mode_toggle_fn(bContext *C, void *tselem_poin, void *UNUSED return; } - outliner_item_mode_toggle(C, &tvc, te, true); + outliner_item_mode_toggle(C, &tvc, te); } /* Return the icon for a given interaction mode diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 4e6e9412292..89771f9f76e 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -292,10 +292,7 @@ bool outliner_item_is_co_over_name_icons(const TreeElement *te, float view_co_x) bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x); bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2]); -void outliner_item_mode_toggle(struct bContext *C, - TreeViewContext *tvc, - TreeElement *te, - const bool extend); +void outliner_item_mode_toggle(struct bContext *C, TreeViewContext *tvc, TreeElement *te); /* outliner_edit.c ---------------------------------------------- */ typedef void (*outliner_operation_fn)(struct bContext *C, diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index e2520d34157..382b7ad94b5 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -79,38 +79,6 @@ #include "outliner_intern.h" -static bool do_outliner_activate_common(bContext *C, - Main *bmain, - Depsgraph *depsgraph, - Scene *scene, - ViewLayer *view_layer, - Base *base, - const bool extend, - const bool do_exit) -{ - bool use_all = false; - - if (do_exit) { - FOREACH_OBJECT_BEGIN (view_layer, ob_iter) { - ED_object_mode_generic_exit(bmain, depsgraph, scene, ob_iter); - } - FOREACH_OBJECT_END; - } - - /* Just like clicking in the object changes the active object, - * clicking on the object data should change it as well. */ - ED_object_base_activate(C, base); - - if (extend) { - use_all = true; - } - else { - ED_object_base_deselect_all(view_layer, NULL, SEL_DESELECT); - } - - return use_all; -} - /** * Find a new active object to keep the other objects in the mode. * @@ -149,119 +117,51 @@ static bool outliner_set_new_active(bContext *C, ListBase *tree, Object *ob, int * If extend is used, we try to have the other compatible selected objects in the new mode as * well. Otherwise only the new object will be active, selected and in the edit mode. */ -static void do_outliner_item_editmode_toggle(bContext *C, - Scene *scene, - ViewLayer *view_layer, - TreeElement *te, - Base *base, - const bool extend) +static void do_outliner_item_editmode_toggle(bContext *C, Scene *scene, Base *base) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - Object *obact = OBACT(view_layer); Object *ob = base->object; - bool use_all = false; + bool ok = false; - /* TODO (Nathan): These aren't needed because edit/pose mode cannot be entered - * from the outliner directly anymore. */ - /*if (obact == NULL) { - ED_object_base_activate(C, base); - DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - obact = ob; - use_all = true; - } - else if (obact->data == ob->data) { - use_all = true; - } - else if (obact->mode == OB_MODE_OBJECT) { - use_all = do_outliner_activate_common( - C, bmain, depsgraph, scene, view_layer, base, extend, false); - } - else if ((ob->type != obact->type) || ((obact->mode & OB_MODE_EDIT) == 0) || - ((obact->mode & OB_MODE_POSE) && ELEM(OB_ARMATURE, ob->type, obact->type)) || !extend) { - use_all = do_outliner_activate_common( - C, bmain, depsgraph, scene, view_layer, base, extend, true); - }*/ + if (BKE_object_is_in_editmode(ob)) { + SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); + outliner_set_new_active(C, &space_outliner->tree, ob, ob->mode); - if (use_all) { - WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); + ok = ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); } else { - bool ok; - if (BKE_object_is_in_editmode(ob)) { - SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - outliner_set_new_active(C, &space_outliner->tree, ob, ob->mode); - - ok = ED_object_editmode_exit_ex(bmain, scene, ob, EM_FREEDATA); - } - else { - ok = ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_NO_CONTEXT); - /* TODO (Nathan): Why does this crash on undo? */ - // ED_object_base_activate(C, base); - } - if (ok) { - ED_object_base_select(base, (ob->mode & OB_MODE_EDIT) ? BA_SELECT : BA_DESELECT); - DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - } + ok = ED_object_editmode_enter_ex(CTX_data_main(C), scene, ob, EM_NO_CONTEXT); + /* TODO (Nathan): Why does this crash on undo? */ + // ED_object_base_activate(C, base); + } + if (ok) { + ED_object_base_select(base, (ob->mode & OB_MODE_EDIT) ? BA_SELECT : BA_DESELECT); + DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } -static void do_outliner_item_posemode_toggle(bContext *C, - Scene *scene, - ViewLayer *view_layer, - TreeElement *te, - Base *base, - const bool extend) +static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *base) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - Object *obact = OBACT(view_layer); Object *ob = base->object; - bool use_all = false; - /*if (obact == NULL) { - ED_object_base_activate(C, base); - DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - obact = ob; - use_all = true; - } - else if (obact->data == ob->data) { - use_all = true; - } - else if (obact->mode == OB_MODE_OBJECT) { - use_all = do_outliner_activate_common( - C, bmain, depsgraph, scene, view_layer, base, extend, false); - } - else if ((!ELEM(ob->type, obact->type)) || - ((obact->mode & OB_MODE_EDIT) && ELEM(OB_ARMATURE, ob->type, obact->type))) { - use_all = do_outliner_activate_common( - C, bmain, depsgraph, scene, view_layer, base, extend, true); - }*/ + bool ok = false; + if (ob->mode & OB_MODE_POSE) { + SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); + outliner_set_new_active(C, &space_outliner->tree, ob, ob->mode); - if (use_all) { - WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); + ok = ED_object_posemode_exit_ex(bmain, ob); } else { - bool ok = false; - if (ob->mode & OB_MODE_POSE) { - SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); - outliner_set_new_active(C, &space_outliner->tree, ob, ob->mode); - - ok = ED_object_posemode_exit_ex(bmain, ob); - } - else { - ok = ED_object_posemode_enter_ex(bmain, ob); - ED_object_base_activate(C, base); - } - if (ok) { - ED_object_base_select(base, (ob->mode & OB_MODE_POSE) ? BA_SELECT : BA_DESELECT); - DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); - WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); - WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - } + ok = ED_object_posemode_enter_ex(bmain, ob); + ED_object_base_activate(C, base); + } + if (ok) { + ED_object_base_select(base, (ob->mode & OB_MODE_POSE) ? BA_SELECT : BA_DESELECT); + DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } @@ -293,18 +193,15 @@ void outliner_object_mode_toggle(bContext *C, Scene *scene, ViewLayer *view_laye { Object *obact = OBACT(view_layer); if (obact->mode & OB_MODE_EDIT) { - do_outliner_item_editmode_toggle(C, scene, view_layer, NULL, base, true); + do_outliner_item_editmode_toggle(C, scene, base); } else if (obact->mode & OB_MODE_POSE) { - do_outliner_item_posemode_toggle(C, scene, view_layer, NULL, base, true); + do_outliner_item_posemode_toggle(C, scene, base); } } /* Toggle the item's interaction mode if supported */ -void outliner_item_mode_toggle(bContext *C, - TreeViewContext *tvc, - TreeElement *te, - const bool extend) +void outliner_item_mode_toggle(bContext *C, TreeViewContext *tvc, TreeElement *te) { TreeStoreElem *tselem = TREESTORE(te); @@ -317,10 +214,10 @@ void outliner_item_mode_toggle(bContext *C, } if (tvc->ob_edit && OB_TYPE_SUPPORT_EDITMODE(ob->type)) { - do_outliner_item_editmode_toggle(C, tvc->scene, tvc->view_layer, te, base, extend); + do_outliner_item_editmode_toggle(C, tvc->scene, base); } else if (tvc->ob_pose && ob->type == OB_ARMATURE) { - do_outliner_item_posemode_toggle(C, tvc->scene, tvc->view_layer, te, base, extend); + do_outliner_item_posemode_toggle(C, tvc->scene, base); } else { do_outliner_item_mode_toggle_generic(C, tvc, base); |