Skip to content

Commit 1d5f39a

Browse files
[FEATURE] Button linking to website for more resources (#549)
* get models and irs buttons with dymanic clear button * revert local development files that were accidentally committed * format.bash * get links direct users to neuralampmodeler.com getting started * Update NeuralAmpModeler.cpp Update link * Update NeuralAmpModelerControls.h fix typo --------- Co-authored-by: Steven Atkinson <[email protected]>
1 parent e588a6b commit 1d5f39a

File tree

4 files changed

+86
-12
lines changed

4 files changed

+86
-12
lines changed

NeuralAmpModeler/NeuralAmpModeler.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
119119

120120
const auto gearSVG = pGraphics->LoadSVG(GEAR_FN);
121121
const auto fileSVG = pGraphics->LoadSVG(FILE_FN);
122+
const auto globeSVG = pGraphics->LoadSVG(GLOBE_ICON_FN);
122123
const auto crossSVG = pGraphics->LoadSVG(CLOSE_BUTTON_FN);
123124
const auto rightArrowSVG = pGraphics->LoadSVG(RIGHT_ARROW_FN);
124125
const auto leftArrowSVG = pGraphics->LoadSVG(LEFT_ARROW_FN);
@@ -222,14 +223,18 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
222223
const std::string defaultNamFileString = "Select model...";
223224
const std::string defaultIRString = "Select IR...";
224225
#endif
225-
pGraphics->AttachControl(new NAMFileBrowserControl(modelArea, kMsgTagClearModel, defaultNamFileString.c_str(),
226-
"nam", loadModelCompletionHandler, style, fileSVG, crossSVG,
227-
leftArrowSVG, rightArrowSVG, fileBackgroundBitmap),
228-
kCtrlTagModelFileBrowser);
226+
// Getting started page listing additional resources
227+
const char* const getUrl = "https://www.neuralampmodeler.com/users#comp-marb84o5";
228+
pGraphics->AttachControl(
229+
new NAMFileBrowserControl(modelArea, kMsgTagClearModel, defaultNamFileString.c_str(), "nam",
230+
loadModelCompletionHandler, style, fileSVG, crossSVG, leftArrowSVG, rightArrowSVG,
231+
fileBackgroundBitmap, globeSVG, "Get NAM Models", getUrl),
232+
kCtrlTagModelFileBrowser);
229233
pGraphics->AttachControl(new ISVGSwitchControl(irSwitchArea, {irIconOffSVG, irIconOnSVG}, kIRToggle));
230234
pGraphics->AttachControl(
231235
new NAMFileBrowserControl(irArea, kMsgTagClearIR, defaultIRString.c_str(), "wav", loadIRCompletionHandler, style,
232-
fileSVG, crossSVG, leftArrowSVG, rightArrowSVG, fileBackgroundBitmap),
236+
fileSVG, crossSVG, leftArrowSVG, rightArrowSVG, fileBackgroundBitmap, globeSVG,
237+
"Get IRs", getUrl),
233238
kCtrlTagIRFileBrowser);
234239
pGraphics->AttachControl(
235240
new NAMSwitchControl(ngToggleArea, kNoiseGateActive, "Noise Gate", style, switchHandleBitmap));

NeuralAmpModeler/NeuralAmpModelerControls.h

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
using namespace iplug;
1313
using namespace igraphics;
1414

15+
enum class NAMBrowserState
16+
{
17+
Empty, // when no file loaded, show "Get" button
18+
Loaded // when file loaded, show "Clear" button
19+
};
20+
1521
// Where the corner button on the plugin (settings, close settings) goes
1622
// :param rect: Rect for the whole plugin's UI
1723
IRECT CornerButtonArea(const IRECT& rect)
@@ -209,12 +215,30 @@ class NAMFileNameControl : public IVButtonControl
209215
}
210216
};
211217

