34 lines
627 B
C++
34 lines
627 B
C++
#include "widget.h"
|
|
|
|
void Widget::input(const sf::Event &event)
|
|
{
|
|
for (auto& child : _children)
|
|
child->input(event);
|
|
}
|
|
|
|
void Widget::update()
|
|
{
|
|
for (auto& child : _children)
|
|
child->update();
|
|
}
|
|
|
|
void Widget::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
|
{
|
|
if (!_is_visible)
|
|
return;
|
|
|
|
for (auto& child : _children)
|
|
child->draw(target, states);
|
|
}
|
|
|
|
void Widget::setVisibility(bool is_visible)
|
|
{
|
|
_is_visible = is_visible;
|
|
}
|
|
|
|
void Widget::addChild(const std::shared_ptr<Widget> &child)
|
|
{
|
|
child->_parent = shared_from_this();
|
|
_children.emplace_back(child);
|
|
}
|