commit 325adfbaa2ba7ecc95c5ff5c8e4fdefee562ea64 parent 5de768fc6eb517a183b22412da46b5102e129aea Author: Oli Larkin <[email protected]> Date: Mon, 22 May 2023 13:46:47 +0200 NAMFileBrowserControl takes an image Diffstat:
6 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/NeuralAmpModeler/NeuralAmpModeler.cpp b/NeuralAmpModeler/NeuralAmpModeler.cpp @@ -98,6 +98,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) auto rightArrowSVG = pGraphics->LoadSVG(RIGHT_ARROW_FN); auto leftArrowSVG = pGraphics->LoadSVG(LEFT_ARROW_FN); + const IBitmap fileControlBackground = pGraphics->LoadBitmap(FILECONTROLBACKGROUND_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); @@ -139,9 +140,8 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) // Areas for model and IR const float fileWidth = 200.0f; const float fileHeight = 30.0f; - const float fileYSpace = 8.0f; const float irYOffset = 38.0f; - const IRECT modelArea = content.GetFromBottom((2.0f * fileHeight) + fileYSpace) + const IRECT modelArea = content.GetFromBottom((2.0f * fileHeight)) .GetFromTop(fileHeight) .GetMidHPadded(fileWidth) .GetTranslated(0.0f, -1); @@ -209,13 +209,13 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info) #endif pGraphics->AttachControl(new NAMFileBrowserControl(modelArea, kMsgTagClearModel, defaultNamFileString.c_str(), "nam", loadModelCompletionHandler, style, fileSVG, - closeButtonSVG, leftArrowSVG, rightArrowSVG), + closeButtonSVG, leftArrowSVG, rightArrowSVG, fileControlBackground), kCtrlTagModelFileBrowser); + pGraphics->AttachControl(new ISVGSwitchControl(irArea.GetFromLeft(30).GetTranslated(-40, 0).GetScaledAboutCentre(0.6), { irIconOffSVG, irIconOnSVG}, kIRToggle)); pGraphics->AttachControl( - new NAMFileBrowserControl(irArea, kMsgTagClearIR, defaultIRString.c_str(), "wav", loadIRCompletionHandler, style, - fileSVG, closeButtonSVG, leftArrowSVG, rightArrowSVG), + new NAMFileBrowserControl(irArea, kMsgTagClearModel, defaultIRString.c_str(), "wav", loadIRCompletionHandler, + style, fileSVG, closeButtonSVG, leftArrowSVG, rightArrowSVG, fileControlBackground), kCtrlTagIRFileBrowser); - 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); diff --git a/NeuralAmpModeler/NeuralAmpModelerControls.h b/NeuralAmpModeler/NeuralAmpModelerControls.h @@ -199,12 +199,13 @@ class NAMFileBrowserControl : public IDirBrowseControlBase public: NAMFileBrowserControl(const IRECT& bounds, int clearMsgTag, const char* labelStr, const char* fileExtension, IFileDialogCompletionHandlerFunc ch, const IVStyle& style, const ISVG& loadSVG, - const ISVG& clearSVG, const ISVG& leftSVG, const ISVG& rightSVG) + const ISVG& clearSVG, const ISVG& leftSVG, const ISVG& rightSVG, const IBitmap& bitmap) : IDirBrowseControlBase(bounds, fileExtension, false, false) , mClearMsgTag(clearMsgTag) , mDefaultLabelStr(labelStr) , mCompletionHandlerFunc(ch) , mStyle(style.WithColor(kFG, COLOR_TRANSPARENT).WithDrawFrame(false)) + , mBitmap(bitmap) , mLoadSVG(loadSVG) , mClearSVG(clearSVG) , mLeftSVG(leftSVG) @@ -212,9 +213,10 @@ public: { mIgnoreMouse = true; } - + void Draw(IGraphics& g) override - { /* NO-OP */ + { + g.DrawFittedBitmap(mBitmap, mRECT); } void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx) override @@ -306,7 +308,7 @@ public: } }; - IRECT padded = mRECT.GetPadded(-5.f); + IRECT padded = mRECT.GetPadded(-6.f).GetHPadded(-2.f); const auto buttonWidth = padded.H(); const auto loadFileButtonBounds = padded.ReduceFromLeft(buttonWidth); const auto clearButtonBounds = padded.ReduceFromRight(buttonWidth); @@ -384,6 +386,7 @@ private: IFileDialogCompletionHandlerFunc mCompletionHandlerFunc; NAMFileNameControl* mFileNameControl = nullptr; IVStyle mStyle; + IBitmap mBitmap; ISVG mLoadSVG, mClearSVG, mLeftSVG, mRightSVG; int mClearMsgTag; }; diff --git a/NeuralAmpModeler/config.h b/NeuralAmpModeler/config.h @@ -80,6 +80,9 @@ #define KNOBBACKGROUND_FN "KnobBackground.png" #define KNOBBACKGROUND2X_FN "[email protected]" #define KNOBBACKGROUND3X_FN "[email protected]" +#define FILECONTROLBACKGROUND_FN "FileControlBackground.png" +#define FILECONTROLBACKGROUND2X_FN "[email protected]" +#define FILECONTROLBACKGROUND3X_FN "[email protected]" // Issue 291 // On the macOS standalone, we might not have permissions to traverse the file directory, so we have the app ask the diff --git a/NeuralAmpModeler/resources/img/FileControlBackground.png b/NeuralAmpModeler/resources/img/FileControlBackground.png Binary files differ. diff --git a/NeuralAmpModeler/resources/img/[email protected] b/NeuralAmpModeler/resources/img/[email protected] Binary files differ. diff --git a/NeuralAmpModeler/resources/img/[email protected] b/NeuralAmpModeler/resources/img/[email protected] Binary files differ.