From 6f3e3a709f1caf378de4ffbc01e2e9e7ef96344e Mon Sep 17 00:00:00 2001 From: Falk David Date: Thu, 28 Mar 2024 12:10:36 +0100 Subject: [PATCH] Cleanup: GPv3: Use `uiItemR` for layer rows in layer tree This was previously ussing the more verbose `uiDefIconButR` but for no good reason. This now uses the `uiItemR` API. --- ...rface_template_grease_pencil_layer_tree.cc | 76 +++++-------------- 1 file changed, 17 insertions(+), 59 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 0646c4b330d..5a61b704214 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 @@ -253,66 +253,23 @@ class LayerViewItem : public AbstractTreeViewItem { void build_layer_buttons(uiLayout &row) { - uiBut *but; + uiLayout *sub; PointerRNA layer_ptr = RNA_pointer_create(&grease_pencil_.id, &RNA_GreasePencilLayer, &layer_); - uiBlock *block = uiLayoutGetBlock(&row); + sub = uiLayoutRow(&row, true); + uiLayoutSetActive(sub, layer_.parent_group().use_masks()); + const int icon_mask = (layer_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ? + ICON_CLIPUV_DEHLT : + ICON_CLIPUV_HLT; + uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon_mask); - 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, - icon, - 0, - 0, - UI_UNIT_X, - UI_UNIT_Y, - &layer_ptr, - "use_masks", - 0, - 0.0f, - 0.0f, - nullptr); - if (layer_.parent_group().use_masks()) { - UI_but_flag_enable(but, UI_BUT_INACTIVE); - } + sub = uiLayoutRow(&row, true); + uiLayoutSetActive(sub, layer_.parent_group().is_visible()); + uiItemR(sub, &layer_ptr, "hide", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE); - but = uiDefIconButR(block, - UI_BTYPE_ICON_TOGGLE, - 0, - ICON_NONE, - 0, - 0, - UI_UNIT_X, - UI_UNIT_Y, - &layer_ptr, - "hide", - 0, - 0.0f, - 0.0f, - nullptr); - if (!layer_.parent_group().is_visible()) { - UI_but_flag_enable(but, UI_BUT_INACTIVE); - } - - but = uiDefIconButR(block, - UI_BTYPE_ICON_TOGGLE, - 0, - ICON_NONE, - 0, - 0, - UI_UNIT_X, - UI_UNIT_Y, - &layer_ptr, - "lock", - 0, - 0.0f, - 0.0f, - nullptr); - if (layer_.parent_group().is_locked()) { - UI_but_flag_enable(but, UI_BUT_INACTIVE); - } + sub = uiLayoutRow(&row, true); + uiLayoutSetActive(sub, !layer_.parent_group().is_locked()); + uiItemR(sub, &layer_ptr, "lock", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE); } }; @@ -382,9 +339,10 @@ 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_HIDE_MASKS) == 0 ? ICON_CLIPUV_DEHLT : - ICON_CLIPUV_HLT; - uiItemR(&row, &group_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon); + 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); }