16 std::shared_ptr<Skin> skin;
18 glm::vec2 anchor_point;
23 glm::dvec2 last_mouse_scroll_position;
26 static std::vector<glm::vec3>
generateRect(
float screen_width,
float screen_height,
float x_pos,
float y_pos,
float width,
float height) noexcept;
36 Element(
VertexData vertex_data, std::shared_ptr<Skin> skin,
const unsigned int layer);
49 std::shared_ptr<Skin>
getSkin()
const noexcept;
55 void setSkin(std::shared_ptr<Skin> skin) noexcept;
85 void setWidth(
const float width) noexcept;
91 void setHeight(
const float height) noexcept;
109 glm::vec4
getColor()
const noexcept;
115 void setColor(
const glm::vec4 color) noexcept;
117 virtual std::string
to_string()
const noexcept
override;
127 virtual std::string
className()
const noexcept
override;
131 virtual void onStart()
override;
132 virtual bool onUpdate(
const double delta)
override;
135 void onNotifyNow(std::shared_ptr<Events::Event> event)
override;
167 virtual void onKeyDown(
const int key) = 0;
173 virtual void onKeyUp(
const int key) = 0;
185 virtual void onScroll(
const glm::dvec2 position_change) = 0;
186 virtual void log(el::base::type::ostream_t& os)
const override;
void setSkin(std::shared_ptr< Skin > skin) noexcept
Sets the UI skin.
Definition: element.cpp:56
void handleQueuedEvent(std::shared_ptr< Events::Event > event) override
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received...
Definition: element.cpp:137
float getHeight() const noexcept
Gets the height.
Definition: element.cpp:79
virtual void onLeftClickRelease()=0
Called when element has left click released over it.
virtual std::string className() const noexceptoverride
Returns a string representing the class name.
Definition: element.cpp:213
virtual void onCursorEnter()=0
Called when the mosue cursor goes over the element.
virtual void onDestroy() override
Called when the engine is shutting down.
Definition: element.cpp:127
glm::vec2 getAnchorPoint() const noexcept
Gets the anchor point.
Definition: element.cpp:60
virtual void onKeyDown(const int key)=0
Called when a key is pressed while element is in focus.
virtual void onRightClickRelease()=0
Called when element has right click released over it.
float getWidth() const noexcept
Gets the width.
Definition: element.cpp:75
virtual void onStart() override
Called when the engine starts and when a new scene is loaded.
Definition: element.cpp:130
Class for renderable.
Definition: renderable.h:22
bool isPointWithin(glm::vec2 point) noexcept
Determines if point is within element.
Definition: element.cpp:111
float getTextPadding() const noexcept
Gets the text padding.
Definition: element.cpp:91
virtual void log(el::base::type::ostream_t &os) const override
Definition: element.cpp:225
std::shared_ptr< Skin > getSkin() const noexcept
Gets the UI skin.
Definition: element.cpp:52
Class for vertex data.
Definition: vertex_data.h:17
Element(VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer)
Element constructor.
Definition: element.cpp:16
static std::vector< glm::vec3 > generateRect(float screen_width, float screen_height, float x_pos, float y_pos, float width, float height) noexcept
Definition: element.cpp:26
void setColor(const glm::vec4 color) noexcept
Sets the color.
Definition: element.cpp:103
void setAnchorPoint(const glm::vec2 anchor_point)
Sets the anchor point.
Definition: element.cpp:64
void onNotifyNow(std::shared_ptr< Events::Event > event) override
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure ...
Definition: element.cpp:205
virtual void onRightClick()=0
Called when element is right clicked.
virtual void onKeyUp(const int key)=0
Called when a key is released while element is in focus.
virtual void onLeftClick()=0
Called when element is left clicked.
void setHeight(const float height) noexcept
Sets the height.
Definition: element.cpp:87
virtual std::string to_string() const noexceptoverride
Returns a string representation of the object.
Definition: element.cpp:217
virtual bool onUpdate(const double delta) override
Called every engine loop.
Definition: element.cpp:133
glm::vec4 getColor() const noexcept
Gets the color.
Definition: element.cpp:99
virtual void onKeyRepeat(const int key)=0
Called when a key is repeated while element is in focus.
void setWidth(const float width) noexcept
Sets the width.
Definition: element.cpp:83
static std::vector< glm::vec2 > basisTexCoords() noexcept
Definition: element.cpp:39
virtual unsigned long long getValueForSorting() const noexceptoverride
Gets the value for sorting.
Definition: element.cpp:209
virtual void onCursorLeave()=0
Called when the mouse cursor goes off the element.
virtual ~Element()
Destroys element.
Definition: element.cpp:22
virtual void onScroll(const glm::dvec2 position_change)=0
Called when the mouse wheel is scrolled while element is in focus.
void setTextPadding(const float text_padding) noexcept
Sets the text padding.
Definition: element.cpp:95