Nymph Game Engine
Chaiscript based Game Engine
|
#include <element.h>
Public Member Functions | |
Element (VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer) | |
Element constructor. More... | |
virtual | ~Element () |
Destroys element. More... | |
std::shared_ptr< Skin > | getSkin () const noexcept |
Gets the UI skin. More... | |
void | setSkin (std::shared_ptr< Skin > skin) noexcept |
Sets the UI skin. More... | |
glm::vec2 | getAnchorPoint () const noexcept |
Gets the anchor point. More... | |
void | setAnchorPoint (const glm::vec2 anchor_point) |
Sets the anchor point. More... | |
float | getWidth () const noexcept |
Gets the width. More... | |
float | getHeight () const noexcept |
Gets the height. More... | |
void | setWidth (const float width) noexcept |
Sets the width. More... | |
void | setHeight (const float height) noexcept |
Sets the height. More... | |
float | getTextPadding () const noexcept |
Gets the text padding. More... | |
void | setTextPadding (const float text_padding) noexcept |
Sets the text padding. More... | |
glm::vec4 | getColor () const noexcept |
Gets the color. More... | |
void | setColor (const glm::vec4 color) noexcept |
Sets the color. More... | |
virtual std::string | to_string () const noexceptoverride |
Returns a string representation of the object. More... | |
bool | isPointWithin (glm::vec2 point) noexcept |
Determines if point is within element. More... | |
virtual std::string | className () const noexceptoverride |
Returns a string representing the class name. More... | |
virtual void | onDestroy () override |
Called when the engine is shutting down. More... | |
virtual void | onStart () override |
Called when the engine starts and when a new scene is loaded. More... | |
virtual bool | onUpdate (const double delta) override |
Called every engine loop. More... | |
void | handleQueuedEvent (std::shared_ptr< Events::Event > event) override |
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More... | |
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 the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More... | |
virtual unsigned long long | getValueForSorting () const noexceptoverride |
Gets the value for sorting. More... | |
virtual void | onLeftClick ()=0 |
Called when element is left clicked. More... | |
virtual void | onRightClick ()=0 |
Called when element is right clicked. More... | |
virtual void | onLeftClickRelease ()=0 |
Called when element has left click released over it. More... | |
virtual void | onRightClickRelease ()=0 |
Called when element has right click released over it. More... | |
virtual void | onCursorEnter ()=0 |
Called when the mosue cursor goes over the element. More... | |
virtual void | onCursorLeave ()=0 |
Called when the mouse cursor goes off the element. More... | |
virtual void | onKeyDown (const int key)=0 |
Called when a key is pressed while element is in focus. More... | |
virtual void | onKeyUp (const int key)=0 |
Called when a key is released while element is in focus. More... | |
virtual void | onKeyRepeat (const int key)=0 |
Called when a key is repeated while element is in focus. More... | |
virtual void | onScroll (const glm::dvec2 position_change)=0 |
Called when the mouse wheel is scrolled while element is in focus. More... | |
virtual void | log (el::base::type::ostream_t &os) const override |
Public Member Functions inherited from Graphics::Renderable | |
Renderable (const unsigned int vertex_array_object, const VertexData &vertex_data) | |
Renderable constructor. More... | |
Renderable (const Renderable &)=delete | |
Renderable | operator= (Renderable &)=delete |
Renderable (Renderable &&renderable) | |
Renderable & | operator= (Renderable &&renderable) |
virtual | ~Renderable () |
void | setShader (std::shared_ptr< Shader > shader_object) noexcept |
Sets the shader. More... | |
std::shared_ptr< Shader > | getShader () const noexcept |
Gets the shader. More... | |
void | addTexture (const unsigned int unit, const std::string uniform_name, std::shared_ptr< BaseTexture > texture_object) noexcept |
Adds a texture. More... | |
void | removeTexture (const unsigned int unit) |
Removes a texture. More... | |
std::map< unsigned int, std::shared_ptr< BaseTexture > > | getTextures () const noexcept |
Gets the textures. More... | |
void | setLightReactive (const bool reactive) noexcept |
Sets if the renderable should be light reactive. More... | |
bool | isLightReactive () const noexcept |
Determines if light reactive. More... | |
void | setAmbientLight (const glm::vec3 color) noexcept |
Sets the ambient light. More... | |
glm::vec3 | getAmbientLight () const noexcept |
Gets the ambient light. More... | |
void | setAmbientIntensity (const float intensity) noexcept |
Sets the ambient intensity. More... | |
float | getAmbientIntensity () const noexcept |
Gets the ambient intensity. More... | |
void | addInfluencingLight (std::shared_ptr< Light > light) noexcept |
Adds an influencing light. More... | |
void | clearInfluencingLights () |
Clears all influencing lights. More... | |
float | highestZ () const noexcept |
The highest possible z value in the renderable. More... | |
unsigned int | getVertexArrayBinding () const noexcept |
Gets the vertex array binding. More... | |
VertexData | getVertexData () const noexcept |
Gets the vertex data. More... | |
Public Member Functions inherited from Component | |
Component () | |
Component constructor. More... | |
void | setTransform (std::shared_ptr< Transform > transform) |
Sets the transform. More... | |
std::shared_ptr< Transform > | getTransform () const noexcept |
Gets the transform. More... | |
void | setActive (const bool active) noexcept |
Sets the component active or inactive. More... | |
bool | isActive () const noexcept |
Determines if active. More... | |
unsigned int | getId () const noexcept |
Gets the identifier. More... | |
bool | operator< (Component &other) noexcept |
Operator < using getValueForSorting. More... | |
virtual | ~Component () |
Destroys the object. More... | |
Public Member Functions inherited from Events::Subject | |
virtual | ~Subject ()=default |
virtual void | notify (std::shared_ptr< Event > event) |
notify is used to tell observers of an event. More... | |
virtual void | notifyNow (std::shared_ptr< Event > event) |
notifyNow is used to tell observers of an event as an interrupt. More... | |
virtual void | addObserver (std::shared_ptr< Observer > observer) |
Adds an observer. More... | |
virtual void | removeObserver (std::shared_ptr< Observer > observer) |
Removes an observer. More... | |
Public Member Functions inherited from Events::Observer | |
virtual | ~Observer () |
void | onNotify (std::shared_ptr< Event > event) |
When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More... | |
void | processEventQueue () |
This should be called once ever loop for every Observer to properly use queued events. More... | |
Static Protected Member Functions | |
static std::vector< glm::vec3 > | generateRect (float screen_width, float screen_height, float x_pos, float y_pos, float width, float height) noexcept |
static std::vector< glm::vec2 > | basisTexCoords () noexcept |
Additional Inherited Members | |
Static Public Member Functions inherited from Graphics::Renderable | |
static std::shared_ptr < Renderable > | create (const VertexData &vertex_data) |
Renderable factory function. More... | |
Protected Member Functions inherited from Graphics::Renderable | |
void | setUniform (const Uniform &uniform) noexcept |
Renderable () | |
Protected Member Functions inherited from Events::Observer | |
std::shared_ptr< Event > | getEvent () |
bool | eventsWaiting () const noexcept |
Protected Attributes inherited from Graphics::Renderable | |
std::set< Uniform > | uniforms |
Protected Attributes inherited from Component | |
std::weak_ptr< Entity > | entity |
std::shared_ptr< Transform > | transform |
bool | active |
unsigned int | id |
Static Protected Attributes inherited from Component | |
static unsigned int | next_id = 0 |
Graphics::UI::Element::Element | ( | VertexData | vertex_data, |
std::shared_ptr< Skin > | skin, | ||
const unsigned int | layer | ||
) |
Element constructor.
[in] | vertex_data | The vertex data |
[in] | skin | The UI skin |
References Graphics::Renderable::addTexture(), Component::getTransform(), and Graphics::Renderable::setShader().
|
virtual |
Destroys element.
|
staticprotectednoexcept |
|
overridevirtualnoexcept |
Returns a string representing the class name.
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, Graphics::UI::Area, and Graphics::UI::QuitButton.
Referenced by generated::getElementModule().
|
staticprotectednoexcept |
|
noexcept |
Gets the anchor point.
Referenced by generated::getElementModule(), and Graphics::UI::TextArea::onStart().
|
noexcept |
Gets the color.
Referenced by generated::getElementModule(), Graphics::UI::Button::onCursorEnter(), Graphics::UI::TextField::onCursorEnter(), Graphics::UI::Button::onCursorLeave(), and Graphics::UI::TextField::onCursorLeave().
|
noexcept |
|
noexcept |
|
noexcept |
|
overridevirtualnoexcept |
Gets the value for sorting.
Reimplemented from Graphics::Renderable.
References Component::getTransform().
|
noexcept |
|
overridevirtual |
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.
[in] | event | The event |
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextArea, and Graphics::UI::TextField.
References Graphics::Renderable::handleQueuedEvent(), Component::isActive(), isPointWithin(), Events::KEY_DOWN, Events::KEY_REPEAT, Events::KEY_UP, Events::MOUSE_BUTTON_DOWN, Events::MOUSE_BUTTON_UP, Events::MOUSE_CURSOR, Events::MOUSE_SCROLL, onCursorEnter(), onCursorLeave(), onKeyDown(), onKeyRepeat(), onKeyUp(), onLeftClick(), onLeftClickRelease(), onRightClick(), onRightClickRelease(), and onScroll().
Referenced by Graphics::UI::Area::handleQueuedEvent(), and onNotifyNow().
|
noexcept |
Determines if point is within element.
[in] | point | The point |
Referenced by generated::getElementModule(), and handleQueuedEvent().
|
overridevirtual |
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, and Graphics::UI::Button.
References to_string().
|
pure virtual |
Called when the mosue cursor goes over the element.
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when the mouse cursor goes off the element.
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
overridevirtual |
Called when the engine is shutting down.
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextField, Graphics::UI::TextArea, and Graphics::UI::Area.
Referenced by Graphics::UI::Area::onDestroy().
|
pure virtual |
Called when a key is pressed while element is in focus.
[in] | key | The key |
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when a key is repeated while element is in focus.
[in] | key | The key |
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when a key is released while element is in focus.
[in] | key | The key |
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when element is left clicked.
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, Graphics::UI::Area, and Graphics::UI::QuitButton.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when element has left click released over it.
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
overridevirtual |
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.
[in] | event | The event |
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextArea, and Graphics::UI::TextField.
References handleQueuedEvent().
|
pure virtual |
Called when element is right clicked.
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when element has right click released over it.
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
pure virtual |
Called when the mouse wheel is scrolled while element is in focus.
[in] | position_change | The position change |
Implemented in Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::Area.
Referenced by handleQueuedEvent().
|
overridevirtual |
Called when the engine starts and when a new scene is loaded.
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextField, Graphics::UI::TextArea, and Graphics::UI::Area.
Referenced by Graphics::UI::Area::onStart().
|
overridevirtual |
Called every engine loop.
[in] | delta | The delta |
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextField, Graphics::UI::TextArea, and Graphics::UI::Area.
References Graphics::Renderable::onUpdate().
Referenced by Graphics::UI::Area::onUpdate().
void Graphics::UI::Element::setAnchorPoint | ( | const glm::vec2 | anchor_point | ) |
Sets the anchor point.
[in] | anchor_point | The anchor point |
References Graphics::Renderable::setUniform().
Referenced by generated::getElementModule().
|
noexcept |
Sets the color.
[in] | color | The color |
Referenced by generated::getElementModule(), Graphics::UI::Button::onCursorEnter(), Graphics::UI::TextField::onCursorEnter(), Graphics::UI::Button::onCursorLeave(), Graphics::UI::TextField::onCursorLeave(), Graphics::UI::Button::onLeftClick(), and Graphics::UI::Button::onLeftClickRelease().
|
noexcept |
|
noexcept |
|
noexcept |
Sets the text padding.
[in] | text_padding | The text padding |
Referenced by generated::getElementModule(), and Graphics::UI::QuitButton::QuitButton().
|
noexcept |
|
overridevirtualnoexcept |
Returns a string representation of the object.
Reimplemented from Graphics::Renderable.
Reimplemented in Graphics::UI::TextArea, Graphics::UI::TextField, and Graphics::UI::Area.
References Graphics::Renderable::to_string().
Referenced by generated::getElementModule(), log(), and Graphics::UI::Area::to_string().