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.
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <SFML/Window/Event.hpp>
|
|
#include <SFML/Graphics/Drawable.hpp>
|
|
#include <SFML/Graphics/RenderTarget.hpp>
|
|
|
|
class Widget : public sf::Drawable, public std::enable_shared_from_this<Widget>
|
|
{
|
|
public:
|
|
virtual ~Widget() = default;
|
|
|
|
virtual void input(const sf::Event& event) = 0;
|
|
virtual void update(const sf::Time& dt) = 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;
|
|
virtual bool isUnderMouse(int mouse_x, int mouse_y) const = 0;
|
|
|
|
virtual void setVisibility(bool is_visible = true);
|
|
bool isVisible() const;
|
|
|
|
void addChild(const std::shared_ptr<Widget>& child);
|
|
void setParent(const std::shared_ptr<Widget>& parent);
|
|
|
|
void blockBy(const std::shared_ptr<Widget>& blocker);
|
|
void unblock();
|
|
|
|
protected:
|
|
std::vector<std::shared_ptr<Widget>> _children;
|
|
std::shared_ptr<Widget> _parent;
|
|
std::shared_ptr<Widget> _blocker;
|
|
bool _is_visible = true;
|
|
};
|
|
|