17 : UIBlock(3, 3,
"Header",
"reverb settings"),
18 parameters(p.parameters),
19 previousSelectedIRs(juce::StringArray())
22 isOn.setButtonText(
"STATE");
23 isOn.setClickingTogglesState(
false);
24 isOn.setInterceptsMouseClicks(
false,
false);
26 isOn.setComponentID(p.PID_ACTIVE);
28 isOnLabel.setText(
"reverb", juce::NotificationType::dontSendNotification);
29 isOnLabel.setJustificationType(juce::Justification::topLeft);
30 isOnLabel.attachToComponent(&isOn,
false);
32 isOnAttachment.reset(
new ButtonAttachment(p.parameters,
33 isOn.getComponentID(),
37 juce::String currentIR = p.parameters.state
38 .getChildWithName(p.PID_IR_FILE_CHOICE)
39 .getProperty(
"value");
41 irChoice.setButtonText(currentIR);
43 irChoice.setComponentID(p.PID_IR_FILE_CHOICE);
45 irChoiceLabel.setText(
"impulse response", juce::NotificationType::dontSendNotification);
46 irChoiceLabel.setJustificationType(juce::Justification::topLeft);
47 irChoiceLabel.attachToComponent(&irChoice,
false);
50 auto sampleRateTemp = std::to_string(p.getSampleRate() / 1000);
52 sampleRate.setButtonText(sampleRateTemp.substr(0, 4) +
" kHz");
53 sampleRate.setClickingTogglesState(
false);
54 sampleRate.setInterceptsMouseClicks(
false,
false);
56 sampleRateLabel.setText(
"sample rate", juce::NotificationType::dontSendNotification);
57 sampleRateLabel.setJustificationType(juce::Justification::topLeft);
58 sampleRateLabel.attachToComponent(&sampleRate,
false);
63 addAndMakeVisible(isOn);
64 addAndMakeVisible(irChoice);
65 addAndMakeVisible(sampleRate);
71 g.fillAll(getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId));
73 g.setColour(juce::Colours::white);
86 juce::Rectangle<
int> bounds(getLocalBounds());
88 int boundsWidth = bounds.getWidth();
89 int boundsHeight = bounds.getHeight();
102 std::vector<juce::Rectangle<
int>> cells(3);
103 std::vector<
double> cellWidths = { 0.15, 0.60, 0.25 };
105 for (
int i = 0; i < 3; ++i)
107 cells[i] = bounds.removeFromLeft((
int)std::round(cellWidths[i] * boundsWidth));
109 cells[i].removeFromTop(labelHeight);
110 cells[i].reduce(padding, padding);
114 isOn.setBounds(cells[0]);
115 irChoice.setBounds(cells[1]);
116 sampleRate.setBounds(cells[2]);
float getParam(const juce::AudioProcessorValueTreeState ¶ms, const juce::String &blockId) const
Internal method used to get (and check) a parameter's value.
void resized() override
Manages the layout of UIHeaderBlock when the block is resized.