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

#include <staticimg.hpp>

Inheritance diagram for gui::widget::StaticImg:
gui::widget::Widget

Public Types

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

Public Member Functions

 StaticImg (glm::vec2 origin, gui::img::Img img, float size=1.0f)
 
 StaticImg (gui::img::Img img)
 
 ~StaticImg ()
 
void changeImage (gui::img::Img img)
 
void render () override
 ====================================================================================== More...
 
- 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 StaticImg unique ptr widget More...
 

Data Fields

float size_width
 
float size_height
 

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...
 

Detailed Description

Widget to display a static image (png) to the screen.

BUG: This doesn't work at all currently! ASDAJSHHASHDAHHHHHHH!

Reference: The chapter on sprite rendering from https://learnopengl.com/book/book_pdf.pdf

Member Typedef Documentation

◆ Ptr

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

Constructor & Destructor Documentation

◆ StaticImg() [1/2]

gui::widget::StaticImg::StaticImg ( glm::vec2  origin,
gui::img::Img  img,
float  size = 1.0f 
)

◆ StaticImg() [2/2]

gui::widget::StaticImg::StaticImg ( gui::img::Img  img)
explicit

◆ ~StaticImg()

gui::widget::StaticImg::~StaticImg ( )

Member Function Documentation

◆ changeImage()

void gui::widget::StaticImg::changeImage ( gui::img::Img  img)

◆ make()

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

creates a StaticImg unique ptr widget

Parameters
origin(Optional) bottom left coordinate of the widget in GUI Coordinates
imgId for the image to render
Returns
A StaticImg widget

◆ render()

void gui::widget::StaticImg::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::StaticImg::shader = nullptr
static

◆ size_height

float gui::widget::StaticImg::size_height

◆ size_width

float gui::widget::StaticImg::size_width

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