From e17bb40941f2e787637e45e9dbb1749383e85f5c Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 28 Mar 2024 12:35:12 +0100 Subject: [PATCH] UI: GPv3: Disable buttons for layer group in layer tree We disable the button for a layers depending on the state of the parent group. E.g. if the parent group is hidden the layer button to toggle the visibility was disabled to indicate that toggling it won't actually change the visibility of the layer (since the whole group is hidden). This wasn't the case for layer groups though and this change fixes that. --- ...rface_template_grease_pencil_layer_tree.cc | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc index 5a61b704214..ada62f38c7f 100644 --- a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc @@ -246,7 +246,7 @@ class LayerViewItem : public AbstractTreeViewItem { { uiBut *but = uiItemL_ex( &row, layer_.name().c_str(), ICON_OUTLINER_DATA_GP_LAYER, false, false); - if (layer_.is_locked() || !layer_.parent_group().is_visible()) { + if (!layer_.is_editable()) { UI_but_disable(but, "Layer is locked or not visible"); } } @@ -329,22 +329,37 @@ class LayerGroupViewItem : public AbstractTreeViewItem { { uiItemS_ex(&row, 0.8f); uiBut *but = uiItemL_ex(&row, group_.name().c_str(), ICON_FILE_FOLDER, false, false); - if (group_.is_locked()) { - UI_but_disable(but, "Layer Group is locked"); + if (!group_.is_editable()) { + UI_but_disable(but, "Layer Group is locked or not visible"); } } void build_layer_group_buttons(uiLayout &row) { + uiLayout *sub; PointerRNA group_ptr = RNA_pointer_create( &grease_pencil_.id, &RNA_GreasePencilLayerGroup, &group_); + sub = uiLayoutRow(&row, true); + if (group_.as_node().parent_group()) { + uiLayoutSetActive(sub, group_.as_node().parent_group()->use_masks()); + } const int icon_mask = (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_mask); - 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); + uiItemR(sub, &group_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon_mask); + + sub = uiLayoutRow(&row, true); + if (group_.as_node().parent_group()) { + uiLayoutSetActive(sub, group_.as_node().parent_group()->is_visible()); + } + uiItemR(sub, &group_ptr, "hide", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE); + + sub = uiLayoutRow(&row, true); + if (group_.as_node().parent_group()) { + uiLayoutSetActive(sub, !group_.as_node().parent_group()->is_locked()); + } + uiItemR(sub, &group_ptr, "lock", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE); } };