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

Class for wrappable text. More...

#include <wrappable_text.h>

Inheritance diagram for Graphics::UI::WrappableText:
Graphics::UI::Text Component Events::Subject Events::Observer

Public Types

enum  HorizontalAlignment : unsigned int { LEFT, HCENTER, RIGHT }
 Horizontal Alignment Enum. More...
 
enum  VerticalAlignment : unsigned int { TOP, VCENTER, BOTTOM }
 Vertical Alignment Enum. More...
 

Public Member Functions

 WrappableText ()
 Wrappable Text constructor. More...
 
void setSize (float width, float height)
 Sets the size. More...
 
void setLineSpacing (float spacing)
 Sets the line spacing. More...
 
void setHorizontalAlignment (const HorizontalAlignment &alignment)
 Sets the horizontal alignment. More...
 
void setVerticalAlignment (const VerticalAlignment &alignment)
 Sets the vertical alignment. More...
 
virtual void setText (const std::string &text) override
 Sets the text string. 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...
 
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 void log (el::base::type::ostream_t &os) const
 
- Public Member Functions inherited from Graphics::UI::Text
 Text ()
 Constructor for Text. More...
 
void setFont (const std::shared_ptr< Font > font)
 Sets the font. More...
 
std::string getText () const noexcept
 Gets the text string. More...
 
void setColor (const glm::vec4 &color)
 Sets the color. More...
 
glm::vec4 getColor () const noexcept
 Gets the color. More...
 
void setShader (std::shared_ptr< Shader > shader)
 Sets the shader. More...
 
void setKerning (const float amount) noexcept
 Sets the kerning. More...
 
float getKerning () const noexcept
 Gets the kerning. More...
 
virtual unsigned long long getValueForSorting () const noexceptoverride
 Gets the value for sorting. 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...
 

Protected Member Functions

std::vector< std::pair< float,
std::vector< Character > > > 
splitTextIntoLines ()
 
- Protected Member Functions inherited from Graphics::UI::Text
void renderCharacter (const unsigned char character, Transform transform)
 
- Protected Member Functions inherited from Events::Observer
std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 

Additional Inherited Members

- Protected Attributes inherited from Graphics::UI::Text
std::shared_ptr< Fontfont
 
std::string text
 
glm::vec4 color
 
std::shared_ptr< Shadershader
 
float kerning
 
- 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 wrappable text.

Member Enumeration Documentation

Horizontal Alignment Enum.

Enumerator
LEFT 
HCENTER 
RIGHT 

Vertical Alignment Enum.

Enumerator
TOP 
VCENTER 
BOTTOM 

Constructor & Destructor Documentation

Graphics::UI::WrappableText::WrappableText ( )

Wrappable Text constructor.

Member Function Documentation

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

Returns a string representing the class name.

Returns
The class name

Reimplemented from Graphics::UI::Text.

Referenced by generated::getWrappableTextModule().

void Graphics::UI::WrappableText::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::Text.

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

Reimplemented from Graphics::UI::Text.

References to_string().

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

Called when the engine is shutting down.

Reimplemented from Graphics::UI::Text.

void Graphics::UI::WrappableText::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::Text.

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

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

Reimplemented from Graphics::UI::Text.

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

Called every engine loop.

Parameters
[in]deltaThe delta
Returns
true if active

Reimplemented from Graphics::UI::Text.

References Graphics::UI::Text::color, Component::isActive(), Graphics::UI::Text::renderCharacter(), Graphics::Uniform::setData(), Graphics::UI::Text::shader, and Component::transform.

void Graphics::UI::WrappableText::setHorizontalAlignment ( const HorizontalAlignment alignment)

Sets the horizontal alignment.

Parameters
[in]alignmentThe alignment

Referenced by generated::getWrappableTextModule().

void Graphics::UI::WrappableText::setLineSpacing ( float  spacing)

Sets the line spacing.

Parameters
[in]spacingThe spacing

Referenced by generated::getWrappableTextModule().

void Graphics::UI::WrappableText::setSize ( float  width,
float  height 
)

Sets the size.

Parameters
[in]widthThe width
[in]heightThe height

Referenced by generated::getWrappableTextModule().

void Graphics::UI::WrappableText::setText ( const std::string &  text)
overridevirtual
void Graphics::UI::WrappableText::setVerticalAlignment ( const VerticalAlignment alignment)

Sets the vertical alignment.

Parameters
[in]alignmentThe alignment

Referenced by generated::getWrappableTextModule().

std::vector< std::pair< float, std::vector< Character > > > Graphics::UI::WrappableText::splitTextIntoLines ( )
protected
std::string Graphics::UI::WrappableText::to_string ( ) const
overridevirtualnoexcept

Returns a string representation of the object.

Returns
String representation of the object.

Reimplemented from Graphics::UI::Text.

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

Referenced by generated::getWrappableTextModule(), and log().


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