Outliner visibility: Prevent changing linked objects and collections

We still change their base/layer collection visibility, just not what would change the
original ID datablock.
This commit is contained in:
Dalai Felinto
2019-02-08 20:09:37 -02:00
parent e04d6794d0
commit 191b8951f7
3 changed files with 35 additions and 16 deletions

View File

@@ -1005,9 +1005,11 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
bool depsgraph_need_update = false;
LayerCollection *lc_master = view_layer->layer_collections.first;
if (lc->collection->flag & COLLECTION_RESTRICT_VIEW) {
lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
depsgraph_need_update = true;
if (lc->collection->id.lib == NULL) {
if (lc->collection->flag & COLLECTION_RESTRICT_VIEW) {
lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
depsgraph_need_update = true;
}
}
if (!extend) {
@@ -1027,9 +1029,11 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
}
while (lc_parent != lc) {
if (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEW) {
lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
depsgraph_need_update = true;
if (lc_parent->collection->id.lib == NULL) {
if (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEW) {
lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
depsgraph_need_update = true;
}
}
lc_parent->flag &= ~LAYER_COLLECTION_RESTRICT_VIEW;
@@ -1084,7 +1088,10 @@ bool BKE_layer_collection_set_visible(ViewLayer *view_layer, LayerCollection *lc
{
bool depsgraph_changed = false;
if (visible && ((lc->collection->flag & COLLECTION_RESTRICT_VIEW) != 0)) {
if (visible &&
(lc->collection->id.lib == NULL) &&
((lc->collection->flag & COLLECTION_RESTRICT_VIEW) != 0))
{
lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
depsgraph_changed = true;
}

View File

@@ -1065,7 +1065,9 @@ static int collection_flag_exec(bContext *C, wmOperator *op)
GSET_ITER(collections_to_edit_iter, data.collections_to_edit) {
LayerCollection *layer_collection = BLI_gsetIterator_getKey(&collections_to_edit_iter);
Collection *collection = layer_collection->collection;
if (collection->id.lib != NULL) {
continue;
}
if (clear) {
collection->flag &= ~flag;
}

View File

@@ -276,13 +276,16 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2)
bool do_isolate = (win->eventstate->ctrl != 0) && !do_disable;
bool extend = (win->eventstate->shift != 0);
bool depsgraph_changed = false;
const bool is_editable = BASE_EDITABLE((View3D *)NULL, base);
if (do_disable) {
ob->restrictflag |= OB_RESTRICT_VIEW;
depsgraph_changed = true;
if (is_editable) {
ob->restrictflag |= OB_RESTRICT_VIEW;
depsgraph_changed = true;
}
}
else if (do_isolate) {
depsgraph_changed = (ob->restrictflag & OB_RESTRICT_VIEW) != 0;
depsgraph_changed = is_editable && ((ob->restrictflag & OB_RESTRICT_VIEW) != 0);
if (!extend) {
/* Make only one base visible. */
@@ -296,11 +299,16 @@ static void hidebutton_base_flag_cb(bContext *C, void *poin, void *poin2)
/* Toggle visibility of one base. */
base->flag ^= BASE_HIDDEN;
}
ob->restrictflag &= ~OB_RESTRICT_VIEW;
if (is_editable) {
ob->restrictflag &= ~OB_RESTRICT_VIEW;
}
}
else if (ob->restrictflag & OB_RESTRICT_VIEW) {
ob->restrictflag &= ~OB_RESTRICT_VIEW;
base->flag &= ~BASE_HIDDEN;
if (is_editable) {
ob->restrictflag &= ~OB_RESTRICT_VIEW;
base->flag &= ~BASE_HIDDEN;
}
depsgraph_changed = true;
}
else {
@@ -334,8 +342,10 @@ static void hidebutton_layer_collection_flag_cb(bContext *C, void *poin, void *p
bool depsgraph_changed = false;
if (do_disable) {
collection->flag |= COLLECTION_RESTRICT_VIEW;
depsgraph_changed = true;
if (collection->id.lib == NULL) {
collection->flag |= COLLECTION_RESTRICT_VIEW;
depsgraph_changed = true;
}
}
else if (do_isolate) {
depsgraph_changed |= BKE_layer_collection_isolate(scene, view_layer, lc, extend);