Skip to content

Commit

Permalink
theme color per instance
Browse files Browse the repository at this point in the history
  • Loading branch information
fichl committed Feb 6, 2024
1 parent 85d63b8 commit c862787
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
28 changes: 23 additions & 5 deletions NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ using namespace igraphics;

const double kDCBlockerFrequency = 5.0;

iplug::igraphics::IColor NAM_CUSTOMTHEMECOLOR = PluginColors::NAM_THEMECOLOR;

// Styles
const IVColorSpec colorSpec{
DEFAULT_BGCOLOR, // Background
Expand Down Expand Up @@ -421,6 +423,7 @@ bool NeuralAmpModeler::SerializeState(IByteChunk& chunk) const
// when we unserialize)
chunk.PutStr(mNAMPath.Get());
chunk.PutStr(mIRPath.Get());
chunk.PutStr(mHighLightColor.Get());
return SerializeParams(chunk);
}

Expand All @@ -429,6 +432,7 @@ int NeuralAmpModeler::UnserializeState(const IByteChunk& chunk, int startPos)
WDL_String dir;
startPos = chunk.GetStr(mNAMPath, startPos);
startPos = chunk.GetStr(mIRPath, startPos);
startPos = chunk.GetStr(mHighLightColor, startPos);
int retcode = UnserializeParams(chunk, startPos);
if (mNAMPath.GetLength())
_StageModel(mNAMPath);
Expand Down Expand Up @@ -460,6 +464,20 @@ void NeuralAmpModeler::OnUIOpen()
if (mModel != nullptr)
GetUI()->GetControlWithTag(kCtrlTagOutNorm)->SetDisabled(!mModel->HasLoudness());
mCheckSampleRateWarning = true;

GetUI()->ForStandardControlsFunc([&](IControl* pControl) {
if (auto* pVectorBase = pControl->As<IVectorBase>())
{
if (mHighLightColor.GetLength())
NAM_CUSTOMTHEMECOLOR = IColor::FromColorCodeStr(mHighLightColor.Get());

pVectorBase->SetColor(kX1, NAM_CUSTOMTHEMECOLOR);
pVectorBase->SetColor(kPR, NAM_CUSTOMTHEMECOLOR.WithOpacity(0.6f));
pVectorBase->SetColor(kFR, NAM_CUSTOMTHEMECOLOR.WithOpacity(0.1f));
pVectorBase->SetColor(kX3, NAM_CUSTOMTHEMECOLOR.WithContrast(0.1f));
}
pControl->GetUI()->SetAllControlsDirty();
});
}

void NeuralAmpModeler::OnParamChangeUI(int paramIdx, EParamSource source)
Expand Down Expand Up @@ -495,12 +513,12 @@ bool NeuralAmpModeler::OnMessage(int msgTag, int ctrlTag, int dataSize, const vo
GetUI()->ForStandardControlsFunc([&](IControl* pControl) {
if (auto* pVectorBase = pControl->As<IVectorBase>())
{
IColor color = IColor::FromColorCodeStr(mHighLightColor.Get());
NAM_CUSTOMTHEMECOLOR = 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));
pVectorBase->SetColor(kX1, NAM_CUSTOMTHEMECOLOR);
pVectorBase->SetColor(kPR, NAM_CUSTOMTHEMECOLOR.WithOpacity(0.6f));
pVectorBase->SetColor(kFR, NAM_CUSTOMTHEMECOLOR.WithOpacity(0.1f));
pVectorBase->SetColor(kX3, NAM_CUSTOMTHEMECOLOR.WithContrast(0.1f));
}
pControl->GetUI()->SetAllControlsDirty();
});
Expand Down
18 changes: 9 additions & 9 deletions NeuralAmpModeler/NeuralAmpModelerControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,14 @@ class NAMAboutBoxControl : public IContainerBase
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}, {""}));
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, {kX1}, {""}));

OnResize();
}
Expand All @@ -581,7 +581,7 @@ class NAMAboutBoxControl : public IContainerBase
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));
GetChild(6)->SetTargetAndDrawRECTs(content.GetFromBRHC(100, 50));
}
}

Expand Down

0 comments on commit c862787

Please sign in to comment.