Skip to content

Commit

Permalink
deprecate UIBarGraph
Browse files Browse the repository at this point in the history
Introduce Dplug_NoMouseCursor additional Options to keep not changing mouse cursor
Less Phobos use.
  • Loading branch information
Guillaume Piolat committed Oct 26, 2023
1 parent 801897f commit bb748d0
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 27 deletions.
6 changes: 3 additions & 3 deletions pbrwidgets/dplug/pbrwidgets/bargraph.d
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion pbrwidgets/dplug/pbrwidgets/imageknob.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 13 additions & 6 deletions pbrwidgets/dplug/pbrwidgets/knob.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion pbrwidgets/dplug/pbrwidgets/label.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Authors: Guillaume Piolat
*/
module dplug.pbrwidgets.label;

import std.math;
import dplug.gui.element;
import dplug.client.params;

Expand Down
2 changes: 1 addition & 1 deletion pbrwidgets/dplug/pbrwidgets/logo.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pbrwidgets/dplug/pbrwidgets/onoffswitch.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 7 additions & 6 deletions pbrwidgets/dplug/pbrwidgets/paramhint.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
8 changes: 5 additions & 3 deletions pbrwidgets/dplug/pbrwidgets/slider.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions window/dplug/window/cocoawindow.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -325,7 +334,7 @@ private:
_listener.onMouseMove(mousePos.x, mousePos.y, mousePos.x - _lastMouseX, mousePos.y - _lastMouseY,
getMouseState(event));

version(legacyMouseCursor)
version(noCursors)
{}
else
{
Expand All @@ -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);
}
Expand Down
14 changes: 12 additions & 2 deletions window/dplug/window/win32window.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -748,7 +758,7 @@ version(Windows)

int setMouseCursor(bool forceUpdate)
{
version(legacyMouseCursor)
version(noCursors)
{}
else
{
Expand Down
11 changes: 10 additions & 1 deletion window/dplug/window/x11window.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -373,7 +382,7 @@ private:

void setCursor()
{
version(legacyMouseCursor)
version(noCursors)
{}
else
{
Expand Down

0 comments on commit bb748d0

Please sign in to comment.