Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Graphics::UI::TextArea Class Reference

Class for text area. More...

#include <text_area.h>

Inheritance diagram for Graphics::UI::TextArea:
Graphics::UI::Area Graphics::UI::Element Graphics::Renderable Component Events::Subject Events::Observer Graphics::UI::Button Graphics::UI::TextField Graphics::UI::QuitButton

Public Member Functions

 TextArea (std::shared_ptr< WrappableText > text, VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer)
 TextArea constructor. More...
 
void setText (std::shared_ptr< WrappableText > text)
 Sets the text. More...
 
std::shared_ptr< WrappableTextgetText () const noexcept
 Gets the text. More...
 
virtual void onLeftClick () override
 Called when element is left clicked. More...
 
virtual void onRightClick () override
 Called when element is right clicked. More...
 
virtual void onLeftClickRelease () override
 Called when element has left click released over it. More...
 
virtual void onRightClickRelease () override
 Called when element has right click released over it. More...
 
virtual void onCursorEnter () override
 Called when the mosue cursor goes over the element. More...
 
virtual void onCursorLeave () override
 Called when the mouse cursor goes off the element. More...
 
virtual void onKeyDown (const int key) override
 Called when a key is pressed while element is in focus. More...
 
virtual void onKeyUp (const int key) override
 Called when a key is released while element is in focus. More...
 
virtual void onKeyRepeat (const int key) override
 Called when a key is repeated while element is in focus. More...
 
virtual void onScroll (const glm::dvec2 position_change) override
 Called when the mouse wheel is scrolled while element is in focus. 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...
 
virtual std::string to_string () const noexceptoverride
 Returns a string representation of the object. More...
 
virtual std::string className () const noexceptoverride
 Returns a string representing the class name. 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 void log (el::base::type::ostream_t &os) const
 
- Public Member Functions inherited from Graphics::UI::Area
 Area (VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer)
 Area constructor. More...
 
- Public Member Functions inherited from Graphics::UI::Element
 Element (VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer)
 Element constructor. More...
 
virtual ~Element ()
 Destroys element. More...
 
std::shared_ptr< SkingetSkin () 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...
 
bool isPointWithin (glm::vec2 point) noexcept
 Determines if point is within element. More...
 
virtual unsigned long long getValueForSorting () const noexceptoverride
 Gets the value for sorting. More...
 
- 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)
 
Renderableoperator= (Renderable &&renderable)
 
virtual ~Renderable ()
 
void setShader (std::shared_ptr< Shader > shader_object) noexcept
 Sets the shader. More...
 
std::shared_ptr< ShadergetShader () 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< TransformgetTransform () 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 Public Member Functions

static std::shared_ptr< TextAreacreate (std::shared_ptr< Skin > skin, std::shared_ptr< WrappableText > text, glm::vec4 color, glm::vec4 text_color, float padding, float screen_width, float screen_height, float x_pos, float y_pos, float width, float height, const unsigned int layer)
 TextArea factory function. More...
 
- Static Public Member Functions inherited from Graphics::UI::Area
static std::shared_ptr< Areacreate (std::shared_ptr< Skin > skin, glm::vec4 color, float screen_width, float screen_height, float x_pos, float y_pos, float width, float height, const unsigned int layer)
 Area factory function. More...
 
- Static Public Member Functions inherited from Graphics::Renderable
static std::shared_ptr
< Renderable
create (const VertexData &vertex_data)
 Renderable factory function. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Graphics::Renderable
void setUniform (const Uniform &uniform) noexcept
 
 Renderable ()
 
- Protected Member Functions inherited from Events::Observer
std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 
- Static Protected Member Functions inherited from Graphics::UI::Element
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
 
- Protected Attributes inherited from Graphics::Renderable
std::set< Uniformuniforms
 
- Protected Attributes inherited from Component
std::weak_ptr< Entityentity
 
std::shared_ptr< Transformtransform
 
bool active
 
unsigned int id
 
- Static Protected Attributes inherited from Component
static unsigned int next_id = 0
 

Detailed Description

Class for text area.

Constructor & Destructor Documentation

Graphics::UI::TextArea::TextArea ( std::shared_ptr< WrappableText text,
VertexData  vertex_data,
std::shared_ptr< Skin skin,
const unsigned int  layer 
)

TextArea constructor.

Parameters
[in]textThe text
[in]vertex_dataThe vertex data
[in]skinThe skin

References Component::getTransform().

Member Function Documentation

std::string Graphics::UI::TextArea::className ( ) const
overridevirtualnoexcept

Returns a string representing the class name.

Returns
The class name

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::QuitButton.

