From d273f01a85385afd831a6f1e6baad3cbe919dd06 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 27 Apr 2020 17:27:52 +0200 Subject: [PATCH] Improve cursor scaling --- Sources/arm/render/Uniforms.hx | 7 +++++-- Sources/arm/ui/UISidebar.hx | 6 +++--- Sources/arm/ui/UIView2D.hx | 4 +++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/arm/render/Uniforms.hx b/Sources/arm/render/Uniforms.hx index a47af81c..917d196a 100644 --- a/Sources/arm/render/Uniforms.hx +++ b/Sources/arm/render/Uniforms.hx @@ -32,11 +32,14 @@ class Uniforms { if (Config.raw.pressure_radius && pen.down()) { val *= pen.pressure * Config.raw.pressure_sensitivity; } + var scale2d = (900 / App.h()) * Config.raw.window_scale; var decal = Context.tool == ToolDecal || Context.tool == ToolText; if (Config.raw.brush_3d && !decal) { - val *= Context.paint2d ? 0.6 : 2; + val *= Context.paint2d ? 0.55 * scale2d : 2; + } + else { + val *= scale2d; // Projection ratio } - else val *= 900 / App.h(); // Projection ratio return val; } if (link == "_brushScaleX") { diff --git a/Sources/arm/ui/UISidebar.hx b/Sources/arm/ui/UISidebar.hx index e5502c89..d1231047 100644 --- a/Sources/arm/ui/UISidebar.hx +++ b/Sources/arm/ui/UISidebar.hx @@ -759,7 +759,7 @@ class UISidebar { } var cursorImg = Res.get("cursor.k"); - var psize = Std.int(cursorImg.width * (Context.brushRadius * Context.brushNodesRadius)); + var psize = Std.int(cursorImg.width * (Context.brushRadius * Context.brushNodesRadius) * ui.SCALE()); // Clone source cursor var mouse = Input.getMouse(); @@ -781,8 +781,8 @@ class UISidebar { if (!Config.raw.brush_3d || in2dView || (decal && !Config.raw.brush_live)) { if (decal && !inNodes) { - var psizex = Std.int(256 * (Context.brushRadius * Context.brushNodesRadius * Context.brushScaleX)); - var psizey = Std.int(256 * (Context.brushRadius * Context.brushNodesRadius)); + var psizex = Std.int(256 * ui.SCALE() * (Context.brushRadius * Context.brushNodesRadius * Context.brushScaleX)); + var psizey = Std.int(256 * ui.SCALE() * (Context.brushRadius * Context.brushNodesRadius)); g.color = kha.Color.fromFloats(1, 1, 1, Context.brushOpacity); var angle = (Context.brushAngle + Context.brushNodesAngle) * (Math.PI / 180); g.pushRotation(-angle, mx, my); diff --git a/Sources/arm/ui/UIView2D.hx b/Sources/arm/ui/UIView2D.hx index f84932c4..aaa44675 100644 --- a/Sources/arm/ui/UIView2D.hx +++ b/Sources/arm/ui/UIView2D.hx @@ -233,7 +233,9 @@ class UIView2D { if (Context.tool == ToolPicker) { var cursorImg = Res.get("cursor.k"); - ui.g.drawScaledImage(cursorImg, tx + tw * Context.uvxPicked - 16, ty + th * Context.uvyPicked - 16, 32, 32); + var hsize = 16 * ui.SCALE(); + var size = hsize * 2; + ui.g.drawScaledImage(cursorImg, tx + tw * Context.uvxPicked - hsize, ty + th * Context.uvyPicked - hsize, size, size); } } ui.end();