2018-06-21 09:00:53 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: Widget.hpp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Created: 21/06/2018 07:19:27
|
|
|
|
*
|
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef WIDGET_HPP_
|
|
|
|
#define WIDGET_HPP_
|
|
|
|
|
|
|
|
#include "IDrawable.hpp"
|
2018-12-28 06:19:40 +01:00
|
|
|
#include "Rect.hpp"
|
|
|
|
#include "SDLHeaders.hpp"
|
2018-06-21 09:00:53 +02:00
|
|
|
#include "Transformable.hpp"
|
|
|
|
|
|
|
|
class Widget : public IDrawable, public Transformable {
|
|
|
|
public:
|
|
|
|
Widget(Widget *parent = nullptr) : m_parent(parent) {}
|
|
|
|
Widget(unsigned int width, unsigned int height, Widget *parent = nullptr)
|
|
|
|
: m_parent(parent), m_width(width), m_height(height) {}
|
|
|
|
|
2018-12-28 06:19:40 +01:00
|
|
|
virtual void onEvent(const SDL_Event &) {}
|
2018-06-27 05:39:56 +02:00
|
|
|
virtual void update() {}
|
|
|
|
|
2018-06-21 09:00:53 +02:00
|
|
|
bool isPointInWidget(float x, float y);
|
|
|
|
|
2018-12-28 06:19:40 +01:00
|
|
|
FloatRect getGlobalBounds() const;
|
2018-06-25 22:30:38 +02:00
|
|
|
|
2018-06-23 01:32:23 +02:00
|
|
|
const Widget *parent() { return m_parent; }
|
2018-06-28 11:31:51 +02:00
|
|
|
void setParent(Widget *parent) { m_parent = parent; }
|
2018-06-23 01:32:23 +02:00
|
|
|
|
2018-06-21 09:00:53 +02:00
|
|
|
unsigned int width() const { return m_width; }
|
|
|
|
unsigned int height() const { return m_height; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Widget *m_parent = nullptr;
|
|
|
|
|
|
|
|
unsigned int m_width = 0;
|
|
|
|
unsigned int m_height = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // WIDGET_HPP_
|