2021-10-05 14:48:28 -04:00
|
|
|
#include "editorwidget.h"
|
2021-11-02 13:03:27 -04:00
|
|
|
#include "core/editor.h"
|
2021-10-05 14:48:28 -04:00
|
|
|
|
2021-12-02 11:02:13 -05:00
|
|
|
EditorWidget::EditorWidget(Callbacks&& callbacks) :
|
|
|
|
_input(std::move(callbacks.onInput)),
|
|
|
|
_update(std::move(callbacks.onUpdate)),
|
|
|
|
_draw(std::move(callbacks.onDraw))
|
2021-10-05 14:48:28 -04:00
|
|
|
{}
|
|
|
|
|
|
|
|
void EditorWidget::input(const sf::Event& event)
|
|
|
|
{
|
2021-12-02 11:02:13 -05:00
|
|
|
_input(event);
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWidget::update(const sf::Time& dt)
|
|
|
|
{
|
2021-12-02 11:02:13 -05:00
|
|
|
_update(dt);
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWidget::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
|
|
|
{
|
2021-12-02 11:02:13 -05:00
|
|
|
_draw(target, states);
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWidget::move(const sf::Vector2f& delta)
|
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
(void)delta;
|
|
|
|
// delegate to children
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorWidget::isUnderMouse(int mouse_x, int mouse_y) const
|
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
return _parent->isUnderMouse(mouse_x, mouse_y);
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWidget::setRect(const sf::FloatRect& rect)
|
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
(void)rect;
|
|
|
|
// basically useless beacuse editor widget fills the entire screen
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sf::FloatRect EditorWidget::rect() const
|
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
return {};
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorWidget::setPosition(const sf::Vector2f& position)
|
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
(void)position;
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
sf::Vector2f EditorWidget::position() const
|
|
|
|
{
|
2021-11-02 13:03:27 -04:00
|
|
|
return {};
|
2021-10-05 14:48:28 -04:00
|
|
|
}
|