diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-02-09 00:52:28 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-02-09 00:59:02 +0300 |
commit | e04d6794d017b82f33a893bfc959cebd909d3176 (patch) | |
tree | 236e66514a1c50dd5cbe8eda2a867b733b06ac9a | |
parent | 744223afbf4b99de167d4e36ee4783ac9754901e (diff) |
Outliner Visibility: Alt+H operator to unhide all objects and collections
4 files changed, 42 insertions, 0 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 32a5a29850e..9b79823b272 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -686,6 +686,7 @@ def km_outliner(params): ("outliner.collection_exclude_set", {"type": 'E', "value": 'PRESS'}, None), ("outliner.collection_exclude_clear", {"type": 'E', "value": 'PRESS', "alt": True}, None), ("outliner.hide", {"type": 'H', "value": 'PRESS'}, None), + ("outliner.unhide_all", {"type": 'H', "value": 'PRESS', "alt": True}, None), ("object.hide_view_clear", {"type": 'H', "value": 'PRESS', "alt": True}, {"properties": [("select", False)]}), ("object.hide_view_set", {"type": 'H', "value": 'PRESS'}, diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index b0446b97597..a07fe4b9e15 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -1253,6 +1253,45 @@ void OUTLINER_OT_hide(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +static int outliner_unhide_all_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + + /* Unhide all the collections. */ + LayerCollection *lc_master = view_layer->layer_collections.first; + for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; lc_iter = lc_iter->next) { + lc_iter->flag &= ~LAYER_COLLECTION_RESTRICT_VIEW; + layer_collection_flag_recursive_set(lc_iter, LAYER_COLLECTION_RESTRICT_VIEW); + } + + /* Unhide all objects. */ + for (Base *base = view_layer->object_bases.first; base; base = base->next) { + base->flag &= ~BASE_HIDDEN; + } + + BKE_layer_collection_sync(scene, view_layer); + DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS); + + WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL); + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_unhide_all(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Unhide All"; + ot->idname = "OUTLINER_OT_unhide_all"; + ot->description = "Unhide all objects and collections"; + + /* api callbacks */ + ot->exec = outliner_unhide_all_exec; + ot->poll = outliner_view_layer_collections_editor_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /** * Populates the \param objects: ListBase with all the outliner selected objects * We store it as (Object *)LinkData->data diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 52deda50c2a..80d734c77f2 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -337,6 +337,7 @@ void OUTLINER_OT_collection_disable(struct wmOperatorType *ot); void OUTLINER_OT_collection_enable_render(struct wmOperatorType *ot); void OUTLINER_OT_collection_disable_render(struct wmOperatorType *ot); void OUTLINER_OT_hide(struct wmOperatorType *ot); +void OUTLINER_OT_unhide_all(struct wmOperatorType *ot); /* outliner_utils.c ---------------------------------------------- */ diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index e1f82ad9cda..b296b9edcd6 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -115,6 +115,7 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_collection_hide_inside); WM_operatortype_append(OUTLINER_OT_collection_show_inside); WM_operatortype_append(OUTLINER_OT_hide); + WM_operatortype_append(OUTLINER_OT_unhide_all); } void outliner_keymap(wmKeyConfig *keyconf) |