Nodes: Hide the node preview button when the overlays are disabled

When the overlays are hidden or the previews overlays are hidden, it is
more consistent to have the preview toggle button hidden than shown.

This patch also removes the preview rendering when the previews are
hidden.

Pull Request: https://projects.blender.org/blender/blender/pulls/110949
This commit is contained in:
Colin Marmond
2023-08-09 14:04:11 +02:00
committed by Brecht Van Lommel
parent 6afbb66a53
commit c63bcbf906
3 changed files with 14 additions and 7 deletions

View File

@@ -2213,7 +2213,8 @@ static void node_draw_basis(const bContext &C,
bNodeInstanceKey key)
{
const float iconbutw = NODE_HEADER_ICON_SIZE;
const bool show_preview = (snode.overlay.flag & SN_OVERLAY_SHOW_PREVIEWS) &&
const bool show_preview = (snode.overlay.flag & SN_OVERLAY_SHOW_OVERLAYS) &&
(snode.overlay.flag & SN_OVERLAY_SHOW_PREVIEWS) &&
(node.flag & NODE_PREVIEW) &&
(U.experimental.use_shader_node_previews ||
ntree.type != NTREE_SHADER);
@@ -2302,7 +2303,7 @@ static void node_draw_basis(const bContext &C,
float iconofs = rct.xmax - 0.35f * U.widget_unit;
/* Preview. */
if (node_is_previewable(ntree, node)) {
if (node_is_previewable(snode, ntree, node)) {
iconofs -= iconbutw;
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
uiBut *but = uiDefIconBut(&block,
@@ -3511,7 +3512,8 @@ static void draw_nodetree(const bContext &C,
}
else if (ntree.type == NTREE_SHADER && U.experimental.use_shader_node_previews &&
BKE_scene_uses_shader_previews(CTX_data_scene(&C)) &&
U.experimental.use_shader_node_previews)
snode->overlay.flag & SN_OVERLAY_SHOW_OVERLAYS &&
snode->overlay.flag & SN_OVERLAY_SHOW_PREVIEWS)
{
tree_draw_ctx.nested_group_infos = get_nested_previews(C, *snode);
}