Referenced by generated::getTextAreaModule().

std::shared_ptr< TextArea > Graphics::UI::TextArea::create ( std::shared_ptr< Skin skin,
std::shared_ptr< WrappableText text,
glm::vec4  color,
glm::vec4  text_color,
float  padding,
float  screen_width,
float  screen_height,
float  x_pos,
float  y_pos,
float  width,
float  height,
const unsigned int  layer 
)
static

TextArea factory function.

Parameters
[in]skinThe skin
[in]textThe text
[in]colorThe color
[in]text_colorThe text color
[in]paddingThe padding
[in]screen_widthThe screen width
[in]screen_heightThe screen height
[in]x_posThe x position
[in]y_posThe y position
[in]widthThe width
[in]heightThe height
Returns
A newly created TextArea

References Graphics::UI::Element::basisTexCoords(), and Graphics::UI::Element::generateRect().

Referenced by generated::getTextAreaModule().

std::shared_ptr< WrappableText > Graphics::UI::TextArea::getText ( ) const
noexcept

Gets the text.

Returns
The text.

Referenced by generated::getTextAreaModule(), handleQueuedEvent(), and onStart().

void Graphics::UI::TextArea::handleQueuedEvent ( std::shared_ptr< Events::Event event)
overridevirtual

HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received.

Parameters
[in]eventThe event

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField.

References Events::CHANGE_TEXT, getText(), and Graphics::UI::Area::handleQueuedEvent().

Referenced by Graphics::UI::Button::handleQueuedEvent(), Graphics::UI::TextField::handleQueuedEvent(), and onNotifyNow().

void Graphics::UI::TextArea::log ( el::base::type::ostream_t &  os) const
virtual

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

References to_string().

Referenced by Graphics::UI::Button::log().

void Graphics::UI::TextArea::onCursorEnter ( )
overridevirtual

Called when the mosue cursor goes over the element.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onCursorLeave ( )
overridevirtual

Called when the mouse cursor goes off the element.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onDestroy ( )
overridevirtual

Called when the engine is shutting down.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField.

References Graphics::UI::Area::onDestroy().

Referenced by generated::getTextAreaModule(), and Graphics::UI::TextField::onDestroy().

void Graphics::UI::TextArea::onKeyDown ( const int  key)
overridevirtual

Called when a key is pressed while element is in focus.

Parameters
[in]keyThe key

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onKeyRepeat ( const int  key)
overridevirtual

Called when a key is repeated while element is in focus.

Parameters
[in]keyThe key

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onKeyUp ( const int  key)
overridevirtual

Called when a key is released while element is in focus.

Parameters
[in]keyThe key

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onLeftClick ( )
overridevirtual

Called when element is left clicked.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, Graphics::UI::Button, and Graphics::UI::QuitButton.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onLeftClickRelease ( )
overridevirtual

Called when element has left click released over it.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onNotifyNow ( std::shared_ptr< Events::Event event)
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.

Parameters
[in]eventThe event

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField.

References handleQueuedEvent().

void Graphics::UI::TextArea::onRightClick ( )
overridevirtual

Called when element is right clicked.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onRightClickRelease ( )
overridevirtual

Called when element has right click released over it.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onScroll ( const glm::dvec2  position_change)
overridevirtual

Called when the mouse wheel is scrolled while element is in focus.

Parameters
[in]position_changeThe position change

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField, and Graphics::UI::Button.

Referenced by generated::getTextAreaModule().

void Graphics::UI::TextArea::onStart ( )
overridevirtual

Called when the engine starts and when a new scene is loaded.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField.

References Graphics::UI::Element::getAnchorPoint(), getText(), and Graphics::UI::Area::onStart().

Referenced by generated::getTextAreaModule(), and Graphics::UI::TextField::onStart().

bool Graphics::UI::TextArea::onUpdate ( const double  delta)
overridevirtual

Called every engine loop.

Parameters
[in]deltaThe delta
Returns
true if active

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField.

References Graphics::UI::Area::onUpdate().

Referenced by generated::getTextAreaModule(), and Graphics::UI::TextField::onUpdate().

void Graphics::UI::TextArea::setText ( std::shared_ptr< WrappableText text)
std::string Graphics::UI::TextArea::to_string ( ) const
overridevirtualnoexcept

Returns a string representation of the object.

Returns
String representation of the object.

Reimplemented from Graphics::UI::Area.

Reimplemented in Graphics::UI::TextField.

References Graphics::UI::Area::to_string().

Referenced by generated::getTextAreaModule(), log(), and Graphics::UI::TextField::to_string().


The documentation for this class was generated from the following files: