Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theme color per instance #435

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions NeuralAmpModeler/NeuralAmpModeler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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 @@ -414,6 +416,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 Down Expand Up @@ -459,6 +462,20 @@ void NeuralAmpModeler::OnUIOpen()
{
_UpdateControlsFromModel();
}

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::OnParamChange(int paramIdx)
Expand Down Expand Up @@ -513,12 +530,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: 18 additions & 0 deletions NeuralAmpModeler/NeuralAmpModelerControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,23 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren
outputModeControl->SetTooltip(
"How to adjust the level of the output.\nRaw=No adjustment.\nNormalized=Adjust the level so that all models "
"are about the same loudness.\nCalibrated=Match the input's digital-analog calibration.");

// Attach highlight color controls
const auto colorArea =
titleArea.GetFromTop(0.5f * height).GetFromLeft(0.5f * width).GetTranslated(0.0f, 47.0f);
const auto highlightArea = colorArea.GetFromLeft(0.5f * width).GetHPadded(-92.0f).GetVPadded(-15.0f);
;
AddNamedChildControl(
new IVColorSwatchControl(highlightArea, "Highlight Color",
[&](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 }, { "" }),
mControlNames.highlightColor)
->SetTooltip("choose your favorite color \nfor the plugin controls");
}

const float halfWidth = PLUG_WIDTH / 2.0f - pad;
Expand Down Expand Up @@ -754,6 +771,7 @@ class NAMSettingsPageControl : public IContainerBaseWithNamedChildren
const std::string modelInfo = "ModelInfo";
const std::string outputMode = "OutputMode";
const std::string title = "Title";
const std::string highlightColor = "Highlight Color";
} mControlNames;

class InputLevelControl : public IEditableTextControl
Expand Down
3 changes: 3 additions & 0 deletions NeuralAmpModeler/Unserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void NeuralAmpModeler::_UnserializeApplyConfig(nlohmann::json& config)

mNAMPath.Set(static_cast<std::string>(config["NAMPath"]).c_str());
mIRPath.Set(static_cast<std::string>(config["IRPath"]).c_str());
mHighLightColor.Set(static_cast<std::string>(config["HighLightColor"]).c_str());

if (mNAMPath.GetLength())
{
Expand All @@ -77,6 +78,8 @@ int _UnserializePathsAndExpectedKeys(const iplug::IByteChunk& chunk, int startPo
config["NAMPath"] = std::string(path.Get());
pos = chunk.GetStr(path, pos);
config["IRPath"] = std::string(path.Get());
pos = chunk.GetStr(path, pos);
config["HighLightColor"] = std::string(path.Get());

for (auto it = paramNames.begin(); it != paramNames.end(); ++it)
{
Expand Down
Loading