Fix: GPv3: Function `use_masks` returns wrong value

This fixes an issue where the `use_masks` functions on layers
and groups returned the wrong value.
The issue was that the root group doesn't have this flag set
which then propagates to all the layers and groups.
To fix this we invert the `GP_LAYER_TREE_NODE_USE_MASKS` flag (now called `GP_LAYER_TREE_NODE_HIDE_MASKS`).

The API still uses the `use_masks` function.
This commit is contained in:
Falk David 2024-03-14 15:25:17 +01:00
parent af7a68d31f
commit 6a320524b9
5 changed files with 11 additions and 11 deletions

View File

@ -692,7 +692,7 @@ inline bool TreeNode::use_onion_skinning() const
}
inline bool TreeNode::use_masks() const
{
return ((this->flag & GP_LAYER_TREE_NODE_USE_MASKS) != 0) &&
return ((this->flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0) &&
(!this->parent_group() || this->parent_group()->as_node().use_masks());
}
inline bool TreeNode::is_child_of(const LayerGroup &group) const

View File

@ -427,7 +427,7 @@ void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, b
(gpl->onion_flag & GP_LAYER_ONIONSKIN),
GP_LAYER_TREE_NODE_USE_ONION_SKINNING);
SET_FLAG_FROM_TEST(
new_layer.base.flag, (gpl->flag & GP_LAYER_USE_MASK), GP_LAYER_TREE_NODE_USE_MASKS);
new_layer.base.flag, (gpl->flag & GP_LAYER_USE_MASK) == 0, GP_LAYER_TREE_NODE_HIDE_MASKS);
new_layer.blend_mode = int8_t(gpl->blend_mode);

View File

@ -256,8 +256,8 @@ class LayerViewItem : public AbstractTreeViewItem {
uiBlock *block = uiLayoutGetBlock(&row);
const int icon = (layer_.base.flag & GP_LAYER_TREE_NODE_USE_MASKS) != 0 ? ICON_CLIPUV_DEHLT :
ICON_CLIPUV_HLT;
const int icon = (layer_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ? ICON_CLIPUV_DEHLT :
ICON_CLIPUV_HLT;
but = uiDefIconButR(block,
UI_BTYPE_ICON_TOGGLE,
0,
@ -380,8 +380,8 @@ class LayerGroupViewItem : public AbstractTreeViewItem {
PointerRNA group_ptr = RNA_pointer_create(
&grease_pencil_.id, &RNA_GreasePencilLayerGroup, &group_);
const int icon = (group_.base.flag & GP_LAYER_TREE_NODE_USE_MASKS) != 0 ? ICON_CLIPUV_DEHLT :
ICON_CLIPUV_HLT;
const int icon = (group_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ? ICON_CLIPUV_DEHLT :
ICON_CLIPUV_HLT;
uiItemR(&row, &group_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon);
uiItemR(&row, &group_ptr, "hide", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE);
uiItemR(&row, &group_ptr, "lock", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE);

View File

@ -240,7 +240,7 @@ typedef enum GreasePencilLayerTreeNodeFlag {
GP_LAYER_TREE_NODE_USE_LIGHTS = (1 << 4),
GP_LAYER_TREE_NODE_USE_ONION_SKINNING = (1 << 5),
GP_LAYER_TREE_NODE_EXPANDED = (1 << 6),
GP_LAYER_TREE_NODE_USE_MASKS = (1 << 7),
GP_LAYER_TREE_NODE_HIDE_MASKS = (1 << 7),
} GreasePencilLayerTreeNodeFlag;
struct GreasePencilLayerTreeGroup;

View File

@ -408,8 +408,8 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
/* Use Masks. */
prop = RNA_def_property(srna, "use_masks", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(
prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_USE_MASKS);
RNA_def_property_boolean_negative_sdna(
prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_HIDE_MASKS);
RNA_def_property_ui_text(
prop,
"Use Masks",
@ -535,8 +535,8 @@ static void rna_def_grease_pencil_layer_group(BlenderRNA *brna)
/* Use Masks. */
prop = RNA_def_property(srna, "use_masks", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(
prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_USE_MASKS);
RNA_def_property_boolean_negative_sdna(
prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_HIDE_MASKS);
RNA_def_property_ui_text(prop,
"Use Masks",
"The visibility of drawings in the layers in this group is affected by "