- 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