editor: added resize and better line representation
This commit is contained in:
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
class LampshadeLine {
|
class LampshadeLine {
|
||||||
public:
|
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;
|
bool orientation;
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
float len;
|
||||||
|
|
||||||
const static bool Horizontal = 0;
|
const static bool Horizontal = 0;
|
||||||
const static bool Vertical = 1;
|
const static bool Vertical = 1;
|
||||||
|
@@ -2,47 +2,47 @@
|
|||||||
#include "PluginEditor.h"
|
#include "PluginEditor.h"
|
||||||
|
|
||||||
|
|
||||||
|
LampshadeAudioProcessorEditor::LampshadeAudioProcessorEditor(LampshadeAudioProcessor& p)
|
||||||
LampshadeAudioProcessorEditor::LampshadeAudioProcessorEditor (LampshadeAudioProcessor& p)
|
: AudioProcessorEditor (&p), processor (p), lineThickness(4)
|
||||||
: AudioProcessorEditor (&p), processor (p), lineThickness(4)
|
|
||||||
{
|
{
|
||||||
lines = {
|
hlines = {
|
||||||
LampshadeLine(LampshadeLine::Horizontal, 1./3., 1./3.),
|
LampshadeLine(LampshadeLine::Horizontal, 1./3.),
|
||||||
LampshadeLine(LampshadeLine::Horizontal, 2./3., 2./3.),
|
LampshadeLine(LampshadeLine::Horizontal, 2./3.)
|
||||||
LampshadeLine(LampshadeLine::Vertical, 1./3., 1./3.),
|
|
||||||
LampshadeLine(LampshadeLine::Vertical, 2./3., 2./3.)
|
|
||||||
};
|
};
|
||||||
component.setTextBoxStyle(Slider::NoTextBox, true, 0, 0);
|
vlines = {
|
||||||
setSize(400, 300);
|
LampshadeLine(LampshadeLine::Vertical, 1./3.),
|
||||||
component.setLookAndFeel(gui);
|
LampshadeLine(LampshadeLine::Vertical, 1./3.+0.01, 1./3.+0.01, 1./3.),
|
||||||
addAndMakeVisible(component);
|
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()
|
LampshadeAudioProcessorEditor::~LampshadeAudioProcessorEditor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void LampshadeAudioProcessorEditor::paint (Graphics& g)
|
void LampshadeAudioProcessorEditor::paint(Graphics& g)
|
||||||
{
|
{
|
||||||
g.fillAll(Colours::white);
|
g.fillAll(Colours::white);
|
||||||
|
|
||||||
for (auto line : lines) {
|
for (auto line : vlines) {
|
||||||
if (line.orientation == LampshadeLine::Horizontal) {
|
g.drawLine(getWidth()*line.x, 0, getWidth()*line.y, getHeight()*line.len, lineThickness);
|
||||||
g.drawLine(0, getHeight()*line.x, getWidth(), getHeight()*line.y, lineThickness);
|
}
|
||||||
} else {
|
for (auto line : hlines) {
|
||||||
g.drawLine(getWidth()*line.x, 0, getWidth()*line.y, getHeight(), lineThickness);
|
g.drawLine(0, getHeight()*line.x, getWidth()*line.len, getHeight()*line.y, lineThickness);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LampshadeAudioProcessorEditor::resized()
|
void LampshadeAudioProcessorEditor::resized()
|
||||||
{
|
{
|
||||||
int h = 1;
|
// hardcoded because they should stay in the same rectangle
|
||||||
int w = 1;
|
float w = getWidth() * vlines[0].x;
|
||||||
|
float h = getHeight() * hlines[0].x;
|
||||||
for (auto l : lines) { l.orientation == LampshadeLine::Horizontal ? w++ : h++; }
|
slider.setBounds(w+lineThickness/2, h+lineThickness/2, w-lineThickness, h-lineThickness);
|
||||||
|
|
||||||
w = getWidth() / w;
|
|
||||||
h = getHeight() / h;
|
|
||||||
component.setBounds(w+lineThickness/2, h+lineThickness/2, w-lineThickness+1, h-lineThickness);
|
|
||||||
}
|
}
|
||||||
|
@@ -19,10 +19,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
LampshadeAudioProcessor& processor;
|
LampshadeAudioProcessor& processor;
|
||||||
LampshadeLookAndFeel* gui = new LampshadeLookAndFeel();
|
LampshadeLookAndFeel* gui = new LampshadeLookAndFeel();
|
||||||
std::list<LampshadeLine> lines;
|
std::vector<LampshadeLine> hlines;
|
||||||
|
std::vector<LampshadeLine> vlines;
|
||||||
int lineThickness;
|
int lineThickness;
|
||||||
|
|
||||||
Slider component;
|
Slider slider;
|
||||||
|
ResizableCornerComponent* corner;
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LampshadeAudioProcessorEditor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LampshadeAudioProcessorEditor)
|
||||||
};
|
};
|
||||||
|
@@ -117,7 +117,7 @@ bool LampshadeAudioProcessor::hasEditor() const
|
|||||||
|
|
||||||
AudioProcessorEditor* LampshadeAudioProcessor::createEditor()
|
AudioProcessorEditor* LampshadeAudioProcessor::createEditor()
|
||||||
{
|
{
|
||||||
return new LampshadeAudioProcessorEditor (*this);
|
return new LampshadeAudioProcessorEditor(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LampshadeAudioProcessor::getStateInformation (MemoryBlock& destData)
|
void LampshadeAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||||
|
Reference in New Issue
Block a user