- reformat to JUCE-Guidelines

- added Matrix => half working ;)
This commit is contained in:
Maurice Grönwoldt 2020-06-13 16:52:16 +02:00
commit ac22ea5e75
58 changed files with 1220 additions and 799 deletions

View file

@ -4,40 +4,49 @@
#include "BaseComponent.h"
#include "../../Fonts/Fonts.h"
#include <utility>
BaseComponent::BaseComponent(const std::string& processId) {
BaseComponent::BaseComponent (const std::string& processId)
{
m_processId = processId;
}
BaseComponent::~BaseComponent() {
m_label.reset();
BaseComponent::~BaseComponent ()
{
m_label.reset ();
}
void BaseComponent::addLabel(const std::string &label_text, LabelPosition labelPosition) {
void BaseComponent::addLabel (const std::string& label_text, LabelPosition labelPosition)
{
m_enableLabel = true;
m_label = std::make_shared<LabelComponent>(this, label_text);
m_label->setPosition(labelPosition);
m_label = std::make_shared<LabelComponent> (this, label_text);
m_label->setPosition (labelPosition);
}
void BaseComponent::resized() {
if (m_enableLabel && m_label != nullptr) {
LabelPosition position = m_label->getLabelPosition();
if (position == LabelPosition::TOP) {
m_label->setBounds(0, 0, getWidth(), 15);
} else if (position == LabelPosition::BOTTOM) {
m_label->setBounds(0, getHeight() - 20, getWidth(), 15);
void BaseComponent::resized ()
{
if (m_enableLabel && m_label != nullptr)
{
LabelPosition position = m_label->getLabelPosition ();
if (position == LabelPosition::TOP)
{
m_label->setBounds (0, 0, getWidth (), 15);
}
else if (position == LabelPosition::BOTTOM)
{
m_label->setBounds (0, getHeight () - 20, getWidth (), 15);
}
}
}
void BaseComponent::paint(Graphics &g) {
g.setFont(VenoFonts::getNormal());
void BaseComponent::paint (Graphics& g)
{
g.setFont (*VenoFonts::getNormal ());
}
void BaseComponent::setParameter(std::string name, std::string group) {
m_name = std::move(name);
m_group = std::move(group);
setName(m_name);
void BaseComponent::setParameter (std::string name, std::string group)
{
m_name = std::move (name);
m_group = std::move (group);
setName (m_name);
}

View file

@ -13,22 +13,21 @@
/**
* this is the base Component of all VeNo Components... it has all important Methods
*/
class BaseComponent : public Component {
class BaseComponent : public Component
{
private:
std::string m_group;
std::string m_name;
bool m_enableLabel = false;
std::shared_ptr<LabelComponent> m_label;
public:
explicit BaseComponent(const std::string& processId);
~BaseComponent() override;
void addLabel(const std::string& label, LabelPosition labelPosition);
void setParameter(std::string name, std::string group);
void resized() override;
void paint(Graphics &g) override;
explicit BaseComponent (const std::string& processId);
~BaseComponent () override;
void addLabel (const std::string& label, LabelPosition labelPosition);
void setParameter (std::string name, std::string group);
void resized () override;
void paint (Graphics& g) override;
protected:
std::string m_processId;
};
#endif //VENO_BASECOMPONENT_H

View file

@ -7,49 +7,56 @@
#include "../../../Core/Config.h"
#include "../../../Fonts/Fonts.h"
SidebarLCD::SidebarLCD(const std::string &process_id) : BaseComponent(process_id) {
waveform = std::make_unique<Waveforms>(process_id);
addAndMakeVisible(*waveform);
SidebarLCD::SidebarLCD (const std::string& process_id) : BaseComponent (process_id)
{
waveform = std::make_unique<Waveforms> (process_id);
addAndMakeVisible (*waveform);
}
SidebarLCD::~SidebarLCD() {
waveform.reset(nullptr);
SidebarLCD::~SidebarLCD ()
{
waveform.reset (nullptr);
}
void SidebarLCD::drawHeadline(Graphics &g) {
float fontSize = VeNo::Utils::setFontSize(12.0f, g) + 2;
void SidebarLCD::drawHeadline (Graphics& g)
{
float fontSize = VeNo::Utils::setFontSize (12.0f, g) + 2;
int line = m_innerY + fontSize + 2;
g.drawText(">>> VeNo <<<", 0, m_innerY, getWidth() - m_width, fontSize,
Justification::centred,
true);
g.drawLine(0, line, getWidth(), line);
g.drawText (">>> VeNo <<<", 0, m_innerY, getWidth () - m_width, fontSize,
Justification::centred,
true);
g.drawLine (0, line, getWidth (), line);
}
void SidebarLCD::drawFooter(Graphics &g) {
float fontSize = VeNo::Utils::setFontSize(8.0f, g) + 4;
void SidebarLCD::drawFooter (Graphics& g)
{
float fontSize = VeNo::Utils::setFontSize (8.0f, g) + 4;
int space = m_innerY + fontSize;
int line = getHeight() - space;
g.drawText("by VersusTuneZ", 0, line, getWidth() - m_width, fontSize,
Justification::horizontallyCentred,
true);
g.drawLine(0, line - 4, getWidth(), line - 4);
int line = getHeight () - space;
g.drawText ("by VersusTuneZ", 0, line, getWidth () - m_width, fontSize,
Justification::horizontallyCentred,
true);
g.drawLine (0, line - 4, getWidth (), line - 4);
}
void SidebarLCD::resized() {
float topSpace = (12 * Config::getInstance()->getScale()) + 4 + m_innerY;
if (waveform != nullptr) {
waveform->setBounds(0, topSpace*2, getWidth(), getHeight() - (topSpace*4));
void SidebarLCD::resized ()
{
float topSpace = (12 * Config::getInstance ()->getScale ()) + 4 + m_innerY;
if (waveform != nullptr)
{
waveform->setBounds (0, topSpace * 2, getWidth (), getHeight () - (topSpace * 4));
}
}
void SidebarLCD::paint(Graphics &g) {
std::shared_ptr<Theme> theme = Config::getInstance()->getCurrentTheme();
auto colour = theme->getColour(ThemeColour::lcd_bg);
g.fillAll(colour);
void SidebarLCD::paint (Graphics& g)
{
std::shared_ptr<Theme> theme = Config::getInstance ()->getCurrentTheme ();
auto colour = theme->getColour (ThemeColour::lcd_bg);
g.fillAll (colour);
// background
auto accent = theme->getColour(ThemeColour::lcd);
g.setColour(accent);
g.setFont(VenoFonts::getLCD());
drawHeadline(g);
drawFooter(g);
auto accent = theme->getColour (ThemeColour::lcd);
g.setColour (accent);
g.setFont (*VenoFonts::getLCD ());
drawHeadline (g);
drawFooter (g);
}

View file

@ -9,24 +9,20 @@
#include "../BaseComponent.h"
#include "Waveforms.h"
class SidebarLCD : public BaseComponent {
class SidebarLCD : public BaseComponent
{
private:
int m_innerX = 5;
int m_innerY = 5;
int m_width = m_innerX * 2;
public:
explicit SidebarLCD(const std::string &process_id);
~SidebarLCD();
void resized() override;
void paint(Graphics &g) override;
explicit SidebarLCD (const std::string& process_id);
~SidebarLCD ();
void resized () override;
void paint (Graphics& g) override;
protected:
void drawHeadline(Graphics &g);
void drawFooter(Graphics &g);
void drawHeadline (Graphics& g);
void drawFooter (Graphics& g);
std::unique_ptr<Waveforms> waveform;
};
#endif //VENO_SIDEBARLCD_H

View file

@ -9,227 +9,270 @@
#include "../../../VenoInstance.h"
#include "../../../Fonts/Fonts.h"
Waveforms::Waveforms(const std::string &processId) : BaseComponent(processId) {
m_context.setOpenGLVersionRequired(OpenGLContext::OpenGLVersion::openGL3_2);
m_context.setRenderer(this);
m_context.setContinuousRepainting(false);
m_context.setComponentPaintingEnabled(true);
m_context.attachTo(*this);
auto fps = Config::getInstance()->getFps();
startTimerHz(Config::getInstance()->getFps());
std::srand(unsigned(time(nullptr)));
pickRandomText = (std::rand() % RANDOM_TEXT_COUNT);
Waveforms::Waveforms (const std::string& processId) : BaseComponent (processId)
{
m_context.setOpenGLVersionRequired (OpenGLContext::OpenGLVersion::openGL3_2);
m_context.setRenderer (this);
m_context.setContinuousRepainting (false);
m_context.setComponentPaintingEnabled (true);
m_context.attachTo (*this);
auto fps = Config::getInstance ()->getFps ();
startTimerHz (Config::getInstance ()->getFps ());
std::srand (unsigned (time (nullptr)));
pickRandomText = (std::rand () % RANDOM_TEXT_COUNT);
m_ticks = 0;
// is something that
m_time_needed = roundToInt(4000 / (1000 / fps));
m_time_needed_startup = roundToInt(1000 / (1000 / fps));
m_time_needed = roundToInt (4000 / (1000 / fps));
m_time_needed_startup = roundToInt (1000 / (1000 / fps));
}
Waveforms::~Waveforms() {
stopTimer();
shaderProgram.reset();
m_context.detach();
Waveforms::~Waveforms ()
{
stopTimer ();
shaderProgram.reset ();
m_context.detach ();
}
void Waveforms::newOpenGLContextCreated() {
compileOpenGLShaderProgram();
void Waveforms::newOpenGLContextCreated ()
{
compileOpenGLShaderProgram ();
}
void Waveforms::openGLContextClosing() {
void Waveforms::openGLContextClosing ()
{
}
void Waveforms::renderOpenGL() {
if (!isShowing() || shaderProgram == nullptr || !shaderProgram->getLastError().isEmpty()) {
void Waveforms::renderOpenGL ()
{
if (!isShowing () || shaderProgram == nullptr || !shaderProgram->getLastError ().isEmpty ())
{
return;
}
auto theme = Config::getInstance()->getCurrentTheme();
if (theme == nullptr) {
auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr)
{
return;
}
glViewport(0, 0, getWidth(), getHeight());
OpenGLHelpers::clear(theme->getColour(ThemeColour::lcd_bg));
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
shaderProgram->use();
auto color = theme->getColour(ThemeColour::lcd);
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(),
color.getFloatAlpha());
if (m_isWelcome || m_isStarting || m_isChangingData) {
glViewport (0, 0, getWidth (), getHeight ());
OpenGLHelpers::clear (theme->getColour (ThemeColour::lcd_bg));
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
shaderProgram->use ();
auto color = theme->getColour (ThemeColour::lcd);
shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
color.getFloatAlpha ());
if (m_isWelcome || m_isStarting || m_isChangingData)
{
return;
}
switch (m_mode) {
switch (m_mode)
{
case 1:
drawAudioOutput();
drawAudioOutput ();
break;
case 2:
drawWaveTable();
drawWaveTable ();
break;
case 3:
drawSpectrum();
drawSpectrum ();
break;
default:
drawPeakMeter();
drawPeakMeter ();
}
}
void Waveforms::handleAsyncUpdate() {
void Waveforms::handleAsyncUpdate ()
{
}
void Waveforms::compileOpenGLShaderProgram() {
void Waveforms::compileOpenGLShaderProgram ()
{
std::unique_ptr<OpenGLShaderProgram> shaderProgramAttempt
= std::make_unique<OpenGLShaderProgram>(m_context);
if (shaderProgramAttempt->addVertexShader({BinaryData::WaveForm_vertex_glsl})
&& shaderProgramAttempt->addFragmentShader({BinaryData::WaveForm_fragment_glsl})
&& shaderProgramAttempt->link()) {
shaderProgram = std::move(shaderProgramAttempt);
= std::make_unique<OpenGLShaderProgram> (m_context);
if (shaderProgramAttempt->addVertexShader ({BinaryData::WaveForm_vertex_glsl})
&& shaderProgramAttempt->addFragmentShader ({BinaryData::WaveForm_fragment_glsl})
&& shaderProgramAttempt->link ())
{
shaderProgram = std::move (shaderProgramAttempt);
}
}
void Waveforms::mouseDown(const MouseEvent &e) {
if (!m_enableModeToggle) {
void Waveforms::mouseDown (const MouseEvent& e)
{
if (!m_enableModeToggle)
{
return;
}
m_mode++;
if (m_mode > 3) {
if (m_mode > 3)
{
m_mode = 0;
}
}
void Waveforms::mouseDrag(const MouseEvent &e) {
void Waveforms::mouseDrag (const MouseEvent& e)
{
//do nothing... you faggot
}
void Waveforms::timerCallback() {
if (m_isWelcome || m_isStarting || m_isChangingData || needToClear) {
repaint();
} else {
if (m_context.isAttached()) {
m_context.triggerRepaint();
void Waveforms::timerCallback ()
{
if (m_isWelcome || m_isStarting || m_isChangingData || needToClear)
{
repaint ();
}
else
{
if (m_context.isAttached ())
{
m_context.triggerRepaint ();
}
}
}
void Waveforms::drawWaveTable() {
void Waveforms::drawWaveTable ()
{
// this will draw the current selected oscillator :D
}
void Waveforms::drawAudioOutput() {
void Waveforms::drawAudioOutput ()
{
// draw audio from the oscillators
auto instance = VenoInstance::getInstance(BaseComponent::m_processId);
auto buffer = instance->audioBuffer->getBuffer();
glBegin(GL_LINE_STRIP);
auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
auto buffer = instance->audioBuffer->getBuffer ();
glBegin (GL_LINE_STRIP);
float posX = -1;
float inc = 2.0f / buffer.size();
for (float i : buffer) {
glVertex2f(posX, i);
float inc = 2.0f / buffer.size ();
for (float i : buffer)
{
glVertex2f (posX, i);
posX += inc;
}
glEnd();
glEnd ();
}
void Waveforms::drawPeakMeter() {
auto theme = Config::getInstance()->getCurrentTheme();
if (theme == nullptr) {
void Waveforms::drawPeakMeter ()
{
auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr)
{
return;
}
auto instance = VenoInstance::getInstance(BaseComponent::m_processId);
instance->audioBuffer->calcPeak();
auto instance = VenoInstance::getInstance (BaseComponent::m_processId);
instance->audioBuffer->calcPeak ();
// draw peak signal
auto leftChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->leftPeak, -80.0f), -80.0f, 6.0f, -1.0f,
1.0f);
selectColourByPeak(leftChannel);
glBegin(GL_TRIANGLES);
glVertex2f(-0.9f, leftChannel);
glVertex2f(-0.9f, -1.0f);
glVertex2f(-0.01f, -1.0f);
glVertex2f(-0.9f, leftChannel);
glVertex2f(-0.01f, leftChannel);
glVertex2f(-0.01f, -1.0f);
glEnd();
auto rightChannel = jmap(Decibels::gainToDecibels(instance->audioBuffer->rightPeak, -80.0f), -80.0f, 6.0f, -1.0f,
auto leftChannel = jmap (Decibels::gainToDecibels (instance->audioBuffer->leftPeak, -80.0f), -80.0f, 6.0f, -1.0f,
1.0f);
selectColourByPeak(rightChannel);
glBegin(GL_TRIANGLES);
glVertex2f(0.9f, rightChannel);
glVertex2f(0.9f, -1.0f);
glVertex2f(0.01f, -1.0f);
glVertex2f(0.9f, rightChannel);
glVertex2f(0.01f, rightChannel);
glVertex2f(0.01f, -1.0f);
glEnd();
selectColourByPeak (leftChannel);
glBegin (GL_TRIANGLES);
glVertex2f (-0.9f, leftChannel);
glVertex2f (-0.9f, -1.0f);
glVertex2f (-0.01f, -1.0f);
glVertex2f (-0.9f, leftChannel);
glVertex2f (-0.01f, leftChannel);
glVertex2f (-0.01f, -1.0f);
glEnd ();
auto rightChannel = jmap (Decibels::gainToDecibels (instance->audioBuffer->rightPeak, -80.0f), -80.0f, 6.0f, -1.0f,
1.0f);
selectColourByPeak (rightChannel);
glBegin (GL_TRIANGLES);
glVertex2f (0.9f, rightChannel);
glVertex2f (0.9f, -1.0f);
glVertex2f (0.01f, -1.0f);
glVertex2f (0.9f, rightChannel);
glVertex2f (0.01f, rightChannel);
glVertex2f (0.01f, -1.0f);
glEnd ();
}
void Waveforms::paint(Graphics &g) {
std::shared_ptr<Theme> theme = Config::getInstance()->getCurrentTheme();
auto accent = theme->getColour(ThemeColour::lcd);
g.setColour(accent);
g.setFont(VenoFonts::getLCD());
VeNo::Utils::setFontSize(16.0f, g);
if (m_isWelcome) {
drawWelcome(g, getWidth(), getHeight(), 0, 0);
void Waveforms::paint (Graphics& g)
{
std::shared_ptr<Theme> theme = Config::getInstance ()->getCurrentTheme ();
auto accent = theme->getColour (ThemeColour::lcd);
g.setColour (accent);
g.setFont (*VenoFonts::getLCD ());
VeNo::Utils::setFontSize (16.0f, g);
if (m_isWelcome)
{
drawWelcome (g, getWidth (), getHeight (), 0, 0);
m_ticks++;
if (m_ticks > m_time_needed_startup) {
if (m_ticks > m_time_needed_startup)
{
m_isWelcome = false;
m_ticks = 0;
needToClear = true;
}
} else if (m_isStarting) {
g.drawText(m_warmUpText[pickRandomText], 0, 0, getWidth(), getHeight(),
Justification::centred, true);
}
else if (m_isStarting)
{
g.drawText (m_warmUpText[pickRandomText], 0, 0, getWidth (), getHeight (),
Justification::centred, true);
m_ticks++;
if (m_ticks > m_time_needed_startup) {
if (m_ticks > m_time_needed_startup)
{
m_isStarting = false;
m_ticks = 0;
needToClear = true;
}
} else if (m_isChangingData) {
drawChangedParameter(g, getWidth(), getHeight(), 0, 0);
}
else if (m_isChangingData)
{
drawChangedParameter (g, getWidth (), getHeight (), 0, 0);
m_ticks++;
if (m_ticks > m_time_needed) {
if (m_ticks > m_time_needed)
{
m_isChangingData = false;
m_ticks = 0;
needToClear = true;
}
} else {
g.resetToDefaultState();
}
else
{
g.resetToDefaultState ();
needToClear = false;
}
}
void Waveforms::drawChangedParameter(Graphics &g, int w, int h, int x, int y) const {
void Waveforms::drawChangedParameter (Graphics& g, int w, int h, int x, int y) const
{
int halfHeight = h / 2;
float font = VeNo::Utils::setFontSize(12, g);
g.drawText(changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true);
g.drawText(std::to_string(changedValue), x, y + halfHeight + 4, w, font, Justification::centred,
true);
float font = VeNo::Utils::setFontSize (12, g);
g.drawText (changingParameter, x, y + halfHeight - font, w, font, Justification::centred, true);
g.drawText (std::to_string (changedValue), x, y + halfHeight + 4, w, font, Justification::centred,
true);
}
void Waveforms::drawWelcome(Graphics &g, int w, int h, int x, int y) {
float font = VeNo::Utils::setFontSize(12, g);
void Waveforms::drawWelcome (Graphics& g, int w, int h, int x, int y)
{
float font = VeNo::Utils::setFontSize (12, g);
int halfHeight = h / 2;
g.drawText(m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true);
g.drawText(SystemStats::getLogonName(), x, y + halfHeight + 4, w, font, Justification::centred,
true);
g.drawText (m_readyText, x, y + halfHeight - font, w, font, Justification::centred, true);
g.drawText (SystemStats::getLogonName (), x, y + halfHeight + 4, w, font, Justification::centred,
true);
}
void Waveforms::drawSpectrum() {
void Waveforms::drawSpectrum ()
{
}
void Waveforms::selectColourByPeak(float value) {
auto theme = Config::getInstance()->getCurrentTheme();
if (theme == nullptr) {
void Waveforms::selectColourByPeak (float value)
{
auto theme = Config::getInstance ()->getCurrentTheme ();
if (theme == nullptr)
{
return;
}
auto color = theme->getColour(ThemeColour::lcd);
if (value > 0.8 && value < 0.9) {
color = theme->getColour(ThemeColour::warning);
auto color = theme->getColour (ThemeColour::lcd);
if (value > 0.8 && value < 0.9)
{
color = theme->getColour (ThemeColour::warning);
}
if (value > 0.9) {
color = theme->getColour(ThemeColour::clip);
if (value > 0.9)
{
color = theme->getColour (ThemeColour::clip);
}
shaderProgram->setUniform("color", color.getFloatRed(), color.getFloatGreen(), color.getFloatBlue(),
color.getFloatAlpha());
shaderProgram->setUniform ("color", color.getFloatRed (), color.getFloatGreen (), color.getFloatBlue (),
color.getFloatAlpha ());
}

View file

@ -9,17 +9,18 @@
#include "../BaseComponent.h"
#define RANDOM_TEXT_COUNT 5
// opengl context :D
class Waveforms : public BaseComponent,
private OpenGLRenderer,
private AsyncUpdater,
private Timer {
private Timer
{
protected:
bool m_enableModeToggle = true;
int m_mode = 0;
std::string m_readyText = "=WELCOME=";
std::string m_warmUpText[RANDOM_TEXT_COUNT] = {"Warmup...", "Mayonnaise", "Dont shake the baby", "Awesome stuff", "drink beer"};
std::string m_warmUpText[RANDOM_TEXT_COUNT] = {"Warmup...", "Mayonnaise", "Dont shake the baby", "Awesome stuff",
"drink beer"};
int pickRandomText = 0;
bool m_isWelcome = true;
bool m_isStarting = true;
@ -28,46 +29,29 @@ protected:
int m_time_needed = 0;
bool needToClear = false;
public:
explicit Waveforms(const std::string &processId);
~Waveforms() override;
void newOpenGLContextCreated() override;
void openGLContextClosing() override;
void renderOpenGL() override;
void handleAsyncUpdate() override;
void mouseDown(const MouseEvent &e) override;
void mouseDrag(const MouseEvent &e) override;
void paint(Graphics &g) override;
explicit Waveforms (const std::string& processId);
~Waveforms () override;
void newOpenGLContextCreated () override;
void openGLContextClosing () override;
void renderOpenGL () override;
void handleAsyncUpdate () override;
void mouseDown (const MouseEvent& e) override;
void mouseDrag (const MouseEvent& e) override;
void paint (Graphics& g) override;
bool m_isChangingData = false;
std::string changingParameter = "";
float changedValue = 0;
private:
void timerCallback() override;
void drawWaveTable();
void drawAudioOutput();
void drawSpectrum();
void drawPeakMeter(); //?!
void drawChangedParameter(Graphics &g, int w, int h, int x, int y) const;
void drawWelcome(Graphics &g, int w, int h, int x, int y);
void compileOpenGLShaderProgram();
void selectColourByPeak(float value);
void timerCallback () override;
void drawWaveTable ();
void drawAudioOutput ();
void drawSpectrum ();
void drawPeakMeter (); //?!
void drawChangedParameter (Graphics& g, int w, int h, int x, int y) const;
void drawWelcome (Graphics& g, int w, int h, int x, int y);
void compileOpenGLShaderProgram ();
void selectColourByPeak (float value);
OpenGLContext m_context;
std::unique_ptr<OpenGLShaderProgram> shaderProgram;
};
#endif //VENO_WAVEFORMS_H

View file

@ -4,29 +4,36 @@
#include "LabelComponent.h"
LabelComponent::LabelComponent(Component *parent, std::string name) {
LabelComponent::LabelComponent (Component* parent, std::string name)
{
m_text = name;
m_parent = parent;
m_label = std::make_shared<Label>(m_parent->getName(), name);
m_label = std::make_shared<Label> (m_parent->getName (), name);
}
LabelComponent::~LabelComponent() {
m_label.reset();
LabelComponent::~LabelComponent ()
{
m_label.reset ();
}
void LabelComponent::resized() {
if (m_label != nullptr) {
m_label->setBounds(0, 0, getWidth(), getHeight());
void LabelComponent::resized ()
{
if (m_label != nullptr)
{
m_label->setBounds (0, 0, getWidth (), getHeight ());
}
}
void LabelComponent::paint(Graphics &g) {
void LabelComponent::paint (Graphics& g)
{
}
void LabelComponent::setPosition(LabelPosition position) {
void LabelComponent::setPosition (LabelPosition position)
{
m_position = position;
}
LabelPosition LabelComponent::getLabelPosition() {
LabelPosition LabelComponent::getLabelPosition ()
{
return m_position;
}

View file

@ -7,28 +7,26 @@
#include "JuceHeader.h"
enum LabelPosition {
enum LabelPosition
{
NO_LABEL,
TOP,
BOTTOM
};
class LabelComponent : public Component {
class LabelComponent : public Component
{
public:
LabelComponent(Component *parent, std::string name);
~LabelComponent() override;
void resized() override;
void paint(Graphics &g) override;
void setPosition(LabelPosition position);
LabelPosition getLabelPosition();
LabelComponent (Component* parent, std::string name);
~LabelComponent () override;
void resized () override;
void paint (Graphics& g) override;
void setPosition (LabelPosition position);
LabelPosition getLabelPosition ();
protected:
private:
std::string m_text;
Component *m_parent;
Component* m_parent;
LabelPosition m_position = LabelPosition::NO_LABEL;
std::shared_ptr<Label> m_label;
};
#endif //VENO_LABELCOMPONENT_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 13.06.20.
//
#include "Sidebar.h"

View file

@ -0,0 +1,19 @@
//
// Created by versustune on 13.06.20.
//
#ifndef VENO_SIDEBAR_H
#define VENO_SIDEBAR_H
#include "JuceHeader.h"
#include "../../Components/BaseComponent.h"
class Sidebar : public BaseComponent
{
private:
public:
Sidebar ();
~Sidebar ();
protected:
};
#endif //VENO_SIDEBAR_H

View file

@ -0,0 +1,5 @@
//
// Created by versustune on 13.06.20.
//
#include "SidebarMixer.h"

View file

@ -0,0 +1,11 @@
//
// Created by versustune on 13.06.20.
//
#ifndef VENO_SIDEBARMIXER_H
#define VENO_SIDEBARMIXER_H
class SidebarMixer
{
};
#endif //VENO_SIDEBARMIXER_H

View file

@ -7,11 +7,10 @@
#include "JuceHeader.h"
class CrazyLook : public LookAndFeel_V4 {
class CrazyLook : public LookAndFeel_V4
{
private:
public:
protected:
};
#endif //VENO_CRAZYLOOK_H

View file

@ -7,11 +7,10 @@
#include "JuceHeader.h"
class FlatLook : public LookAndFeel_V4 {
class FlatLook : public LookAndFeel_V4
{
private:
public:
protected:
};
#endif //VENO_FLATLOOK_H

View file

@ -5,20 +5,24 @@
#include "LookHandler.h"
#include "../../Core/Config.h"
LookHandler::LookHandler() {
selectLook(Config::getInstance()->getCurrentLook());
LookHandler::LookHandler ()
{
selectLook (Config::getInstance ()->getCurrentLook ());
}
LookHandler::~LookHandler() {
LookHandler::~LookHandler ()
{
//delete this shit!
delete m_feels[0];
delete m_feels[1];
}
void LookHandler::selectLook(int index) {
void LookHandler::selectLook (int index)
{
m_currentLook = index;
}
LookAndFeel_V4* LookHandler::getLook() {
LookAndFeel_V4* LookHandler::getLook ()
{
return m_feels[m_currentLook];
}

View file

@ -13,19 +13,18 @@
/**
* overwrite the basic m_look and feel based on the selected Look and Feel :)
*/
class LookHandler : public LookAndFeel_V4 {
class LookHandler : public LookAndFeel_V4
{
private:
std::shared_ptr<LookAndFeel_V4> m_look;
int m_currentLook = 0;
public:
LookHandler();
~LookHandler() override;
void selectLook(int index);
LookAndFeel_V4* getLook();
LookHandler ();
~LookHandler () override;
void selectLook (int index);
LookAndFeel_V4* getLook ();
protected:
//currently both available themes are CrazyLook <-- (this is a fun one xD) and FlatLook
LookAndFeel_V4 *m_feels[2] = {new FlatLook(), new CrazyLook()};
LookAndFeel_V4* m_feels[2] = {new FlatLook (), new CrazyLook ()};
};
#endif //VENO_LOOKHANDLER_H

View file

@ -5,73 +5,87 @@
#include "Theme.h"
#include "ThemePresets.cpp"
Theme::Theme(std::shared_ptr<PropertiesFile> file) {
Theme::Theme (std::shared_ptr<PropertiesFile> file)
{
m_configFile = file;
}
Theme::~Theme() {
m_colours.clear();
m_configFile.reset();
Theme::~Theme ()
{
m_colours.clear ();
m_configFile.reset ();
}
void Theme::setColour(ThemeColour index, Colour *colour) {
void Theme::setColour (ThemeColour index, Colour* colour)
{
auto c = m_colours[index];
if (c) {
if (c)
{
delete c;
m_colours[index] = colour;
} else {
}
else
{
m_colours[index] = colour;
}
m_configFile->setValue(ThemeColourToString(index), colour->toString());
m_configFile->save();
m_configFile->setValue (ThemeColourToString (index), colour->toString ());
m_configFile->save ();
}
void Theme::init() {
getColourFromConfig(ThemeColour::bg);
getColourFromConfig(ThemeColour::bg_two);
getColourFromConfig(ThemeColour::accent);
getColourFromConfig(ThemeColour::accent_two);
getColourFromConfig(ThemeColour::warning);
getColourFromConfig(ThemeColour::clip);
getColourFromConfig(ThemeColour::lcd_bg);
getColourFromConfig(ThemeColour::lcd);
void Theme::init ()
{
getColourFromConfig (ThemeColour::bg);
getColourFromConfig (ThemeColour::bg_two);
getColourFromConfig (ThemeColour::accent);
getColourFromConfig (ThemeColour::accent_two);
getColourFromConfig (ThemeColour::warning);
getColourFromConfig (ThemeColour::clip);
getColourFromConfig (ThemeColour::lcd_bg);
getColourFromConfig (ThemeColour::lcd);
}
void Theme::getColourFromConfig(ThemeColour index) {
std::string key = ThemeColourToString(index);
if (m_configFile->containsKey(key)) {
auto baseColour = Colour::fromString(m_configFile->getValue(key));
auto *colour = new Colour(baseColour.getRed(), baseColour.getGreen(), baseColour.getBlue());
void Theme::getColourFromConfig (ThemeColour index)
{
std::string key = ThemeColourToString (index);
if (m_configFile->containsKey (key))
{
auto baseColour = Colour::fromString (m_configFile->getValue (key));
auto* colour = new Colour (baseColour.getRed (), baseColour.getGreen (), baseColour.getBlue ());
delete m_colours[index];
m_colours[index] = colour;
} else {
}
else
{
// should only trigger if config is broken or empty :)
setLEDTheme(this);
setLEDTheme (this);
}
}
Colour Theme::getColour(ThemeColour index) {
if (m_colours[index] != nullptr) {
Colour Theme::getColour (ThemeColour index)
{
if (m_colours[index] != nullptr)
{
return *m_colours[index];
}
return Colour(255, 255, 255);
return Colour (255, 255, 255);
}
void Theme::setColourThemeById(int id) {
switch (id) {
void Theme::setColourThemeById (int id)
{
switch (id)
{
case 1:
setLEDTheme(this);
setLEDTheme (this);
break;
case 2:
setOrangeDreamTheme(this);
setOrangeDreamTheme (this);
break;
case 3:
setBloodTheme(this);
setBloodTheme (this);
break;
case 4:
setOceanTheme(this);
setOceanTheme (this);
default:
break;
}

View file

@ -8,25 +8,23 @@
#include "JuceHeader.h"
#include <vector>
enum class ThemeColour {
enum class ThemeColour
{
bg = 0, bg_two, accent, accent_two, warning, clip, lcd_bg, lcd
};
class Theme {
class Theme
{
private:
public:
explicit Theme(std::shared_ptr<PropertiesFile> file);
~Theme();
void setColour(ThemeColour index, Colour *colour);
void setColourThemeById(int id);
void init();
void getColourFromConfig(ThemeColour index);
Colour getColour(ThemeColour index);
explicit Theme (std::shared_ptr<PropertiesFile> file);
~Theme ();
void setColour (ThemeColour index, Colour* colour);
void setColourThemeById (int id);
void init ();
void getColourFromConfig (ThemeColour index);
Colour getColour (ThemeColour index);
protected:
std::map<ThemeColour, Colour*> m_colours;
std::shared_ptr<PropertiesFile> m_configFile;
};
#endif //VENO_THEME_H

View file

@ -9,53 +9,58 @@
* maybe i want a double m_look and feel... that's make it easier to implement different knob styles, slider styles and co
*/
void setLEDTheme(Theme *theme) {
theme->setColour(ThemeColour::bg, new Colour(41, 47, 54));
theme->setColour(ThemeColour::bg_two, new Colour(217, 217, 217));
theme->setColour(ThemeColour::accent, new Colour(169, 208, 142));
theme->setColour(ThemeColour::accent_two, new Colour(139, 171, 117));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21));
theme->setColour(ThemeColour::lcd, new Colour(169, 208, 142));
void setLEDTheme (Theme* theme)
{
theme->setColour (ThemeColour::bg, new Colour (41, 47, 54));
theme->setColour (ThemeColour::bg_two, new Colour (217, 217, 217));
theme->setColour (ThemeColour::accent, new Colour (169, 208, 142));
theme->setColour (ThemeColour::accent_two, new Colour (139, 171, 117));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::lcd, new Colour (169, 208, 142));
}
void setBloodTheme(Theme *theme) {
theme->setColour(ThemeColour::bg, new Colour(41, 47, 54));
theme->setColour(ThemeColour::bg_two, new Colour(64, 67, 78));
theme->setColour(ThemeColour::accent, new Colour(180, 38, 50));
theme->setColour(ThemeColour::accent_two, new Colour(115, 47, 64));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(0, 0, 0));
theme->setColour(ThemeColour::lcd, new Colour(180, 38, 78));
void setBloodTheme (Theme* theme)
{
theme->setColour (ThemeColour::bg, new Colour (41, 47, 54));
theme->setColour (ThemeColour::bg_two, new Colour (64, 67, 78));
theme->setColour (ThemeColour::accent, new Colour (180, 38, 50));
theme->setColour (ThemeColour::accent_two, new Colour (115, 47, 64));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (0, 0, 0));
theme->setColour (ThemeColour::lcd, new Colour (180, 38, 78));
}
void setOrangeDreamTheme(Theme *theme) {
theme->setColour(ThemeColour::bg, new Colour(21, 21, 21));
theme->setColour(ThemeColour::bg_two, new Colour(42, 42, 42));
theme->setColour(ThemeColour::accent, new Colour(255, 160, 0));
theme->setColour(ThemeColour::accent_two, new Colour(255, 11, 0));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(33, 33, 33));
theme->setColour(ThemeColour::lcd, new Colour(255, 160, 0));
void setOrangeDreamTheme (Theme* theme)
{
theme->setColour (ThemeColour::bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::bg_two, new Colour (42, 42, 42));
theme->setColour (ThemeColour::accent, new Colour (255, 160, 0));
theme->setColour (ThemeColour::accent_two, new Colour (255, 11, 0));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (33, 33, 33));
theme->setColour (ThemeColour::lcd, new Colour (255, 160, 0));
}
void setOceanTheme(Theme *theme) {
theme->setColour(ThemeColour::bg, new Colour(55, 63, 81));
theme->setColour(ThemeColour::bg_two, new Colour(64, 67, 78));
theme->setColour(ThemeColour::accent, new Colour(0, 141, 213));
theme->setColour(ThemeColour::accent_two, new Colour(0, 129, 194));
theme->setColour(ThemeColour::clip, new Colour(255, 23, 68));
theme->setColour(ThemeColour::warning, new Colour(255, 143, 0));
theme->setColour(ThemeColour::lcd_bg, new Colour(21, 21, 21));
theme->setColour(ThemeColour::lcd, new Colour(0, 129, 194));
void setOceanTheme (Theme* theme)
{
theme->setColour (ThemeColour::bg, new Colour (55, 63, 81));
theme->setColour (ThemeColour::bg_two, new Colour (64, 67, 78));
theme->setColour (ThemeColour::accent, new Colour (0, 141, 213));
theme->setColour (ThemeColour::accent_two, new Colour (0, 129, 194));
theme->setColour (ThemeColour::clip, new Colour (255, 23, 68));
theme->setColour (ThemeColour::warning, new Colour (255, 143, 0));
theme->setColour (ThemeColour::lcd_bg, new Colour (21, 21, 21));
theme->setColour (ThemeColour::lcd, new Colour (0, 129, 194));
}
std::string ThemeColourToString(ThemeColour index) {
switch (index) {
std::string ThemeColourToString (ThemeColour index)
{
switch (index)
{
case ThemeColour::bg:
return "colour_bg";
case ThemeColour::bg_two: