From cfc8ff74a3faa85925905889b8887b3394761ffd Mon Sep 17 00:00:00 2001 From: Guillaume Piolat Date: Wed, 9 Aug 2023 15:55:59 +0200 Subject: [PATCH] UIKnob (the PBR Knob) gets 3 new @ScriptProperty: emissive emissiveHovered emissiveDragged to help with usability of small PBR knobs. --- pbrwidgets/dplug/pbrwidgets/knob.d | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pbrwidgets/dplug/pbrwidgets/knob.d b/pbrwidgets/dplug/pbrwidgets/knob.d index 2fe754db..7200deac 100644 --- a/pbrwidgets/dplug/pbrwidgets/knob.d +++ b/pbrwidgets/dplug/pbrwidgets/knob.d @@ -38,9 +38,12 @@ nothrow: // Modify these public members to customize knobs! // @ScriptProperty float knobRadius = 0.75f; - @ScriptProperty RGBA knobDiffuse = RGBA(233, 235, 236, 0); + @ScriptProperty RGBA knobDiffuse = RGBA(233, 235, 236, 0); // Last channel is ignored. @ScriptProperty RGBA knobMaterial = RGBA(0, 255, 128, 255); @ScriptProperty KnobStyle style = KnobStyle.thumb; + @ScriptProperty ubyte emissive = 0; + @ScriptProperty ubyte emissiveHovered = 30; + @ScriptProperty ubyte emissiveDragged = 0; // LEDs @ScriptProperty int numLEDs = 7; @@ -228,11 +231,11 @@ nothrow: float posEdgeX = center.x + sin(angle) * depthRadius2; float posEdgeY = center.y - cos(angle) * depthRadius2; - ubyte emissive = 0; + ubyte emissiveComputed = emissive; if (_shouldBeHighlighted) - emissive = 30; + emissiveComputed = emissiveHovered; if (isDragged) - emissive = 0; + emissiveComputed = emissiveDragged; if (style == KnobStyle.thumb) { @@ -255,7 +258,7 @@ nothrow: croppedDepth.aaSoftDisc!1.2f(center.x - bx, center.y - by, 2, knobRadiusPx, depth); } RGBA knobDiffuseLit = knobDiffuse; - knobDiffuseLit.a = emissive; + knobDiffuseLit.a = emissiveComputed; croppedDiffuse.aaSoftDisc(center.x - bx, center.y - by, knobRadiusPx - 1, knobRadiusPx, knobDiffuseLit); croppedMaterial.aaSoftDisc(center.x - bx, center.y - by, knobRadiusPx - 5, knobRadiusPx, knobMaterial);