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.
This commit is contained in:
Falk David 2024-03-28 12:35:12 +01:00
parent 6f3e3a709f
commit e17bb40941
1 changed files with 21 additions and 6 deletions

View File

@ -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);
}
};