diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2019-05-31 19:17:16 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2019-05-31 20:02:26 +0300 |
commit | d0258abdd7db5aee66da78008df897d8f444b987 (patch) | |
tree | 31677457c0365f554fd99211d5d9c145199d4402 /source/blender/makesrna/intern/rna_collection.c | |
parent | 3f23299403d4f20fa5c8ef799bde940d0c291228 (diff) |
Fix Outliner: New collections are hidden
Users could change the master collection flags, but they should not.
That would not effectively affect the master collection objects
(depsgraph flag evaluation ignores master collection flags).
However we use the layer collection flags of the parent collection when creating
a new child collection.
We *could* solve this differently by creating a new RNA type for the
master collection (and layer collection) and hook this with rna refine.
But this patch seems to work well enough and it is simpler.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D4981
Diffstat (limited to 'source/blender/makesrna/intern/rna_collection.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_collection.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_collection.c b/source/blender/makesrna/intern/rna_collection.c index ae944f59a35..99606a929a9 100644 --- a/source/blender/makesrna/intern/rna_collection.c +++ b/source/blender/makesrna/intern/rna_collection.c @@ -267,6 +267,37 @@ static bool rna_Collection_children_override_apply(Main *bmain, return true; } +static void rna_Collection_flag_set(PointerRNA *ptr, const bool value, const int flag) +{ + Collection *collection = (Collection *)ptr->data; + + if (collection->flag & COLLECTION_IS_MASTER) { + return; + } + + if (value) { + collection->flag |= flag; + } + else { + collection->flag &= ~flag; + } +} + +static void rna_Collection_hide_select_set(PointerRNA *ptr, bool value) +{ + rna_Collection_flag_set(ptr, value, COLLECTION_RESTRICT_SELECT); +} + +static void rna_Collection_hide_viewport_set(PointerRNA *ptr, bool value) +{ + rna_Collection_flag_set(ptr, value, COLLECTION_RESTRICT_VIEWPORT); +} + +static void rna_Collection_hide_render_set(PointerRNA *ptr, bool value) +{ + rna_Collection_flag_set(ptr, value, COLLECTION_RESTRICT_RENDER); +} + static void rna_Collection_flag_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Collection *collection = (Collection *)ptr->data; @@ -402,6 +433,7 @@ void RNA_def_collections(BlenderRNA *brna) /* Flags */ prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_SELECT); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Collection_hide_select_set"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1); @@ -410,6 +442,7 @@ void RNA_def_collections(BlenderRNA *brna) prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_VIEWPORT); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Collection_hide_viewport_set"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1); @@ -418,6 +451,7 @@ void RNA_def_collections(BlenderRNA *brna) prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", COLLECTION_RESTRICT_RENDER); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Collection_hide_render_set"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1); |