Hi there,
I’m having an hard time here trying to understand what i do wrong.
Using the default LookAndFeel class allows me to recall sliders values when i close and open again the plugin in my daw. ValueTree Attachment works fine.
But when my custom LookAndFeel gets called automations work perfectly fine, closing and opening again my plugin wouldn’t recall the last ValueState, and saving ValueState with the daw and recalling it would work only if reloaded twice.
Would anybody get an advice? I can’t figure out if i should create a specific function in my custom LookAndFell or if i simply do something wrong.
Here is what the LookAndFeel function looks like
void setParameters(float cubes, float marginCubes, float marginHeight)
{
mcubes = cubes;
mmarginCubes = marginCubes;
mmarginHeight = marginHeight;
}
void drawRotarySlider(juce::Graphics& g, int x, int y, int width, int height, float sliderPos, float startAngle, float endAngle, juce::Slider& slider) override
{
auto* colour = &colour0;
g.setColour(colour->withAlpha(0.0f));
g.drawRect(x, y, width, height);
g.setColour(*colour);
auto widthF = float(width);
auto heightF = float(height);
auto textWidthRel = 0.25f;
auto textWidth = widthF * textWidthRel;
aleo.setHeight(textWidth / slider.getName().length());
g.setFont(aleo);
g.drawText(slider.getName(), juce::Rectangle<float>(0.0f, 0.0f, textWidth, heightF), juce::Justification::centredRight, true);
widthF -= textWidth;
auto marginHeightMirror = 1.0f - mmarginHeight;
auto cubesInv = 1.0f / mcubes;
auto cubePerSlider = mcubes * sliderPos;
auto cubesMaxInv = 1.0f / (cubePerSlider - 1.0f);
auto cubeWidth = widthF / (mcubes + mcubes * mmarginCubes * 2.0f);
auto cubeX = cubeWidth * mmarginCubes;
for (auto c = 0.0f; c < cubePerSlider; ++c)
{
auto cRel = c * cubesMaxInv;
auto cubeHeight = heightF * marginHeightMirror;
auto cubeY = heightF - cubeHeight;
auto cubeArea = juce::Rectangle<float>(textWidth + cubeX, cubeY, cubeWidth, cubeHeight);
auto alpha = std::tanh(2.0f * c * cubesInv);
g.setColour(colour->withAlpha(alpha));
g.fillRect(cubeArea);
cubeX += cubeWidth + cubeWidth * mmarginCubes * 2.0f;
}
}
And how i call it
void EMFXAudioProcessorEditor::sliderVisible(juce::Slider& slider)
{
slider.setSliderStyle(juce::Slider::SliderStyle::RotaryHorizontalVerticalDrag);
addAndMakeVisible(slider);
slider.setRange(0.0f, 1.0f, 0.1f);
slider.setValue(0.5f);
slider.setLookAndFeel(&olaf2);
olaf2.setParameters(35.0, 0.1, 0.0);
}
Thanks a lot!