editor: added resize and better line representation
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
|
||||
class LampshadeLine {
|
||||
public:
|
||||
LampshadeLine(bool orientation, float x, float y) : orientation(orientation), x(x), y(y)
|
||||
{
|
||||
}
|
||||
LampshadeLine(bool orientation, float x, float y, float len) : orientation(orientation), x(x), y(y), len(len) {}
|
||||
LampshadeLine(bool orientation, float x, float y) : orientation(orientation), x(x), y(y), len(1.) {}
|
||||
LampshadeLine(bool orientation, float xy) : orientation(orientation), x(xy), y(xy), len(1.) {}
|
||||
|
||||
bool orientation;
|
||||
float x;
|
||||
float y;
|
||||
float len;
|
||||
|
||||
const static bool Horizontal = 0;
|
||||
const static bool Vertical = 1;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -19,10 +19,12 @@ public:
|
||||
private:
|
||||
LampshadeAudioProcessor& processor;
|
||||
LampshadeLookAndFeel* gui = new LampshadeLookAndFeel();
|
||||
std::list<LampshadeLine> lines;
|
||||
std::vector<LampshadeLine> hlines;
|
||||
std::vector<LampshadeLine> vlines;
|
||||
int lineThickness;
|
||||
|
||||
Slider component;
|
||||
Slider slider;
|
||||
ResizableCornerComponent* corner;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LampshadeAudioProcessorEditor)
|
||||
};
|
||||
|
@@ -117,7 +117,7 @@ bool LampshadeAudioProcessor::hasEditor() const
|
||||
|
||||
AudioProcessorEditor* LampshadeAudioProcessor::createEditor()
|
||||
{
|
||||
return new LampshadeAudioProcessorEditor (*this);
|
||||
return new LampshadeAudioProcessorEditor(*this);
|
||||
}
|
||||
|
||||
void LampshadeAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||
|
Reference in New Issue
Block a user