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

53 lines
1.1 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-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 ()
{
m_label.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)
{
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);
}