commit 6453d1bd5f708021a0334669f40540dfb6d489bd
parent f92cc4a6fac1745ef9deb079f8c8e6ca01c822d0
Author: Oli Larkin <olilarkin@googlemail.com>
Date: Mon, 22 May 2023 14:35:49 +0200
Add NAMAboutBoxControl
Diffstat:
4 files changed, 161 insertions(+), 48 deletions(-)
diff --git a/NeuralAmpModeler/Colors.h b/NeuralAmpModeler/Colors.h
@@ -77,6 +77,8 @@ const iplug::igraphics::IColor NAM_THEMEFONTCOLOR(255, 242, 242, 242); // Dark W
// const iplug::igraphics::IColor MOUSEOVER = NAM_3.WithOpacity(0.3);
const iplug::igraphics::IColor MOUSEOVER = NAM_THEMEFONTCOLOR.WithOpacity(0.1);
const iplug::igraphics::IColor HELP_TEXT = iplug::igraphics::COLOR_WHITE;
+const iplug::igraphics::IColor HELP_TEXT_MO = iplug::igraphics::COLOR_WHITE.WithOpacity(0.9);
+const iplug::igraphics::IColor HELP_TEXT_CLICKED = iplug::igraphics::COLOR_WHITE.WithOpacity(0.8);
}; // namespace PluginColors
diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp
@@ -97,6 +97,8 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
auto closeButtonSVG = pGraphics->LoadSVG(CLOSE_BUTTON_FN);
auto rightArrowSVG = pGraphics->LoadSVG(RIGHT_ARROW_FN);
auto leftArrowSVG = pGraphics->LoadSVG(LEFT_ARROW_FN);
+
+ const IBitmap bgBitmap = pGraphics->LoadBitmap(BACKGROUND_FN);
const IBitmap irSwitchBitmap = pGraphics->LoadBitmap((TOGGLEIR_FN), 2, true);
const IBitmap switchHandleBitmap = pGraphics->LoadBitmap((TOGGLE_HANDLE_FN), true);
const IBitmap knobBackground = pGraphics->LoadBitmap(KNOBBACKGROUND_FN);
@@ -253,57 +255,11 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
pGraphics->AttachControl(new NAMCircleButtonControl(
mainArea.GetFromTRHC(50, 50).GetCentredInside(20, 20),
[pGraphics](IControl* pCaller) {
- pGraphics->GetControlWithTag(kCtrlTagAboutBox)->As<IAboutBoxControl>()->HideAnimated(false);
+ pGraphics->GetControlWithTag(kCtrlTagAboutBox)->As<NAMAboutBoxControl>()->HideAnimated(false);
},
helpSVG));
- pGraphics
- ->AttachControl(
- new IAboutBoxControl(
- b, COLOR_GRAY,
- // AttachFunc
- [](IContainerBase* pParent, const IRECT& r) {
- pParent->AddChildControl(new IPanelControl(
- IRECT(),
- IPattern::CreateLinearGradient(
- r, EDirection::Vertical, {{PluginColors::NAM_THEMEFONTCOLOR, 0.f}, {PluginColors::NAM_0, 1.f}})));
-
- pParent->AddChildControl(new IVPanelControl(IRECT(), "",
- style.WithColor(kFR, PluginColors::NAM_1.WithOpacity(0.9f))
- .WithColor(kFG, PluginColors::NAM_1.WithOpacity(0.9f))));
-
- pParent->AddChildControl(new IVLabelControl(
- IRECT(), "Neural Amp Modeler",
- style.WithDrawFrame(false).WithValueText({30, EAlign::Center, PluginColors::HELP_TEXT})));
-
- WDL_String versionStr{"Version "};
- versionStr.Append(PLUG_VERSION_STR);
- pParent->AddChildControl(new IVLabelControl(
- IRECT(), versionStr.Get(),
- style.WithDrawFrame(false).WithValueText({DEFAULT_TEXT_SIZE, EAlign::Center, PluginColors::HELP_TEXT})));
- pParent->AddChildControl(new IVLabelControl(
- IRECT(), "By Steven Atkinson",
- style.WithDrawFrame(false).WithValueText({DEFAULT_TEXT_SIZE, EAlign::Center, PluginColors::HELP_TEXT})));
- pParent->AddChildControl(new IURLControl(IRECT(), "Train your own model",
- "https://github.com/sdatkinson/neural-amp-modeler",
- {DEFAULT_TEXT_SIZE, PluginColors::HELP_TEXT}));
- },
- // ResizeFunc
- [](IContainerBase* pParent, const IRECT& r) {
- const IRECT mainArea = r.GetPadded(-20);
- const auto content = mainArea.GetPadded(-10);
- const auto titleLabel = content.GetFromTop(50);
- pParent->GetChild(0)->SetTargetAndDrawRECTs(r);
- pParent->GetChild(1)->SetTargetAndDrawRECTs(mainArea);
- pParent->GetChild(2)->SetTargetAndDrawRECTs(titleLabel);
- pParent->GetChild(3)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H()));
- pParent->GetChild(4)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 20));
- pParent->GetChild(5)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 40));
- },
- // Animation Time
- 0),
- kCtrlTagAboutBox)
- ->Hide(true);
+ pGraphics->AttachControl(new NAMAboutBoxControl(b, bgBitmap, style), kCtrlTagAboutBox)->Hide(true);
pGraphics->ForAllControlsFunc([](IControl* pControl) {
pControl->SetMouseEventsWhenDisabled(true);
@@ -503,6 +459,29 @@ bool NeuralAmpModeler::OnMessage(int msgTag, int ctrlTag, int dataSize, const vo
{
case kMsgTagClearModel: mShouldRemoveModel = true; return true;
case kMsgTagClearIR: mShouldRemoveIR = true; return true;
+ case kMsgTagHighlightColor:
+ {
+ mHighLightColor.Set((const char*) pData);
+
+ if (GetUI())
+ {
+ GetUI()->ForStandardControlsFunc([&](IControl* pControl){
+
+ if (auto* pVectorBase = pControl->As<IVectorBase>())
+ {
+ IColor color = IColor::FromColorCodeStr(mHighLightColor.Get());
+
+ pVectorBase->SetColor(kX1, color);
+ pVectorBase->SetColor(kPR, color.WithOpacity(0.3f));
+ pVectorBase->SetColor(kFR, color.WithOpacity(0.4f));
+ pVectorBase->SetColor(kX3, color.WithContrast(0.1f));
+ }
+ pControl->GetUI()->SetAllControlsDirty();
+ });
+ }
+
+ return true;
+ }
default: return false;
}
}
diff --git a/NeuralAmpModeler/NeuralAmpModeler.h b/NeuralAmpModeler/NeuralAmpModeler.h
@@ -51,6 +51,7 @@ enum EMsgTags
// These tags are used from UI -> DSP
kMsgTagClearModel = 0,
kMsgTagClearIR,
+ kMsgTagHighlightColor,
// The following tags are from DSP -> UI
kMsgTagLoadFailed,
kMsgTagLoadedModel,
@@ -155,6 +156,8 @@ private:
WDL_String mNAMPath;
// Path to IR (.wav file)
WDL_String mIRPath;
+
+ WDL_String mHighLightColor;
std::unordered_map<std::string, double> mNAMParams = {{"Input", 0.0}, {"Output", 0.0}};
diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h
@@ -2,6 +2,8 @@
#include "IControls.h"
+#define PLUG() static_cast<PLUG_CLASS_NAME*>(GetDelegate())
+
using namespace iplug;
using namespace igraphics;
@@ -385,3 +387,130 @@ private:
ISVG mLoadSVG, mClearSVG, mLeftSVG, mRightSVG;
int mClearMsgTag;
};
+
+class NAMAboutBoxControl : public IContainerBase
+{
+public:
+ NAMAboutBoxControl(const IRECT& bounds, const IBitmap& bitmap, const IVStyle& style)
+ : IContainerBase(bounds)
+ , mAnimationTime(0)
+ , mBitmap(bitmap)
+ , mStyle(style)
+ {
+ mIgnoreMouse = false;
+ }
+
+ bool OnKeyDown(float x, float y, const IKeyPress& key) override
+ {
+ if (key.VK == kVK_ESCAPE)
+ {
+ HideAnimated(true);
+ return true;
+ }
+
+ return false;
+ }
+
+ void OnMouseDown(float x, float y, const IMouseMod& mod) override
+ {
+ HideAnimated(true);
+ }
+
+ void HideAnimated(bool hide)
+ {
+ mWillHide = hide;
+
+ if (hide == false)
+ {
+ mHide = false;
+ }
+ else // hide subcontrols immediately
+ {
+ ForAllChildrenFunc([hide](int childIdx, IControl* pChild) {
+ pChild->Hide(hide);
+ });
+ }
+
+ SetAnimation([&](IControl* pCaller) {
+ auto progress = static_cast<float>(pCaller->GetAnimationProgress());
+
+ if (mWillHide)
+ SetBlend(IBlend(EBlend::Default, 1.0f-progress));
+ else
+ SetBlend(IBlend(EBlend::Default, progress));
+
+ if (progress > 1.0f)
+ {
+ pCaller->OnEndAnimation();
+ IContainerBase::Hide(mWillHide);
+ GetUI()->SetAllControlsDirty();
+ return;
+ }
+
+ }, mAnimationTime);
+
+ SetDirty(true);
+ }
+
+ void OnAttached() override
+ {
+ AddChildControl(new IBitmapControl(IRECT(), mBitmap))->SetIgnoreMouse(true);
+
+ const IVStyle titleStyle =
+ DEFAULT_STYLE
+ .WithValueText(IText(24, COLOR_WHITE, "Ronduit-Light"))
+ .WithDrawFrame(false)
+ .WithShadowOffset(2.f);
+
+ AddChildControl(new IVLabelControl(IRECT(), "Neural Amp Modeler", titleStyle));
+
+ WDL_String verStr, buildInfoStr;
+ PLUG()->GetPluginVersionStr(verStr);
+
+ buildInfoStr.SetFormatted(100, "Version %s %s %s", verStr.Get(), PLUG()->GetArchStr(), PLUG()->GetAPIStr());
+
+ const auto text = IText(DEFAULT_TEXT_SIZE, EAlign::Center, PluginColors::HELP_TEXT);
+ const auto style = mStyle.WithDrawFrame(false).WithValueText(text);
+
+
+ AddChildControl(new IVLabelControl(IRECT(), "By Steven Atkinson", style));
+ AddChildControl(new IVLabelControl(IRECT(), buildInfoStr.Get(), style));
+ AddChildControl(new IURLControl(IRECT(), "Plug-in development: Steve Atkinson, Oli Larkin, ... ", "https://github.com/sdatkinson/NeuralAmpModelerPlugin/graphs/contributors", text, COLOR_TRANSPARENT, PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED));
+ AddChildControl(new IURLControl(IRECT(), "www.neuralampmodeler.com", "https://www.neuralampmodeler.com", text, COLOR_TRANSPARENT, PluginColors::HELP_TEXT_MO, PluginColors::HELP_TEXT_CLICKED));
+
+// AddChildControl(new IVColorSwatchControl(IRECT() , "Highlight", [&](int idx, IColor color){
+//
+// WDL_String colorCodeStr;
+// color.ToColorCodeStr(colorCodeStr, false);
+// this->GetDelegate()->SendArbitraryMsgFromUI(kMsgTagHighlightColor, kNoTag, colorCodeStr.GetLength(), colorCodeStr.Get());
+//
+// }, mStyle, IVColorSwatchControl::ECellLayout::kHorizontal, {kFG}, {""}));
+
+ OnResize();
+ }
+
+ void OnResize() override
+ {
+ if (NChildren())
+ {
+ const IRECT mainArea = mRECT.GetPadded(-20);
+ const auto content = mainArea.GetPadded(-10);
+ const auto titleLabel = content.GetFromTop(50);
+ GetChild(0)->SetTargetAndDrawRECTs(mRECT);
+ GetChild(1)->SetTargetAndDrawRECTs(titleLabel);
+ GetChild(2)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H()));
+ GetChild(3)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 20).GetMidVPadded(5));
+ GetChild(4)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 40).GetMidVPadded(7));
+ GetChild(5)->SetTargetAndDrawRECTs(titleLabel.GetVShifted(titleLabel.H() + 60).GetMidVPadded(7));
+// GetChild(6)->SetTargetAndDrawRECTs(content.GetFromBRHC(100, 50));
+ }
+ }
+
+
+private:
+ IBitmap mBitmap;
+ IVStyle mStyle;
+ int mAnimationTime = 200;
+ bool mWillHide = false;
+};
+