diff --git a/pbrwidgets/dplug/pbrwidgets/bargraph.d b/pbrwidgets/dplug/pbrwidgets/bargraph.d index 742a3557..7e0bfd30 100644 --- a/pbrwidgets/dplug/pbrwidgets/bargraph.d +++ b/pbrwidgets/dplug/pbrwidgets/bargraph.d @@ -13,10 +13,9 @@ import std.math; import dplug.gui.element; import dplug.core.sync; import dplug.core.math; -import std.algorithm.comparison: clamp; // Vertical bargraphs made of LEDs -class UIBargraph : UIElement +deprecated("Will be removed in Dplug v14") class UIBargraph : UIElement { public: nothrow: @@ -128,7 +127,8 @@ nothrow: foreach(i; 0..values.length) { _values[i] = linmap!float(values[i], _minValue, _maxValue, 0, 1); - _values[i] = clamp!float(_values[i], 0, 1); + if (_values[i] < 0) _values[i] = 0; + if (_values[i] > 1) _values[i] = 1; } _valueMutex.unlock(); } diff --git a/pbrwidgets/dplug/pbrwidgets/imageknob.d b/pbrwidgets/dplug/pbrwidgets/imageknob.d index 7f63e424..fc9b24ed 100644 --- a/pbrwidgets/dplug/pbrwidgets/imageknob.d +++ b/pbrwidgets/dplug/pbrwidgets/imageknob.d @@ -6,7 +6,7 @@ License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) */ module dplug.pbrwidgets.imageknob; -import std.math; +import std.math: PI_2, cos, sin; import dplug.math.vector; import dplug.math.box; diff --git a/pbrwidgets/dplug/pbrwidgets/knob.d b/pbrwidgets/dplug/pbrwidgets/knob.d index 7200deac..ae51e264 100644 --- a/pbrwidgets/dplug/pbrwidgets/knob.d +++ b/pbrwidgets/dplug/pbrwidgets/knob.d @@ -7,8 +7,7 @@ Authors: Guillaume Piolat */ module dplug.pbrwidgets.knob; -import std.math; -import std.algorithm.comparison; +import std.math: PI, exp, abs, sin, cos; import dplug.core.math; @@ -151,7 +150,9 @@ nothrow: // when dragged, trail is two times brighter if (isDragged) { - litTrail.a = cast(ubyte) min(255, 2 * litTrail.a); + int alpha = 2 * litTrail.a; + if (alpha > 255) alpha = 255; + litTrail.a = cast(ubyte) alpha; } foreach(dirtyRect; dirtyRects) @@ -225,8 +226,12 @@ nothrow: // Draw knob // float angle = getValueAngle + PI * 0.5f; - float depthRadius = max(knobRadiusPx * 3.0f / 5.0f, 0); - float depthRadius2 = max(knobRadiusPx * 3.0f / 5.0f, 0); + float depthRadius = knobRadiusPx * 3.0f / 5.0f; + if (depthRadius < 0) + depthRadius = 0; + float depthRadius2 = knobRadiusPx * 3.0f / 5.0f; + if (depthRadius2 < 0) + depthRadius2 = 0; float posEdgeX = center.x + sin(angle) * depthRadius2; float posEdgeY = center.y - cos(angle) * depthRadius2; @@ -273,7 +278,9 @@ nothrow: float t = -1 + 2 * abs(disp - PI) / PI; - float LEDRadius = max(0.0f, lerp(LEDRadiusMin, LEDRadiusMax, t)); + float LEDRadius = lerp(LEDRadiusMin, LEDRadiusMax, t); + if (LEDRadius < 0) + LEDRadius = 0; float smallRadius = knobRadiusPx * LEDRadius * 0.714f; float largerRadius = knobRadiusPx * LEDRadius; diff --git a/pbrwidgets/dplug/pbrwidgets/label.d b/pbrwidgets/dplug/pbrwidgets/label.d index 43b3666d..d3aa695f 100644 --- a/pbrwidgets/dplug/pbrwidgets/label.d +++ b/pbrwidgets/dplug/pbrwidgets/label.d @@ -7,7 +7,6 @@ Authors: Guillaume Piolat */ module dplug.pbrwidgets.label; -import std.math; import dplug.gui.element; import dplug.client.params; diff --git a/pbrwidgets/dplug/pbrwidgets/logo.d b/pbrwidgets/dplug/pbrwidgets/logo.d index 2db5189d..32590a69 100644 --- a/pbrwidgets/dplug/pbrwidgets/logo.d +++ b/pbrwidgets/dplug/pbrwidgets/logo.d @@ -7,7 +7,7 @@ Authors: Guillaume Piolat */ module dplug.pbrwidgets.logo; -import std.math; +import std.math: exp, abs; import dplug.gui.element; import dplug.core.math; import dplug.graphics; diff --git a/pbrwidgets/dplug/pbrwidgets/onoffswitch.d b/pbrwidgets/dplug/pbrwidgets/onoffswitch.d index 5394171c5..44c5a023 100644 --- a/pbrwidgets/dplug/pbrwidgets/onoffswitch.d +++ b/pbrwidgets/dplug/pbrwidgets/onoffswitch.d @@ -7,7 +7,7 @@ Authors: Guillaume Piolat */ module dplug.pbrwidgets.onoffswitch; -import std.math; +import std.math: exp, abs; import dplug.core.math; import dplug.gui.element; import dplug.gui.bufferedelement; diff --git a/pbrwidgets/dplug/pbrwidgets/paramhint.d b/pbrwidgets/dplug/pbrwidgets/paramhint.d index 8baa7a90..de5582d9 100644 --- a/pbrwidgets/dplug/pbrwidgets/paramhint.d +++ b/pbrwidgets/dplug/pbrwidgets/paramhint.d @@ -10,10 +10,6 @@ module dplug.pbrwidgets.paramhint; import core.stdc.string; import core.atomic; -import std.math; -import std.conv; -import std.algorithm.comparison; - import dplug.core; import dplug.gui.element; import dplug.gui.bufferedelement; @@ -85,8 +81,13 @@ nothrow: assert(_upAnimation >= 0 && _upAnimation <= 1); - float openAnimation = min(1.0f, _upAnimation * 2.0f); - float moveUpAnimation = max(0.0f, _upAnimation * 2.0f - 1.0f); + float openAnimation = _upAnimation * 2.0f; + if (openAnimation > 1.0f) + openAnimation = 1.0f; + + float moveUpAnimation = _upAnimation * 2.0f - 1.0f; + if (openAnimation < 0.0f) + openAnimation = 0.0f; box2i fullRect = box2i(0, 0, W, H); diff --git a/pbrwidgets/dplug/pbrwidgets/slider.d b/pbrwidgets/dplug/pbrwidgets/slider.d index 83493106..17979a24 100644 --- a/pbrwidgets/dplug/pbrwidgets/slider.d +++ b/pbrwidgets/dplug/pbrwidgets/slider.d @@ -7,8 +7,7 @@ Authors: Guillaume Piolat */ module dplug.pbrwidgets.slider; -import std.math; -import std.algorithm.comparison; +import std.math: exp, abs; import dplug.core.math; import dplug.gui.bufferedelement; @@ -156,7 +155,10 @@ nothrow: if (isDragged) { // lit trail is 50% brighter when dragged - litTrail.a = cast(ubyte) min(255, 3 * litTrail.a / 2); + int alpha = 3 * litTrail.a / 2; + if (alpha > 255) + alpha = 255; + litTrail.a = cast(ubyte) alpha; } paintTrail(0, 1, unlitTrailDiffuse); diff --git a/window/dplug/window/cocoawindow.d b/window/dplug/window/cocoawindow.d index c45bcc4a..7aeb816b 100644 --- a/window/dplug/window/cocoawindow.d +++ b/window/dplug/window/cocoawindow.d @@ -23,6 +23,15 @@ import dplug.window.window; import derelict.cocoa; +version(legacyMouseCursor) +{ + version = noCursors; // FUTURE: tell to replace with Dplug_NoMouseCursor +} +else version(Dplug_NoMouseCursor) +{ + version = noCursors; +} + version = useCoreGraphicsContext; @@ -325,7 +334,7 @@ private: _listener.onMouseMove(mousePos.x, mousePos.y, mousePos.x - _lastMouseX, mousePos.y - _lastMouseY, getMouseState(event)); - version(legacyMouseCursor) + version(noCursors) {} else { @@ -349,7 +358,7 @@ private: // 2. either the mouseMove event might not be called, because the window is hosted in another process // and isn't active yet (macOS has "click through", a sort of mouse focus) // then we need to set the mouse cursor upon entry. Tricky! - version(legacyMouseCursor) + version(noCursors) { setMouseCursor(MouseCursor.pointer); } diff --git a/window/dplug/window/win32window.d b/window/dplug/window/win32window.d index 9e35f842..0b53cbe6 100644 --- a/window/dplug/window/win32window.d +++ b/window/dplug/window/win32window.d @@ -31,6 +31,16 @@ import dplug.graphics.image; import dplug.window.window; +version(legacyMouseCursor) +{ + version = noCursors; // FUTURE: tell to replace with Dplug_NoMouseCursor +} +else version(Dplug_NoMouseCursor) +{ + version = noCursors; +} + + // Hook the mouse callback so that you can use mouse wheel while dragging outside of the plugin // window boundaries. This is most useful for eg. EQ plugins where you would want to use mouse // wheel while dragging a point out of the plugin window. @@ -348,7 +358,7 @@ version(Windows) // This is done differently depending on whether we want a modifed cursor ourselves. // Easily tested in REAPER by hovering over the left border of // the plugin: this turn the custor into a resize arrow. - version(legacyMouseCursor) + version(noCursors) { goto default; } @@ -748,7 +758,7 @@ version(Windows) int setMouseCursor(bool forceUpdate) { - version(legacyMouseCursor) + version(noCursors) {} else { diff --git a/window/dplug/window/x11window.d b/window/dplug/window/x11window.d index 75e7f488..a73be081 100644 --- a/window/dplug/window/x11window.d +++ b/window/dplug/window/x11window.d @@ -16,6 +16,15 @@ module dplug.window.x11window; version(linux): // because of static linking with the X11 library +version(legacyMouseCursor) +{ + version = noCursors; // FUTURE: tell to replace with Dplug_NoMouseCursor +} +else version(Dplug_NoMouseCursor) +{ + version = noCursors; +} + import core.atomic; import core.stdc.string; import core.sys.posix.unistd; @@ -373,7 +382,7 @@ private: void setCursor() { - version(legacyMouseCursor) + version(noCursors) {} else {