NeuralAmpModelerPlugin

Plugin for Neural Amp Modeler
Log | Files | Refs | Submodules | README | LICENSE

commit 05cd55df6caf330b0b7170ed6f8dfc125582ad66
parent 9787ad9fcb03f977108d0c426e4de4ee7e5bff7b
Author: Oli Larkin <[email protected]>
Date:   Mon, 22 May 2023 14:33:23 +0200

Update NAMSwitchControl for single bitmap

Diffstat:
MNeuralAmpModeler/NeuralAmpModeler.cpp | 45+++++++++------------------------------------
MNeuralAmpModeler/NeuralAmpModelerControls.h | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------
MNeuralAmpModeler/config.h | 2--
3 files changed, 76 insertions(+), 54 deletions(-)

diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -98,7 +98,6 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) auto rightArrowSVG = pGraphics->LoadSVG(RIGHT_ARROW_FN); auto leftArrowSVG = pGraphics->LoadSVG(LEFT_ARROW_FN); const IBitmap irSwitchBitmap = pGraphics->LoadBitmap((TOGGLEIR_FN), 2, true); - const IBitmap switchBitmap = pGraphics->LoadBitmap((TOGGLE_FN), true); const IBitmap switchHandleBitmap = pGraphics->LoadBitmap((TOGGLE_HANDLE_FN), true); const IBitmap knobRotateBitmap = pGraphics->LoadBitmap(KNOB_FN); @@ -128,24 +127,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) const IRECT trebleKnobArea = knobs.GetGridCell(0, kToneTreble, 1, numKnobs).GetPadded(-singleKnobPad); const IRECT outputKnobArea = knobs.GetGridCell(0, kOutputLevel, 1, numKnobs).GetPadded(-singleKnobPad); - const float toggleHeight = 40.0f; - // Area for noise gate toggle - const float ngAreaHeight = toggleHeight; - const IRECT ngToggleArea = - noiseGateArea.GetFromBottom(ngAreaHeight).GetTranslated(-10.f, ngAreaHeight + singleKnobPad - 14.f); - // Area for EQ toggle - const float eqAreaHeight = toggleHeight; - const float eqAreaHalfWidth = 0.5f * middleKnobArea.W(); - const IRECT eqToggleArea = middleKnobArea.GetFromBottom(eqAreaHeight) - .GetTranslated(-10.f, eqAreaHeight + singleKnobPad - 14.f) - .GetMidHPadded(eqAreaHalfWidth); - - // Area for output normalization toggle - const float outNormAreaHeight = toggleHeight; - const float outNormAreaHalfWidth = 0.5f * outputKnobArea.W(); - const IRECT outNormToggleArea = outputKnobArea.GetFromBottom(outNormAreaHeight) - .GetTranslated(-10.f, outNormAreaHeight + singleKnobPad - 14.f) - .GetMidHPadded(outNormAreaHalfWidth); + const IRECT ngToggleArea = noiseGateArea.GetVShifted(noiseGateArea.H()).SubRectVertical(2, 0); + const IRECT eqToggleArea = midKnobArea.GetVShifted(midKnobArea.H()).SubRectVertical(2, 0); + const IRECT outNormToggleArea = outputKnobArea.GetVShifted(midKnobArea.H()).SubRectVertical(2, 0); // Area for IR bypass toggle const float irBypassToggleX = 46.f; @@ -232,23 +216,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) fileSVG, closeButtonSVG, leftArrowSVG, rightArrowSVG), kCtrlTagIRFileBrowser); - // TODO all these magic numbers - pGraphics->AttachControl(new NAMSwitchControl( - ngToggleArea.GetFromTop(60.f).GetPadded(-20.f), kNoiseGateActive, "", style, switchBitmap, switchHandleBitmap)); - pGraphics->AttachControl(new NAMSwitchControl( - eqToggleArea.GetFromTop(60.f).GetPadded(-20.f), kEQActive, "", style, switchBitmap, switchHandleBitmap)); - pGraphics->AttachControl(new NAMSwitchControl(outNormToggleArea.GetFromTop(32.f).GetPadded(-20.f), kOutNorm, "", - style, switchBitmap, switchHandleBitmap), - kCtrlTagOutNorm); - // Get those labels on - { - const float labelNudgeX = 11.f; - const float labelNudgeY = 15.f; - pGraphics->AttachControl( - new ITextControl(eqToggleArea.GetFromTop(70.f).GetTranslated(labelNudgeX, labelNudgeY), "EQ", style.labelText)); - pGraphics->AttachControl(new ITextControl( - outNormToggleArea.GetFromTop(70.f).GetTranslated(labelNudgeX, labelNudgeY), "Normalize", style.labelText)); - } + pGraphics->AttachControl(new NAMSwitchControl(ngToggleArea, kNoiseGateActive, " ", style, switchHandleBitmap)); + pGraphics->AttachControl(new NAMSwitchControl(eqToggleArea, kEQActive, "EQ", style, switchHandleBitmap)); + pGraphics->AttachControl(new NAMSwitchControl(outNormToggleArea, kOutNorm, "Normalize", style, switchHandleBitmap), kCtrlTagOutNorm); // The knobs pGraphics->AttachControl(new NAMKnobControl(inputKnobArea, kInputLevel, "", style, knobRotateBitmap)); @@ -344,6 +314,9 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) pControl->SetMouseEventsWhenDisabled(true); pControl->SetMouseOverWhenDisabled(true); }); + + pGraphics->GetControlWithTag(kCtrlTagOutNorm)->SetMouseEventsWhenDisabled(false); + }; } diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -72,36 +72,87 @@ public: class NAMSwitchControl : public IVSlideSwitchControl, public IBitmapBase { public: - NAMSwitchControl(const IRECT& bounds, int paramIdx, const char* label, const IVStyle& style, IBitmap bitmap, - IBitmap handleBitmap) - : IVSlideSwitchControl( - {bounds.L, bounds.T, bitmap}, paramIdx, label, style.WithRoundness(5.f).WithShowLabel(false).WithShowValue(false)) + NAMSwitchControl(const IRECT& bounds, int paramIdx, const char* label, const IVStyle& style, IBitmap bitmap) + : IVSlideSwitchControl(bounds, paramIdx, label, style + .WithRoundness(0.666f) + .WithShowValue(false) + .WithEmboss(true) + .WithShadowOffset(1.5f) + .WithDrawShadows(false) + .WithColor(kFR, COLOR_BLACK) + .WithFrameThickness(0.5f) + .WithWidgetFrac(0.5f) + .WithLabelOrientation(EOrientation::South)) , IBitmapBase(bitmap) - , mHandleBitmap(handleBitmap) { } void DrawWidget(IGraphics& g) override { - // OL: arg, pixels :-( - if (GetValue() > 0.5f) - g.FillRoundRect(GetColor(kFG), mRECT.GetPadded(-2.7f).GetTranslated(0.0, 1.f), 9.f, &mBlend); - else - g.FillRoundRect(COLOR_BLACK, mRECT.GetPadded(-2.7f).GetTranslated(0.0, 1.f), 9.f, &mBlend); - DrawTrack(g, mWidgetBounds); DrawHandle(g, mHandleBounds); } - void DrawTrack(IGraphics& g, const IRECT& filledArea) override { g.DrawBitmap(mBitmap, mRECT, 0, &mBlend); } + void DrawTrack(IGraphics& g, const IRECT& bounds) override + { + IRECT handleBounds = GetAdjustedHandleBounds(bounds); + handleBounds = IRECT(handleBounds.L, handleBounds.T, handleBounds.R, handleBounds.T + mBitmap.H()); + IRECT centreBounds = handleBounds.GetPadded(-mStyle.shadowOffset); + IRECT shadowBounds = handleBounds.GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset); +// const float contrast = mDisabled ? -GRAYED_ALPHA : 0.f; + float cR = 7.f; + const float tlr = cR; + const float trr = cR; + const float blr = cR; + const float brr = cR; + + // outer shadow + if (mStyle.drawShadows) + g.FillRoundRect(GetColor(kSH), shadowBounds, tlr, trr, blr, brr, &mBlend); + + // Embossed style unpressed + if (mStyle.emboss) + { + // Positive light + g.FillRoundRect(GetColor(kPR), handleBounds, tlr, trr, blr, brr/*, &blend*/); + + // Negative light + g.FillRoundRect(GetColor(kSH), shadowBounds, tlr, trr, blr, brr/*, &blend*/); + + // Fill in foreground + g.FillRoundRect(GetValue() > 0.5 ? GetColor(kX1) : COLOR_BLACK, centreBounds, tlr, trr, blr, brr, &mBlend); + + // Shade when hovered + if (mMouseIsOver) + g.FillRoundRect(GetColor(kHL), centreBounds, tlr, trr, blr, brr, &mBlend); + } + else + { + g.FillRoundRect(GetValue() > 0.5 ? GetColor(kX1) : COLOR_BLACK, handleBounds, tlr, trr, blr, brr/*, &blend*/); + + // Shade when hovered + if (mMouseIsOver) + g.FillRoundRect(GetColor(kHL), handleBounds, tlr, trr, blr, brr, &mBlend); + } + + if (mStyle.drawFrame) + g.DrawRoundRect(GetColor(kFR), handleBounds, tlr, trr, blr, brr, &mBlend, mStyle.frameThickness); + } void DrawHandle(IGraphics& g, const IRECT& filledArea) override { - g.DrawBitmap(mHandleBitmap, filledArea.GetTranslated(2.0, 3.0), 0, &mBlend); + IRECT r; + if (GetSelectedIdx() == 0) + { + r = filledArea.GetFromLeft(mBitmap.W()); + } + else + { + r = filledArea.GetFromRight(mBitmap.W()); + } + + g.DrawBitmap(mBitmap, r.GetTranslated(1, 1), 0, 0, nullptr); } - -private: - IBitmap mHandleBitmap; }; class NAMFileNameControl : public IVButtonControl diff --git a/NeuralAmpModeler/config.h b/NeuralAmpModeler/config.h @@ -69,8 +69,6 @@ #define EH_SKIN2X_FN "[email protected]" #define KNOB_FN "SkinEHeritage_Knob.png" #define KNOB2X_FN "[email protected]" -#define TOGGLE_FN "SkinEHeritage_Toggle.png" -#define TOGGLE2X_FN "[email protected]" #define TOGGLEIR_FN "SkinEHeritage_IR_Toggle.png" #define TOGGLEIR2X_FN "[email protected]" #define TOGGLE_HANDLE_FN "SkinEHeritage_ToggleHandle.png"