layout make lines non-fixed
This commit is contained in:
15
Source/LampshadeLine.h
Normal file
15
Source/LampshadeLine.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
class LampshadeLine {
|
||||
public:
|
||||
LampshadeLine(bool orientation, float x, float y) : orientation(orientation), x(x), y(y)
|
||||
{
|
||||
}
|
||||
|
||||
bool orientation;
|
||||
float x;
|
||||
float y;
|
||||
|
||||
const static bool Horizontal = 0;
|
||||
const static bool Vertical = 1;
|
||||
};
|
@@ -1,11 +1,3 @@
|
||||
//
|
||||
// LookAndFeel.h
|
||||
// lampshade
|
||||
//
|
||||
// Created by Veit Heller on 19.06.17.
|
||||
//
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
|
@@ -4,8 +4,14 @@
|
||||
|
||||
|
||||
LampshadeAudioProcessorEditor::LampshadeAudioProcessorEditor (LampshadeAudioProcessor& p)
|
||||
: AudioProcessorEditor (&p), processor (p), nlines (3), lineThickness(4)
|
||||
: 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.)
|
||||
};
|
||||
component.setTextBoxStyle(Slider::NoTextBox, true, 0, 0);
|
||||
setSize(400, 300);
|
||||
component.setLookAndFeel(gui);
|
||||
@@ -20,13 +26,23 @@ void LampshadeAudioProcessorEditor::paint (Graphics& g)
|
||||
{
|
||||
g.fillAll(Colours::white);
|
||||
|
||||
for (int i = 1; i < nlines; i++) {
|
||||
g.drawLine(0, getHeight()*((float)i / nlines), getWidth(), getHeight()*((float)i / nlines), lineThickness);
|
||||
g.drawLine(getWidth()*((float) i /nlines), 0, getWidth()*((float) i /nlines), getHeight(), lineThickness);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LampshadeAudioProcessorEditor::resized()
|
||||
{
|
||||
component.setBounds(getWidth()/nlines+lineThickness/2, getHeight()/nlines+lineThickness/2, getWidth()/nlines-lineThickness+1, getHeight()/nlines-lineThickness);
|
||||
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);
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h"
|
||||
#include "PluginProcessor.h"
|
||||
#include "LookAndFeel.h"
|
||||
|
||||
#include "LampshadeLine.h"
|
||||
|
||||
class LampshadeAudioProcessorEditor : public AudioProcessorEditor
|
||||
{
|
||||
@@ -17,7 +19,7 @@ public:
|
||||
private:
|
||||
LampshadeAudioProcessor& processor;
|
||||
LampshadeLookAndFeel* gui = new LampshadeLookAndFeel();
|
||||
int nlines;
|
||||
std::list<LampshadeLine> lines;
|
||||
int lineThickness;
|
||||
|
||||
Slider component;
|
||||
|
Reference in New Issue
Block a user