218+
// URL control for the "Get" models/irs links
219+
class NAMGetButtonControl : public NAMSquareButtonControl
220+
{
221+
public:
222+
NAMGetButtonControl(const IRECT& bounds, const char* label, const char* url, const ISVG& globeSVG)
223+
: NAMSquareButtonControl(
224+
bounds,
225+
[url](IControl* pCaller) {
226+
WDL_String fullURL(url);
227+
pCaller->GetUI()->OpenURL(fullURL.Get());
228+
},
229+
globeSVG)
230+
{
231+
SetTooltip(label);
232+
}
233+
};
234+
212235
class NAMFileBrowserControl : public IDirBrowseControlBase
213236
{
214237
public:
215238
NAMFileBrowserControl(const IRECT& bounds, int clearMsgTag, const char* labelStr, const char* fileExtension,
216239
IFileDialogCompletionHandlerFunc ch, const IVStyle& style, const ISVG& loadSVG,
217-
const ISVG& clearSVG, const ISVG& leftSVG, const ISVG& rightSVG, const IBitmap& bitmap)
240+
const ISVG& clearSVG, const ISVG& leftSVG, const ISVG& rightSVG, const IBitmap& bitmap,
241+
const ISVG& globeSVG, const char* getButtonLabel, const char* getButtonURL)
218242
: IDirBrowseControlBase(bounds, fileExtension, false, false)
219243
, mClearMsgTag(clearMsgTag)
220244
, mDefaultLabelStr(labelStr)
@@ -225,6 +249,10 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
225249
, mClearSVG(clearSVG)
226250
, mLeftSVG(leftSVG)
227251
, mRightSVG(rightSVG)
252+
, mGlobeSVG(globeSVG)
253+
, mGetButtonLabel(getButtonLabel)
254+
, mGetButtonURL(getButtonURL)
255+
, mBrowserState(NAMBrowserState::Empty)
228256
{
229257
mIgnoreMouse = true;
230258
}
@@ -304,6 +332,7 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
304332
auto clearFileFunc = [&](IControl* pCaller) {
305333
pCaller->GetDelegate()->SendArbitraryMsgFromUI(mClearMsgTag);
306334
mFileNameControl->SetLabelAndTooltip(mDefaultLabelStr.Get());
335+
SetBrowserState(NAMBrowserState::Empty);
307336
// FIXME disabling output mode...
308337
// pCaller->GetUI()->GetControlWithTag(kCtrlTagOutputMode)->SetDisabled(false);
309338
};
@@ -328,7 +357,7 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
328357
IRECT padded = mRECT.GetPadded(-6.f).GetHPadded(-2.f);
329358
const auto buttonWidth = padded.H();
330359
const auto loadFileButtonBounds = padded.ReduceFromLeft(buttonWidth);
331-
const auto clearButtonBounds = padded.ReduceFromRight(buttonWidth);
360+
const auto clearAndGetButtonBounds = padded.ReduceFromRight(buttonWidth);
332361
const auto leftButtonBounds = padded.ReduceFromLeft(buttonWidth);
333362
const auto rightButtonBounds = padded.ReduceFromLeft(buttonWidth);
334363
const auto fileNameButtonBounds = padded;
@@ -341,10 +370,17 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
341370
->SetAnimationEndActionFunction(nextFileFunc);
342371
AddChildControl(mFileNameControl = new NAMFileNameControl(fileNameButtonBounds, mDefaultLabelStr.Get(), mStyle))
343372
->SetAnimationEndActionFunction(chooseFileFunc);
344-
AddChildControl(new NAMSquareButtonControl(clearButtonBounds, DefaultClickActionFunc, mClearSVG))
345-
->SetAnimationEndActionFunction(clearFileFunc);
346373

347-
mFileNameControl->SetLabelAndTooltip(mDefaultLabelStr.Get());
374+
// creates both right-side controls but only show one based on state
375+
mClearButton = new NAMSquareButtonControl(clearAndGetButtonBounds, DefaultClickActionFunc, mClearSVG);
376+
mClearButton->SetAnimationEndActionFunction(clearFileFunc);
377+
AddChildControl(mClearButton);
378+
379+
mGetButton = new NAMGetButtonControl(clearAndGetButtonBounds, mGetButtonLabel, mGetButtonURL, mGlobeSVG);
380+
AddChildControl(mGetButton);
381+
382+
// initialize control visibility
383+
SetBrowserState(NAMBrowserState::Empty);
348384
}
349385

350386
void LoadFileAtCurrentIndex()
@@ -367,6 +403,7 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
367403
{
368404
std::string label(std::string("(FAILED) ") + std::string(mFileNameControl->GetLabelStr()));
369405
mFileNameControl->SetLabelAndTooltip(label.c_str());
406+
SetBrowserState(NAMBrowserState::Empty);
370407
}
371408
break;
372409
case kMsgTagLoadedModel:
@@ -382,8 +419,9 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
382419
SetupMenu();
383420
SetSelectedFile(fileName.Get());
384421
mFileNameControl->SetLabelAndTooltipEllipsizing(fileName);
385-
break;
422+
SetBrowserState(NAMBrowserState::Loaded);
386423
}
424+
break;
387425
default: break;
388426
}
389427
}
@@ -398,13 +436,38 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
398436
return;
399437
}
400438

439+
// set the state of the browser and the visibility of the "Get" vs. "Clear" buttons
440+
void SetBrowserState(NAMBrowserState newState)
441+
{
442+
mBrowserState = newState;
443+
444+
switch (mBrowserState)
445+
{
446+
case NAMBrowserState::Empty:
447+
mClearButton->Hide(true);
448+
mGetButton->Hide(false);
449+
break;
450+
case NAMBrowserState::Loaded:
451+
mClearButton->Hide(false);
452+
mGetButton->Hide(true);
453+
break;
454+
}
455+
}
456+
401457
WDL_String mDefaultLabelStr;
402458
IFileDialogCompletionHandlerFunc mCompletionHandlerFunc;
403459
NAMFileNameControl* mFileNameControl = nullptr;
404460
IVStyle mStyle;
405461
IBitmap mBitmap;
406-
ISVG mLoadSVG, mClearSVG, mLeftSVG, mRightSVG;
462+
ISVG mLoadSVG, mClearSVG, mLeftSVG, mRightSVG, mGlobeSVG;
407463
int mClearMsgTag;
464+
465+
// new members for the "Get" button
466+
const char* mGetButtonLabel;
467+
const char* mGetButtonURL;
468+
NAMBrowserState mBrowserState;
469+
NAMSquareButtonControl* mClearButton = nullptr;
470+
NAMGetButtonControl* mGetButton = nullptr;
408471
};
409472

410473
class NAMMeterControl : public IVPeakAvgMeterControl<>, public IBitmapBase

NeuralAmpModeler/config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#define MODEL_ICON_FN "ModelIcon.svg"
6868
#define IR_ICON_ON_FN "IRIconOn.svg"
6969
#define IR_ICON_OFF_FN "IRIconOff.svg"
70+
#define GLOBE_ICON_FN "Globe.svg"
7071

7172
#define BACKGROUND_FN "Background.jpg"
7273
#define BACKGROUND2X_FN "[email protected]"
Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)