Outliner Visibility: Alt+H operator to unhide all objects and collections
authorDalai Felinto <dfelinto@gmail.com>
Fri, 8 Feb 2019 21:52:28 +0000 (19:52 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 8 Feb 2019 21:59:02 +0000 (19:59 -0200)
release/scripts/presets/keyconfig/keymap_data/blender_default.py
source/blender/editors/space_outliner/outliner_collections.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_ops.c

index 32a5a29..9b79823 100644 (file)
@@ -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'},
index b0446b9..a07fe4b 100644 (file)
@@ -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
index 52deda5..80d734c 100644 (file)
@@ -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 ---------------------------------------------- */
 
index e1f82ad..b296b9e 100644 (file)
@@ -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)