-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPluginEditor.cpp
More file actions
83 lines (65 loc) · 4.46 KB
/
Copy pathPluginEditor.cpp
File metadata and controls
83 lines (65 loc) · 4.46 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
/*
==============================================================================
This file contains the basic framework code for a JUCE plugin editor.
==============================================================================
*/
#include "PluginProcessor.h"
#include "PluginEditor.h"
//==============================================================================
DistortionPlugInAudioProcessorEditor::DistortionPlugInAudioProcessorEditor (DistortionPlugInAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
addAndMakeVisible(driveKnob = new juce::Slider("Drive"));
driveKnob->setSliderStyle(juce::Slider::Rotary);
driveKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
addAndMakeVisible(rangeKnob = new juce::Slider("Range"));
rangeKnob->setSliderStyle(juce::Slider::Rotary);
rangeKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
addAndMakeVisible(blendKnob = new juce::Slider("Blend"));
blendKnob->setSliderStyle(juce::Slider::Rotary);
blendKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
addAndMakeVisible(volumeKnob = new juce::Slider("Volume"));
volumeKnob->setSliderStyle(juce::Slider::Rotary);
volumeKnob->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
addAndMakeVisible(distSwitch = new juce::Slider("Type"));
distSwitch->setSliderStyle(juce::Slider::LinearHorizontal);
distSwitch->setTextBoxStyle(juce::Slider::NoTextBox, false, 100, 100);
addAndMakeVisible(bypassSwitch = new juce::ToggleButton("Bypass"));
driveAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Drive", *driveKnob);
rangeAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Range", *rangeKnob);
blendAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Blend", *blendKnob);
volumeAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Volume", *volumeKnob);
distAttachment = new juce::AudioProcessorValueTreeState::SliderAttachment(p.getState(), "Type", *distSwitch);
bypassAttachment = new juce::AudioProcessorValueTreeState::ButtonAttachment(p.getState(), "Bypass", *bypassSwitch);
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (500, 200);
}
DistortionPlugInAudioProcessorEditor::~DistortionPlugInAudioProcessorEditor()
{
}
//==============================================================================
void DistortionPlugInAudioProcessorEditor::paint (juce::Graphics& g)
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));
g.setColour (juce::Colours::white);
g.setFont (juce::FontOptions (15.0f));
// g.drawFittedText ("Hello World!", getLocalBounds(), juce::Justification::centred, 1);
g.drawText("Drive", ((getWidth() / 5) * 1) - (100 / 2), (getHeight() / 2) + 5, 100, 100, juce::Justification::centred, false);
g.drawText("Range", ((getWidth() / 5) * 2) - (100 / 2), (getHeight() / 2) + 5, 100, 100, juce::Justification::centred, false);
g.drawText("Blend", ((getWidth() / 5) * 3) - (100 / 2), (getHeight() / 2) + 5, 100, 100, juce::Justification::centred, false);
g.drawText("Volume", ((getWidth() / 5) * 4) - (100 / 2), (getHeight() / 2) + 5, 100, 100, juce::Justification::centred, false);
// g.drawText("Type", (getWidth() / 3) - (100 / 2), (getHeight() / 5), 100, 100, juce::Justification::centred, false);
}
void DistortionPlugInAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
driveKnob->setBounds(((getWidth() / 5) * 1) - (100 / 2), (getHeight() / 2) - (100 / 2), 100, 100);
rangeKnob->setBounds(((getWidth() / 5) * 2) - (100 / 2), (getHeight() / 2) - (100 / 2), 100, 100);
blendKnob->setBounds(((getWidth() / 5) * 3) - (100 / 2), (getHeight() / 2) - (100 / 2), 100, 100);
volumeKnob->setBounds(((getWidth() / 5) * 4) - (100 / 2), (getHeight() / 2) - (100 / 2), 100, 100);
distSwitch->setBounds(((getWidth() / 3) * 2) - (100 / 2), (getHeight() / 5) - (100 / 2), 100, 100);
bypassSwitch->setBounds(((getWidth() / 3) * 1) - (100 / 2), (getHeight() / 5) - (100 / 2), 100, 100);
}