Skip to content

Commit

Permalink
UISlider .sensitivity is now a Wren-exposed variable, rather than a w…
Browse files Browse the repository at this point in the history
…eird D property. This is more in line with UIKnob. See #846
  • Loading branch information
Guillaume Piolat committed May 5, 2024
1 parent d1bdcd5 commit 017f26a
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 deletions pbrwidgets/dplug/pbrwidgets/slider.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,33 @@ public:
nothrow:
@nogc:

// Trail customization
@ScriptProperty L16 trailDepth = L16(30000);
@ScriptProperty RGBA unlitTrailDiffuse = RGBA(130, 90, 45, 5);
@ScriptProperty RGBA litTrailDiffuse = RGBA(240, 165, 102, 130);
@ScriptProperty float trailWidth = 0.2f;

@ScriptProperty RGBA litTrailDiffuseAlt = RGBA(240, 165, 102, 130);
@ScriptProperty bool hasAlternateTrail = false;
@ScriptProperty float trailBase = 0.0f; // trail is from trailBase to parameter value

// Handle customization
@ScriptProperty HandleStyle handleStyle = HandleStyle.shapeW;
@ScriptProperty float handleHeightRatio = 0.25f;
@ScriptProperty float handleWidthRatio = 0.7f;
@ScriptProperty RGBA handleDiffuse = RGBA(248, 245, 233, 16);
@ScriptProperty RGBA handleMaterial = RGBA(0, 255, 128, 255);
@ScriptProperty
{
// Trail customization
L16 trailDepth = L16(30000);
RGBA unlitTrailDiffuse = RGBA(130, 90, 45, 5);
RGBA litTrailDiffuse = RGBA(240, 165, 102, 130);
float trailWidth = 0.2f;

RGBA litTrailDiffuseAlt = RGBA(240, 165, 102, 130);
bool hasAlternateTrail = false;
float trailBase = 0.0f; // trail is from trailBase to parameter value

// Handle customization
HandleStyle handleStyle = HandleStyle.shapeW;
float handleHeightRatio = 0.25f;
float handleWidthRatio = 0.7f;
RGBA handleDiffuse = RGBA(248, 245, 233, 16);
RGBA handleMaterial = RGBA(0, 255, 128, 255);

float sensivity = 1.0f; // Note: 0.6 not bad for volumes
}

this(UIContext context, Parameter param)
{
super(context, flagAnimated | flagPBR);
_param = param;
_param.addListener(this);
_sensivity = 1.0f;
_pushedAnimation = 0;
clearCrosspoints();
setCursorWhenDragged(MouseCursor.drag);
Expand All @@ -62,18 +66,6 @@ nothrow:
_param.removeListener(this);
}

/// Returns: sensivity.
float sensivity()
{
return _sensivity;
}

/// Sets sensivity.
float sensivity(float sensivity)
{
return _sensivity = sensivity;
}

override void onAnimate(double dt, double time) nothrow @nogc
{
float target = isDragged() ? 1 : 0;
Expand Down Expand Up @@ -265,7 +257,7 @@ nothrow:
modifier *= 0.1f;

double oldParamValue = _param.getNormalized() + _draggingDebt;
double newParamValue = oldParamValue - displacementInHeight * modifier * _sensivity;
double newParamValue = oldParamValue - displacementInHeight * modifier * sensivity;
if (mstate.altPressed)
newParamValue = _param.getNormalizedDefault();

Expand Down Expand Up @@ -360,10 +352,6 @@ protected:
/// The parameter this switch is linked with.
Parameter _param;

/// Sensivity: given a mouse movement in 100th of the height of the knob,
/// how much should the normalized parameter change.
float _sensivity;

float _pushedAnimation;

float _mousePosOnLast0Cross;
Expand Down

0 comments on commit 017f26a

Please sign in to comment.