editor: added resize and better line representation
This commit is contained in:
@@ -2,47 +2,47 @@
|
||||
#include "PluginEditor.h"
|
||||
|
||||
|
||||
|
||||
LampshadeAudioProcessorEditor::LampshadeAudioProcessorEditor (LampshadeAudioProcessor& p)
|
||||
: AudioProcessorEditor (&p), processor (p), lineThickness(4)
|
||||
LampshadeAudioProcessorEditor::LampshadeAudioProcessorEditor(LampshadeAudioProcessor& p)
|
||||
: AudioProcessorEditor (&p), processor (p), lineThickness(4)
|
||||
{
|
||||
lines = {
|
||||
LampshadeLine(LampshadeLine::Horizontal, 1./3., 1./3.),
|
||||
LampshadeLine(LampshadeLine::Horizontal, 2./3., 2./3.),
|
||||
LampshadeLine(LampshadeLine::Vertical, 1./3., 1./3.),
|
||||
LampshadeLine(LampshadeLine::Vertical, 2./3., 2./3.)
|
||||
hlines = {
|
||||
LampshadeLine(LampshadeLine::Horizontal, 1./3.),
|
||||
LampshadeLine(LampshadeLine::Horizontal, 2./3.)
|
||||
};
|
||||
component.setTextBoxStyle(Slider::NoTextBox, true, 0, 0);
|
||||
setSize(400, 300);
|
||||
component.setLookAndFeel(gui);
|
||||
addAndMakeVisible(component);
|
||||
vlines = {
|
||||
LampshadeLine(LampshadeLine::Vertical, 1./3.),
|
||||
LampshadeLine(LampshadeLine::Vertical, 1./3.+0.01, 1./3.+0.01, 1./3.),
|
||||
LampshadeLine(LampshadeLine::Vertical, 2./3.+0.05, 2./3.+0.05, 2./3.),
|
||||
LampshadeLine(LampshadeLine::Vertical, 2./3.)
|
||||
};
|
||||
slider.setTextBoxStyle(Slider::NoTextBox, true, 0, 0);
|
||||
setSize(600, 600);
|
||||
slider.setLookAndFeel(gui);
|
||||
addAndMakeVisible(slider);
|
||||
corner = new ResizableCornerComponent(this, new ComponentBoundsConstrainer());
|
||||
addAndMakeVisible(corner);
|
||||
}
|
||||
|
||||
LampshadeAudioProcessorEditor::~LampshadeAudioProcessorEditor()
|
||||
{
|
||||
}
|
||||
|
||||
void LampshadeAudioProcessorEditor::paint (Graphics& g)
|
||||
void LampshadeAudioProcessorEditor::paint(Graphics& g)
|
||||
{
|
||||
g.fillAll(Colours::white);
|
||||
|
||||
for (auto line : lines) {
|
||||
if (line.orientation == LampshadeLine::Horizontal) {
|
||||
g.drawLine(0, getHeight()*line.x, getWidth(), getHeight()*line.y, lineThickness);
|
||||
} else {
|
||||
g.drawLine(getWidth()*line.x, 0, getWidth()*line.y, getHeight(), lineThickness);
|
||||
}
|
||||
for (auto line : vlines) {
|
||||
g.drawLine(getWidth()*line.x, 0, getWidth()*line.y, getHeight()*line.len, lineThickness);
|
||||
}
|
||||
for (auto line : hlines) {
|
||||
g.drawLine(0, getHeight()*line.x, getWidth()*line.len, getHeight()*line.y, lineThickness);
|
||||
}
|
||||
}
|
||||
|
||||
void LampshadeAudioProcessorEditor::resized()
|
||||
{
|
||||
int h = 1;
|
||||
int w = 1;
|
||||
|
||||
for (auto l : lines) { l.orientation == LampshadeLine::Horizontal ? w++ : h++; }
|
||||
|
||||
w = getWidth() / w;
|
||||
h = getHeight() / h;
|
||||
component.setBounds(w+lineThickness/2, h+lineThickness/2, w-lineThickness+1, h-lineThickness);
|
||||
// hardcoded because they should stay in the same rectangle
|
||||
float w = getWidth() * vlines[0].x;
|
||||
float h = getHeight() * hlines[0].x;
|
||||
slider.setBounds(w+lineThickness/2, h+lineThickness/2, w-lineThickness, h-lineThickness);
|
||||
}
|
||||
|
Reference in New Issue
Block a user