- cleanup vars

- added LICENSE.txt
- added LabelComponent.cpp
- renamed some variables
- moved instance id to processor
This commit is contained in:
Maurice Grönwoldt 2020-06-08 21:27:17 +02:00
commit d735c1d076
19 changed files with 948 additions and 180 deletions

View file

@ -3,3 +3,42 @@
//
#include "BaseComponent.h"
#include <utility>
BaseComponent::~BaseComponent() {
m_label.reset();
setLookAndFeel(nullptr);
m_lookHandler.reset();
}
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);
}
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) {
}
BaseComponent::BaseComponent() {
m_lookHandler = std::make_shared<LookHandler>();
setLookAndFeel(m_lookHandler->getLook());
}
void BaseComponent::setParameter(std::string name, std::string group) {
m_name = std::move(name);
m_group = std::move(group);
setName(m_name);
}

View file

@ -6,6 +6,8 @@
#define VENO_BASECOMPONENT_H
#include "JuceHeader.h"
#include "LabelComponent.h"
#include "../LookAndFeel/LookHandler.h"
#include <string>
/**
@ -13,11 +15,18 @@
*/
class BaseComponent : public Component {
private:
std::string prefix;
std::string m_group;
std::string m_name;
bool m_enableLabel = false;
std::shared_ptr<LabelComponent> m_label;
std::shared_ptr<LookHandler> m_lookHandler;
public:
BaseComponent() = default;
~BaseComponent() = default;
BaseComponent();
~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:
};

View file

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

View file

@ -0,0 +1,34 @@
//
// Created by versustune on 07.06.20.
//
#ifndef VENO_LABELCOMPONENT_H
#define VENO_LABELCOMPONENT_H
#include "JuceHeader.h"
enum LabelPosition {
NO_LABEL,
TOP,
BOTTOM
};
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();
protected:
private:
std::string m_text;
Component *m_parent;
LabelPosition m_position = LabelPosition::NO_LABEL;
std::shared_ptr<Label> m_label;
};
#endif //VENO_LABELCOMPONENT_H

View file

@ -11,10 +11,14 @@ LookHandler::LookHandler() {
LookHandler::~LookHandler() {
//delete this shit!
delete feels[0];
delete feels[1];
delete m_feels[0];
delete m_feels[1];
}
void LookHandler::selectLook(int index) {
currentLook = index;
m_currentLook = index;
}
LookAndFeel_V4* LookHandler::getLook() {
return m_feels[m_currentLook];
}

View file

@ -11,19 +11,20 @@
#include <memory>
/**
* overwrite the basic look and feel based on the selected Look and Feel :)
* overwrite the basic m_look and feel based on the selected Look and Feel :)
*/
class LookHandler : public LookAndFeel_V4 {
private:
std::shared_ptr<LookAndFeel_V4> look;
int currentLook = 0;
std::shared_ptr<LookAndFeel_V4> m_look;
int m_currentLook = 0;
public:
LookHandler();
~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 *feels[2] = {new FlatLook(), new CrazyLook()};
LookAndFeel_V4 *m_feels[2] = {new FlatLook(), new CrazyLook()};
};

View file

@ -6,25 +6,25 @@
#include "ThemePresets.cpp"
Theme::Theme(std::shared_ptr<PropertiesFile> file) {
configFile = file;
m_configFile = file;
}
Theme::~Theme() {
colours.clear();
configFile.reset();
m_colours.clear();
m_configFile.reset();
}
void Theme::setColour(ThemeColour index, Colour *colour) {
auto c = colours[index];
auto c = m_colours[index];
if (c) {
delete c;
colours[index] = colour;
m_colours[index] = colour;
} else {
colours[index] = colour;
m_colours[index] = colour;
}
configFile->setValue(ThemeColourToString(index), colour->toString());
configFile->save();
m_configFile->setValue(ThemeColourToString(index), colour->toString());
m_configFile->save();
}
@ -42,8 +42,8 @@ void Theme::init() {
void Theme::getColourFromConfig(ThemeColour index) {
std::string key = ThemeColourToString(index);
if (configFile->containsKey(key)) {
auto baseColour = Colour::fromString(configFile->getValue(key));
if (m_configFile->containsKey(key)) {
auto baseColour = Colour::fromString(m_configFile->getValue(key));
auto *colour = new Colour(baseColour.getRed(), baseColour.getGreen(), baseColour.getBlue());
setColour(index, colour);
}

View file

@ -22,8 +22,8 @@ public:
void init();
void getColourFromConfig(ThemeColour index);
protected:
std::map<ThemeColour, Colour*> colours;
std::shared_ptr<PropertiesFile> configFile;
std::map<ThemeColour, Colour*> m_colours;
std::shared_ptr<PropertiesFile> m_configFile;
};

View file

@ -4,9 +4,9 @@
* this file holds function that read some presets
* in the current Theme class
* so we doesn't have lot's of classes that only save some hex codes... and make the coding harder
* also good on this is that the user can slightly change the preset theme and doesn't have to make all of them himself
* also good on this is that the user can slightly change the preset m_theme and doesn't have to make all of them himself
*
* maybe i want a double look and feel... that's make it easier to implement different knob styles, slider styles and co
* 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) {