diff --git a/source/blender/blenkernel/BKE_grease_pencil.hh b/source/blender/blenkernel/BKE_grease_pencil.hh index c0a2305ccda..5f9ebd83d71 100644 --- a/source/blender/blenkernel/BKE_grease_pencil.hh +++ b/source/blender/blenkernel/BKE_grease_pencil.hh @@ -287,6 +287,9 @@ class LayerGroup : public ::GreasePencilLayerTreeGroup { return this->base.name; } + bool is_visible() const; + bool is_locked() const; + /** * Adds a group at the end of this group. */ diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index 2216cf576a7..198e9f79686 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -490,12 +490,12 @@ Map &Layer::frames_for_write() bool Layer::is_visible() const { - return (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0; + return this->parent_group().is_visible() && (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0; } bool Layer::is_locked() const { - return (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0; + return this->parent_group().is_locked() || (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0; } bool Layer::insert_frame(int frame_number, const GreasePencilFrame &frame) @@ -616,6 +616,24 @@ LayerGroup::~LayerGroup() this->runtime = nullptr; } +bool LayerGroup::is_visible() const +{ + if (this->base.parent) { + return this->base.parent->wrap().is_visible() && + (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0; + } + return (this->base.flag & GP_LAYER_TREE_NODE_HIDE) == 0; +} + +bool LayerGroup::is_locked() const +{ + if (this->base.parent) { + return this->base.parent->wrap().is_locked() || + (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0; + } + return (this->base.flag & GP_LAYER_TREE_NODE_LOCKED) != 0; +} + LayerGroup &LayerGroup::add_group(LayerGroup *group) { BLI_assert(group != nullptr);