51 lines
1.1 KiB
C++
51 lines
1.1 KiB
C++
/*
|
|
* UIElement.h
|
|
*
|
|
* Created on: Nov 27, 2016
|
|
* Author: tibi
|
|
*/
|
|
|
|
#ifndef GUI_PRIMITIVES_UIELEMENT_H_
|
|
#define GUI_PRIMITIVES_UIELEMENT_H_
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
#include <gui/primitives/RenderContext.h>
|
|
|
|
namespace farmlands {
|
|
namespace gui {
|
|
namespace primitives {
|
|
|
|
class UIElement
|
|
{
|
|
public:
|
|
UIElement();
|
|
virtual ~UIElement();
|
|
|
|
virtual void render(RenderContext& context);
|
|
virtual bool handleEvent(SDL_Event& event);
|
|
|
|
// Getters & setters
|
|
inline float x() const { return m_x; }
|
|
inline float y() const { return m_y; }
|
|
inline float width() const { return m_w; }
|
|
inline float height() const { return m_h; }
|
|
inline SDL_Color backColor() const { return m_backColor; }
|
|
|
|
virtual void setPosition(float x, float y);
|
|
virtual void setSize(float w, float h);
|
|
virtual void setBackColor(SDL_Color backColor);
|
|
virtual void setBackColor(float r, float g, float b, float a = 1.0f);
|
|
|
|
private:
|
|
float m_x, m_y;
|
|
float m_w, m_h;
|
|
SDL_Color m_backColor;
|
|
};
|
|
|
|
} /* namespace primitives */
|
|
} /* namespace gui */
|
|
} /* namespace farmlands */
|
|
|
|
#endif /* GUI_PRIMITIVES_UIELEMENT_H_ */
|