diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index ffb32055..2b9a5ebc 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -461,8 +461,9 @@ class App { Krom.setMouseCursor(0); // Arrow isDragging = false; } - if (Context.colorPickerCallback != null && mouse.released()) { + if (Context.colorPickerCallback != null && (mouse.released() || mouse.released("right"))) { Context.colorPickerCallback = null; + Context.selectTool(Context.colorPickerPreviousTool); } handleDropPaths(); diff --git a/Sources/arm/Context.hx b/Sources/arm/Context.hx index f2a1ea7b..dd6c8e5e 100644 --- a/Sources/arm/Context.hx +++ b/Sources/arm/Context.hx @@ -66,6 +66,7 @@ class Context { public static var swatch: TSwatchColor; public static var pickedColor: TSwatchColor = Project.makeSwatch(); public static var colorPickerCallback: TSwatchColor->Void = null; + public static var colorPickerPreviousTool = ToolBrush; public static var materialIdPicked = 0; public static var uvxPicked = 0.0; public static var uvyPicked = 0.0; diff --git a/Sources/arm/ui/TabSwatches.hx b/Sources/arm/ui/TabSwatches.hx index adf9c217..a211b7ad 100644 --- a/Sources/arm/ui/TabSwatches.hx +++ b/Sources/arm/ui/TabSwatches.hx @@ -132,20 +132,26 @@ class TabSwatches { h.color = Context.swatch.base; Context.swatch.base = zui.Ext.colorWheel(ui, h, false, null, 11 * ui.t.ELEMENT_H * ui.SCALE(), true, function () { + Context.colorPickerPreviousTool = Context.tool; Context.selectTool(ToolPicker); Context.colorPickerCallback = function (color: TSwatchColor) { - Project.raw.swatches[i].base = color.base; + Project.raw.swatches[i] = Project.cloneSwatch(color); }; }); - var hopacity = Id.handle({ value: Context.swatch.opacity }); + var hopacity = Id.handle(); + hopacity.value = Context.swatch.opacity; Context.swatch.opacity = ui.slider(hopacity, "Opacity", 0, 1, true); - var hocclusion = Id.handle({ value: Context.swatch.occlusion }); + var hocclusion = Id.handle(); + hocclusion.value = Context.swatch.occlusion; Context.swatch.occlusion = ui.slider(hocclusion, "Occlusion", 0, 1, true); - var hroughness = Id.handle({ value: Context.swatch.roughness }); + var hroughness = Id.handle(); + hroughness.value = Context.swatch.roughness; Context.swatch.roughness = ui.slider(hroughness, "Roughness", 0, 1, true); - var hmetallic = Id.handle({ value: Context.swatch.metallic }); + var hmetallic = Id.handle(); + hmetallic.value = Context.swatch.metallic; Context.swatch.metallic = ui.slider(hmetallic, "Metallic", 0, 1, true); - var hheight = Id.handle({ value: Context.swatch.height }); + var hheight = Id.handle(); + hheight.value = Context.swatch.height; Context.swatch.height = ui.slider(hheight, "Height", 0, 1, true); if (ui.changed || ui.isTyping) UIMenu.keepOpen = true; diff --git a/Sources/arm/ui/UINodes.hx b/Sources/arm/ui/UINodes.hx index 0c8d6d15..d5a5ec2b 100644 --- a/Sources/arm/ui/UINodes.hx +++ b/Sources/arm/ui/UINodes.hx @@ -683,6 +683,7 @@ class UINodes { } if (nodes.colorPickerCallback != null) { + Context.colorPickerPreviousTool = Context.tool; Context.selectTool(ToolPicker); var tmp = nodes.colorPickerCallback; Context.colorPickerCallback = function(color: TSwatchColor) { diff --git a/Sources/arm/ui/UISidebar.hx b/Sources/arm/ui/UISidebar.hx index 62124480..ff52efd5 100644 --- a/Sources/arm/ui/UISidebar.hx +++ b/Sources/arm/ui/UISidebar.hx @@ -815,7 +815,7 @@ class UISidebar { } // Show picked material next to cursor - if (Context.tool == ToolPicker && Context.pickerSelectMaterial) { + if (Context.tool == ToolPicker && Context.pickerSelectMaterial && Context.colorPickerCallback == null) { var img = Context.material.imageIcon; #if kha_opengl g.drawScaledImage(img, mx + 10, my + 10 + img.height, img.width, -img.height); @@ -823,6 +823,12 @@ class UISidebar { g.drawImage(img, mx + 10, my + 10); #end } + if (Context.tool == ToolPicker && Context.colorPickerCallback != null) { + var img = Res.get("icons.k"); + var rect = Res.tile50(img, ToolPicker, 0); + + g.drawSubImage(img, mx + 10, my + 10, rect.x, rect.y, rect.w, rect.h); + } var cursorImg = Res.get("cursor.k"); var psize = Std.int(cursorImg.width * (Context.brushRadius * Context.brushNodesRadius) * ui.SCALE());