reVeno/Source/Veno/GUI/Components/BaseComponent.cpp

56 lines
1.3 KiB
C++
Raw Normal View History

2020-04-03 13:23:19 +02:00
//
// Created by versustune on 17.03.20.
//
#include "BaseComponent.h"
2020-06-14 21:14:28 +02:00
#include "../../Utils.h"
2020-06-13 10:56:20 +02:00
#include "../../Fonts/Fonts.h"
#include <utility>
BaseComponent::BaseComponent (const std::string& processId)
{
2020-06-13 10:56:20 +02:00
m_processId = processId;
}
BaseComponent::~BaseComponent ()
{
2020-06-14 21:14:28 +02:00
m_label.reset();
}
void BaseComponent::addLabel (const std::string& label_text, LabelPosition labelPosition)
{
m_enableLabel = true;
2020-06-14 21:14:28 +02:00
m_label = std::make_shared<LabelComponent>(this, label_text);
m_label->setPosition(labelPosition);
addAndMakeVisible(*m_label);
}
void BaseComponent::resized ()
{
if (m_enableLabel && m_label != nullptr)
{
2020-06-14 21:14:28 +02:00
LabelPosition position = m_label->getLabelPosition();
if (position == LabelPosition::TOP)
{
2020-06-14 21:14:28 +02:00
m_label->setBounds(0, 0, getWidth(), VeNo::Utils::getCalculatedHeight(15));
}
else if (position == LabelPosition::BOTTOM)
{
2020-06-14 21:14:28 +02:00
auto height = VeNo::Utils::getCalculatedHeight(15);
m_label->setBounds(0, getHeight() - height, getWidth(), height);
}
}
}
void BaseComponent::paint (Graphics& g)
{
2020-06-14 21:14:28 +02:00
g.setFont(*VenoFonts::getNormal());
}
void BaseComponent::setParameter (std::string name, std::string group)
{
2020-06-14 21:14:28 +02:00
m_name = std::move(name);
m_group = std::move(group);
setName(m_name);
}