diff --git a/Sources/arm/Enums.hx b/Sources/arm/Enums.hx index 08c7732f..394253c7 100644 --- a/Sources/arm/Enums.hx +++ b/Sources/arm/Enums.hx @@ -209,6 +209,7 @@ package arm; var View2DLayer = 0; var View2DAsset = 1; var View2DFont = 2; + var View2DNode = 3; } @:enum abstract View2DLayerMode(Int) from Int to Int { diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 2e073b92..ac563557 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -7,6 +7,7 @@ import zui.Zui; import zui.Id; import zui.Nodes; import iron.system.Input; +import iron.system.Time; import arm.shader.NodesMaterial; import arm.shader.MaterialParser; import arm.node.NodesBrush; @@ -276,8 +277,28 @@ class UINodes { isNodeMenuOperation = true; }); } + if (canvasType == CanvasMaterial) { + menuSeparator(uiMenu); + if (menuButton(uiMenu, tr("2D View"))) { + UISidebar.inst.show2DView(View2DNode); + } + } uiMenu.enabled = true; - }, 5); + }, canvasType == CanvasMaterial ? 6 : 5); + } + } + if (ui.inputReleased) { + var nodes = getNodes(); + var canvas = getCanvas(true); + for (node in canvas.nodes) { + if (ui.getInputInRect(ui._windowX + nodes.NODE_X(node), ui._windowY + nodes.NODE_Y(node), nodes.NODE_W(node), nodes.NODE_H(canvas, node))) { + if (node == nodes.nodesSelected[0]) { + UIView2D.inst.hwnd.redraws = 2; + if (Time.time() - Context.selectTime < 0.25) UISidebar.inst.show2DView(View2DNode); + Context.selectTime = Time.time(); + } + break; + } } } } @@ -553,6 +574,9 @@ class UINodes { } else { Layers.isFillMaterial() ? Layers.updateFillLayers() : RenderUtil.makeMaterialPreview(); + if (UIView2D.inst.show && UIView2D.inst.type == View2DNode) { + UIView2D.inst.hwnd.redraws = 2; + } } UISidebar.inst.hwnd1.redraws = 2; @@ -1070,4 +1094,13 @@ class UINodes { #end return ui.button(Config.buttonSpacing + text, Config.buttonAlign, label); } + + static function menuSeparator(ui: Zui) { + ui._y++; + #if arm_touchui + ui.fill(0, 0, ui._w / ui.SCALE(), 1, ui.t.ACCENT_SELECT_COL); + #else + ui.fill(22, 0, ui._w / ui.SCALE() - 22, 1, ui.t.ACCENT_SELECT_COL); + #end + } } diff --git a/Sources/arm/ui/UIView2D.hx b/Sources/arm/ui/UIView2D.hx index d38a49a2..2af2238c 100644 --- a/Sources/arm/ui/UIView2D.hx +++ b/Sources/arm/ui/UIView2D.hx @@ -147,9 +147,12 @@ class UIView2D { else if (type == View2DAsset) { tex = Project.getImage(Context.texture); } - else { // View2DFont + else if (type == View2DFont) { tex = Context.font.image; } + else { // View2DNode + tex = Context.nodePreview; + } var th = tw; if (tex != null) { @@ -222,10 +225,12 @@ class UIView2D { assetNames[i] = asset.name; } } - else { // View2DFont + else if (type == View2DFont) { h.text = Context.font.name; Context.font.name = ui.textInput(h, "", Right); } + // else { // View2DNode + // } if (h.changed) UISidebar.inst.hwnd0.redraws = 2; ui.t.ACCENT_COL = ACCENT_COL; diff --git a/Sources/arm/util/RenderUtil.hx b/Sources/arm/util/RenderUtil.hx index 12242892..c4283588 100644 --- a/Sources/arm/util/RenderUtil.hx +++ b/Sources/arm/util/RenderUtil.hx @@ -338,8 +338,6 @@ class RenderUtil { RenderPathPaint.liveLayerDrawn = 0; RenderPathDeferred.drawGbuffer(); - - // Paint brush preview var _brushRadius = Context.brushRadius; var _brushOpacity = Context.brushOpacity;