-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginEditor.cpp
More file actions
91 lines (70 loc) · 3.37 KB
/
Copy pathPluginEditor.cpp
File metadata and controls
91 lines (70 loc) · 3.37 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "PluginEditor.h"
FlatLineAudioProcessorEditor::FlatLineAudioProcessorEditor (FlatLineAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
setSize (520, 250);
titleLabel.setText ("FlatLine", juce::dontSendNotification);
titleLabel.setJustificationType (juce::Justification::centred);
titleLabel.setFont (juce::Font (28.0f, juce::Font::bold));
addAndMakeVisible (titleLabel);
setupSlider (inputSlider, inputLabel, "Input");
setupSlider (driveSlider, driveLabel, "Drive");
setupSlider (lookaheadSlider, lookaheadLabel, "Lookahead");
setupSlider (outputSlider, outputLabel, "Output");
driveSlider.setNumDecimalPlacesToDisplay (6);
lookaheadSlider.setTextValueSuffix (" ms");
deltaButton.setButtonText ("Delta");
addAndMakeVisible (deltaButton);
inputAttachment = std::make_unique<SliderAttachment> (audioProcessor.apvts, "input", inputSlider);
driveAttachment = std::make_unique<SliderAttachment> (audioProcessor.apvts, "drive", driveSlider);
lookaheadAttachment = std::make_unique<SliderAttachment> (audioProcessor.apvts, "lookahead", lookaheadSlider);
outputAttachment = std::make_unique<SliderAttachment> (audioProcessor.apvts, "output", outputSlider);
deltaAttachment = std::make_unique<ButtonAttachment> (audioProcessor.apvts, "delta", deltaButton);
}
void FlatLineAudioProcessorEditor::setupSlider (juce::Slider& slider,
juce::Label& label,
const juce::String& text)
{
slider.setSliderStyle (juce::Slider::RotaryHorizontalVerticalDrag);
slider.setTextBoxStyle (juce::Slider::TextBoxBelow, false, 90, 22);
addAndMakeVisible (slider);
label.setText (text, juce::dontSendNotification);
label.setJustificationType (juce::Justification::centred);
addAndMakeVisible (label);
}
void FlatLineAudioProcessorEditor::paint (juce::Graphics& g)
{
g.fillAll (juce::Colour (0xff101216));
auto area = getLocalBounds().toFloat().reduced (10.0f);
g.setColour (juce::Colour (0xff20242c));
g.fillRoundedRectangle (area, 12.0f);
g.setColour (juce::Colour (0xffd8d8d8));
g.drawRoundedRectangle (area, 12.0f, 1.5f);
g.setColour (juce::Colour (0xff9da7b3));
g.setFont (juce::Font (13.0f));
g.drawFittedText ("Harmonious Records",
getLocalBounds().removeFromBottom (28),
juce::Justification::centred,
1);
}
void FlatLineAudioProcessorEditor::resized()
{
auto area = getLocalBounds().reduced (18);
titleLabel.setBounds (area.removeFromTop (42));
auto buttonArea = area.removeFromBottom (35);
deltaButton.setBounds (buttonArea.withSizeKeepingCentre (100, 26));
auto knobArea = area.reduced (0, 10);
const int knobW = knobArea.getWidth() / 4;
auto setKnob = [&] (juce::Slider& slider,
juce::Label& label,
int index)
{
auto r = knobArea.removeFromLeft (knobW).reduced (8);
label.setBounds (r.removeFromTop (20));
slider.setBounds (r);
};
setKnob (inputSlider, inputLabel, 0);
setKnob (driveSlider, driveLabel, 1);
setKnob (lookaheadSlider, lookaheadLabel, 2);
setKnob (outputSlider, outputLabel, 3);
}