Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
gui::widget::DynText Class Reference

#include <dyntext.hpp>

Inheritance diagram for gui::widget::DynText:
gui::widget::Widget

Data Structures

struct  Options
 

Public Types

using Ptr = std::unique_ptr< DynText >
 
- Public Types inherited from gui::widget::Widget
using Ptr = std::unique_ptr< Widget >
 

Public Member Functions

 DynText (glm::vec2 origin, const std::string &text, std::shared_ptr< gui::font::Loader > loader, Options options)
 
 DynText (const std::string &text, std::shared_ptr< gui::font::Loader > loader, Options options)
 
void render () override
 ====================================================================================== More...
 
void changeColor (font::Color new_color)
 
void changeText (const std::string &new_text)
 
- Public Member Functions inherited from gui::widget::Widget
 Widget (Type type, glm::vec2 origin)
 Sets the type and origin position of the widget, and assigns a new unique handle. More...
 
virtual ~Widget ()=default
 
void setOrigin (glm::vec2 origin)
 Overrides the current origin position with the newly specified one. More...
 
virtual void lock ()
 Function that is run after all of the widgets have been added to the screee but before any input handling has occurred. More...
 
CallbackHandle addOnClick (Callback callback)
 ====================================================================================== More...
 
CallbackHandle addOnHover (Callback callback)
 Register a new onHover callback function for this widget. More...
 
void removeOnClick (CallbackHandle handle)
 Removes the onClick callback function associated with the given handle. More...
 
void removeOnHover (CallbackHandle handle)
 Removes the onHover callback function associated with the given handle. More...
 
virtual void doClick (float x, float y)
 Performs a click at the specified (x,y) position in the GUI coordinate frame. More...
 
virtual void doHover (float x, float y)
 Performs a hover action at the specified (x,y) position in the GUI coordinate frame. More...
 
virtual void render ()=0
 ====================================================================================== More...
 
Type getType () const
 ====================================================================================== More...
 
const glm::vec2 & getOrigin () const
 Queries the origin position of the widget. More...
 
std::pair< std::size_t, std::size_t > getSize () const
 Queries the size of the widget in pixels. More...
 
Handle getHandle () const
 Queries the handle for this specific widget. More...
 
virtual bool hasHandle (Handle handle) const
 ====================================================================================== More...
 
virtual Widgetborrow (Handle handle)
 Gives a pointer to the subwidget specified by the handle. More...
 

Static Public Member Functions

template<typename... Params>
static Ptr make (Params &&... params)
 creates a DynText unique ptr widget More...
 

Static Public Attributes

static std::unique_ptr< Shadershader = nullptr
 

Additional Inherited Members

- Protected Attributes inherited from gui::widget::Widget
Handle handle
 ====================================================================================== More...
 
Type type
 Type of the widget. More...
 
glm::vec2 origin
 Origin position (bottom left) of the widget in GUI coordinates. More...
 
std::size_t width {0}
 Width of the widget, in pixels. More...
 
std::size_t height {0}
 Height of the widget, in pixels. More...
 
std::unordered_map< CallbackHandle, Callbackon_clicks
 all of the onClick handlers, indexable by handle More...
 
std::unordered_map< CallbackHandle, Callbackon_hovers
 all of the onHover handlers, indexable by handle More...
 
- Static Protected Attributes inherited from gui::widget::Widget
static std::size_t num_widgets = 0
 Static counter for the number of widgets that have been created, so a new identifier can be assigned to each widget as they are created. More...
 

Member Typedef Documentation

◆ Ptr

using gui::widget::DynText::Ptr = std::unique_ptr<DynText>

Constructor & Destructor Documentation

◆ DynText() [1/2]

gui::widget::DynText::DynText ( glm::vec2  origin,
const std::string &  text,
std::shared_ptr< gui::font::Loader loader,
DynText::Options  options 
)

◆ DynText() [2/2]

gui::widget::DynText::DynText ( const std::string &  text,
std::shared_ptr< gui::font::Loader loader,
DynText::Options  options 
)

Member Function Documentation

◆ changeColor()

void gui::widget::DynText::changeColor ( font::Color  new_color)

◆ changeText()

void gui::widget::DynText::changeText ( const std::string &  new_text)

◆ make()

template<typename... Params>
static Ptr gui::widget::DynText::make ( Params &&...  params)
inlinestatic

creates a DynText unique ptr widget

Parameters
origin(Optional) Bottom left coordinate position of the widget in GUI coordinates
textText to render
loadFont loader
options(Optional) Options to customize how the text is rendered
Returns
a DynText widget

◆ render()

void gui::widget::DynText::render ( )
overridevirtual

======================================================================================

=<DISPLAY>============================================================================

Renders the widget to the screen

This is the only function that must be overridden by derived classes.

Implements gui::widget::Widget.

Field Documentation

◆ shader

std::unique_ptr< Shader > gui::widget::DynText::shader = nullptr
static

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