forked from NaiJi/project-kyoku
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
758 B
C++
28 lines
758 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <SFML/Window/Event.hpp>
|
|
#include <SFML/Graphics/Drawable.hpp>
|
|
|
|
class Widget : public sf::Drawable, std::enable_shared_from_this<Widget>
|
|
{
|
|
public:
|
|
Widget(const std::shared_ptr<Widget>& parent = nullptr);
|
|
|
|
virtual ~Widget() = default;
|
|
|
|
virtual void input(const sf::Event& event) = 0;
|
|
virtual void update() = 0;
|
|
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const = 0;
|
|
virtual void setRect(const sf::FloatRect& rect) = 0;
|
|
virtual void setPosition(const sf::Vector2f& position) = 0;
|
|
|
|
protected:
|
|
void addChild(const std::shared_ptr<Widget>& child);
|
|
|
|
std::vector<std::shared_ptr<Widget>> _children;
|
|
const std::shared_ptr<Widget> _parent;
|
|
};
|
|
|