blob: 9a093071d928fd6ca9f092dd803e5c3e2cfb3659 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "KnobWithLabel.h"
KnobWithLabel::KnobWithLabel(const juce::String& text, juce::AudioParameterFloat* param)
: param(param)
{
addAndMakeVisible(label);
label.setText(text, juce::dontSendNotification);
label.setJustificationType(juce::Justification::centred);
label.setFont(juce::Font(juce::FontOptions().withHeight(10.0f)));
addAndMakeVisible(knob);
knob.setSliderStyle(juce::Slider::Rotary);
knob.setTextBoxStyle(juce::Slider::TextBoxBelow, false, 50, 20);
knob.setValue(param->get());
auto range = param->getNormalisableRange();
knob.setRange(range.start, range.end, range.interval);
knob.onValueChange = [this]()
{
if (this->param != nullptr)
{
*this->param = (float) knob.getValue();
}
};
}
KnobWithLabel::~KnobWithLabel() {}
void
KnobWithLabel::resized()
{
knob.setBounds(0, 0, getWidth(), getHeight());
label.setBounds(0, -10, getWidth(), getHeight());
}
|