diff options
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_collection.c | 34 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_layer.c | 41 |
2 files changed, 75 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); diff --git a/source/blender/makesrna/intern/rna_layer.c b/source/blender/makesrna/intern/rna_layer.c index 55009aa660d..a8682632e0c 100644 --- a/source/blender/makesrna/intern/rna_layer.c +++ b/source/blender/makesrna/intern/rna_layer.c @@ -212,6 +212,43 @@ int rna_LayerCollection_name_length(PointerRNA *ptr) return strlen(id->name + 2); } +static void rna_LayerCollection_flag_set(PointerRNA *ptr, const bool value, const int flag) +{ + LayerCollection *layer_collection = (LayerCollection *)ptr->data; + Collection *collection = layer_collection->collection; + + if (collection->flag & COLLECTION_IS_MASTER) { + return; + } + + if (value) { + layer_collection->flag |= flag; + } + else { + layer_collection->flag &= ~flag; + } +} + +static void rna_LayerCollection_exclude_set(PointerRNA *ptr, bool value) +{ + rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_EXCLUDE); +} + +static void rna_LayerCollection_holdout_set(PointerRNA *ptr, bool value) +{ + rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HOLDOUT); +} + +static void rna_LayerCollection_indirect_only_set(PointerRNA *ptr, bool value) +{ + rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_INDIRECT_ONLY); +} + +static void rna_LayerCollection_hide_viewport_set(PointerRNA *ptr, bool value) +{ + rna_LayerCollection_flag_set(ptr, value, LAYER_COLLECTION_HIDE); +} + static void rna_LayerCollection_exclude_update_recursive(ListBase *lb, const bool exclude) { for (LayerCollection *lc = lb->first; lc; lc = lc->next) { @@ -299,6 +336,7 @@ static void rna_def_layer_collection(BlenderRNA *brna) /* Restriction flags. */ prop = RNA_def_property(srna, "exclude", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_EXCLUDE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_exclude_set"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Exclude from View Layer", "Exclude from view layer"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -307,6 +345,7 @@ static void rna_def_layer_collection(BlenderRNA *brna) prop = RNA_def_property(srna, "holdout", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_HOLDOUT); + RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_holdout_set"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_icon(prop, ICON_HOLDOUT_OFF, 1); RNA_def_property_ui_text(prop, "Holdout", "Mask out objects in collection from view layer"); @@ -314,6 +353,7 @@ static void rna_def_layer_collection(BlenderRNA *brna) prop = RNA_def_property(srna, "indirect_only", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_INDIRECT_ONLY); + RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_indirect_only_set"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_icon(prop, ICON_INDIRECT_ONLY_OFF, 1); RNA_def_property_ui_text( @@ -325,6 +365,7 @@ static void rna_def_layer_collection(BlenderRNA *brna) prop = RNA_def_property(srna, "hide_viewport", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", LAYER_COLLECTION_HIDE); + RNA_def_property_boolean_funcs(prop, NULL, "rna_LayerCollection_hide_viewport_set"); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1); RNA_def_property_ui_text(prop, "Hide in Viewport", "Temporarily hide in viewport"); |