diff --git a/paint/sources/box_preferences.ts b/paint/sources/box_preferences.ts index 4d752fde..9aefffd1 100644 --- a/paint/sources/box_preferences.ts +++ b/paint/sources/box_preferences.ts @@ -52,6 +52,21 @@ function box_preferences_show() { h_node_previews.b = config_raw.node_previews; } config_raw.node_previews = ui_check(h_node_previews, tr("Node Previews")); + if (h_node_previews.changed) { + for (let i: i32 = 0; i < project_materials.length; ++i) { + let c: ui_node_canvas_t = project_materials[i].canvas; + for (let j: i32 = 0; j < c.nodes.length; ++j) { + let n: ui_node_t = c.nodes[j]; + if (config_raw.node_previews) { + n.flags |= _ui_node_flag_t.PREVIEW; + } + else { + n.flags &= ~_ui_node_flag_t.PREVIEW; + } + } + } + ui_nodes_hwnd.redraws = 2; + } if (ui.is_hovered) { ui_tooltip(tr("Show node preview on each node by default")); } diff --git a/paint/sources/slot_material.ts b/paint/sources/slot_material.ts index fc678aba..b32c421a 100644 --- a/paint/sources/slot_material.ts +++ b/paint/sources/slot_material.ts @@ -62,9 +62,19 @@ function slot_material_create(m: material_data_t = null, c: ui_node_canvas_t = n raw.canvas = util_clone_canvas(c); } + if (config_raw.node_previews) { + for (let i: i32 = 0; i < raw.canvas.nodes.length; ++i) { + let n: ui_node_t = raw.canvas.nodes[i]; + n.flags |= _ui_node_flag_t.PREVIEW; + } + } + ///if (arm_android || arm_ios) raw.nodes.pan_x -= 50; // Center initial position + ///else + raw.nodes.pan_x += 110; ///end + raw.nodes.pan_y += 120; return raw; } diff --git a/paint/sources/ui_nodes.ts b/paint/sources/ui_nodes.ts index 55176076..0d8d96b6 100644 --- a/paint/sources/ui_nodes.ts +++ b/paint/sources/ui_nodes.ts @@ -1458,6 +1458,9 @@ function ui_nodes_make_node_preview() { let nodes: ui_node_t[] = ui_nodes_get_canvas().nodes; let node: ui_node_t = ui_get_node(nodes, ui_nodes.nodes_selected_id[0]); + if (node == null) { + return; + } context_raw.node_preview_name = node.name; if (node.type == "LAYER" ||