Aether
SDL2 based UI Framework for NX
Public Member Functions | List of all members
Aether::MessageBox Class Reference

A "MessageBox" is a box presented in the middle of the screen, usually containing a few yes/no/cancel buttons and some text. Buttons are set up using the provided functions whereas the "body" of the box is set by giving an element containing the desired elements. More...

#include <MessageBox.hpp>

Inheritance diagram for Aether::MessageBox:
Aether::Overlay Aether::Screen Aether::Container Aether::Element

Public Member Functions

 MessageBox ()
 Construct a new Message Box object.
 
void setLineColour (Colour c)
 Set the line colour. More...
 
void setRectangleColour (Colour c)
 Set the rectangle colour. More...
 
void setTextColour (Colour c)
 Set the text colour object. More...
 
void addLeftButton (std::string s, std::function< void()> f)
 Add button to bottom left rectangle. More...
 
void addRightButton (std::string s, std::function< void()> f)
 Add button to bottom right rectangle. More...
 
void addTopButton (std::string s, std::function< void()> f)
 Add button to top rectangle. More...
 
void getBodySize (int *w, int *h)
 Get the body size. More...
 
void setBodySize (int w, int h)
 Set the body size. More...
 
void emptyBody ()
 Deletes the element (and it's children!) used as body.
 
void setBody (Element *e)
 Set the body element Does nothing if a body has been set alreadu! More...
 
- Public Member Functions inherited from Aether::Overlay
 Overlay ()
 Construct a new Overlay object.
 
void close ()
 Mark overlay to be closed.
 
void reuse ()
 Mark overlay to be able to used (readded) again. More...
 
bool shouldClose ()
 Check if overlay is marked to be closed. More...
 
void render ()
 Draws background then renders overlay.
 
- Public Member Functions inherited from Aether::Screen
 Screen ()
 Constructs a new (empty) Screen object.
 
virtual void onLoad ()
 Invoked once when the screen is requested to be 'shown'. This method should set up all child elements.
 
virtual void onUnload ()
 Invoked once when the screen has been replaced by another screen. This method should tidy up all child elements.
 
void onButtonPress (Button btn, std::function< void()> func)
 Assigns a function to invoke when a button is pressed. More...
 
void onButtonRelease (Button btn, std::function< void()> func)
 Assigns a function to invoke when a button is released. More...
 
bool handleEvent (InputEvent *event)
 Attempts to handle the event if it is a button press/release. More...
 
- Public Member Functions inherited from Aether::Container
 Container (int x=0, int y=0, int w=100, int h=100)
 Construct a new Container object. More...
 
void setActive ()
 Re-highlight/focus the focused element.
 
void setInactive ()
 Removes focus from the focused element.
 
void addElement (Element *e)
 Adds new element a child. More...
 
bool removeElement (Element *e)
 Attempt to delete given child element. More...
 
void removeAllElements ()
 Deletes all children elements.
 
bool returnElement (Element *e)
 Attempt to remove the given child element. More...
 
void returnAllElements ()
 Removes (but does not delete) all children elements.
 
- Public Member Functions inherited from Aether::Element
 Element (int x=0, int y=0, int w=100, int h=100)
 Construct a new Element object. More...
 
int x ()
 Returns x-coordinate of element. More...
 
int y ()
 Returns y-coordinate of element. More...
 
int w ()
 Returns width of element. More...
 
int h ()
 Returns height of element. More...
 
virtual void setX (int x)
 Set x-coordinate of element. More...
 
virtual void setY (int y)
 Set y-coordinate of element. More...
 
virtual void setW (int w)
 Set width of element. More...
 
virtual void setH (int h)
 Set height of element. More...
 
virtual void setXY (int x, int y)
 Set co-ordinates of element. More...
 
virtual void setWH (int w, int h)
 Set size of element. More...
 
virtual void setXYWH (int x, int y, int w, int h)
 Setter size and co-ordinates of element. More...
 
Elementparent ()
 Returns the parent element of this element. More...
 
void setParent (Element *p)
 Set the parent element of this element. More...
 
bool isVisible ()
 Check if current element is visible on-screen. More...
 
bool hidden ()
 Check if current element is hidden. More...
 
void setHidden (bool b)
 Set whether element is hidden or not. More...
 
bool selected ()
 Check if current element is selected. More...
 
virtual void setSelected (bool b)
 Set whether element is selected or not. More...
 
bool selectable ()
 Check if current element is selectable. More...
 
void setSelectable (bool b)
 Set whether element is selectable or not. More...
 
bool touchable ()
 Check if current element is touch responsive. More...
 
void setTouchable (bool b)
 Set whether element is touch responsive or not. More...
 
bool highlighted ()
 Check if current element is highlighted. More...
 
void setHighlighted (bool b)
 Set whether element is highlighted or not. More...
 
bool hasHighlighted ()
 Check if current element has highlighted children element. More...
 
void setHasHighlighted (bool b)
 Set whether element has highlighted children element or not. More...
 
bool hasSelectable ()
 Check if current element has selectable children element. More...
 
void setHasSelectable (bool b)
 Set whether element has selectable children element or not. More...
 
bool hasSelected ()
 Check if current element has selected children element. More...
 
void setHasSelected (bool b)
 Set whether element has selected children element or not. More...
 
void setFocused (Element *e)
 Sets current element as unfocused and instead focuses a sub-element. More...
 
void setFocussed (Element *e)
 Sets current element as unfocused and instead focuses a sub-element. More...
 
Elementfocused ()
 Returns the currently focused element. More...
 
Elementfocussed ()
 Returns the currently focused element. More...
 
std::function< void()> onPressFunc ()
 Returns function invoked when the element is pressed. More...
 
void onPress (std::function< void()> f)
 Sets the function to invoked when the element is pressed. More...
 
virtual void update (unsigned int dt)
 Update is passed time since last frame (for animations) More...
 
virtual DrawablerenderHighlightBG ()
 Renders the highlight background. More...
 
virtual DrawablerenderHighlight ()
 Renders the highlight border. More...
 
virtual DrawablerenderSelection ()
 Renders the selection overlay. More...
 
virtual ~Element ()
 Destroy the Element object.
 

Additional Inherited Members

- Protected Member Functions inherited from Aether::Container
void addElementAt (Element *e, size_t i)
 
- Protected Member Functions inherited from Aether::Element
void renderHighlightTextures ()
 Renders cached highlight textures.
 
void renderSelectionTexture ()
 Renders cached selection texture.
 
void addElementAt (Element *e, size_t i)
 Add element at given index in vector. More...
 
- Protected Attributes inherited from Aether::Element
Elementparent_
 Pointer to parent element, if there is one.
 
std::vector< Element * > children
 Vector of child elements (used to call their methods)
 
Elementfocused_
 Children element which is highlighted/focused (to regain focus on activation)
 
- Static Protected Attributes inherited from Aether::Element
static Colour hiBGColour
 Background colour if element is highlighted.
 
static Colour hiBorderColour
 Border colour if element is highlighted.
 
static Colour selColour
 Selected colour if element is highlighted.
 
static unsigned int hiSize
 Size of highlight border.
 
static DrawablehiBGTex
 Highlight background texture.
 
static DrawablehiBorderTex
 Highlight border texture.
 
static DrawableselTex
 Selection texture.
 
static Rendererrenderer
 
static bool isTouch
 Indicator on whether the touch is "active" (i.e. hide highlighting) or not.
 

Detailed Description

A "MessageBox" is a box presented in the middle of the screen, usually containing a few yes/no/cancel buttons and some text. Buttons are set up using the provided functions whereas the "body" of the box is set by giving an element containing the desired elements.

Member Function Documentation

◆ addLeftButton()

void Aether::MessageBox::addLeftButton ( std::string  s,
std::function< void()>  f 
)

Add button to bottom left rectangle.

Note
Don't call these multiple times as the previous ones aren't deleted!
Parameters
sbutton label string
ffunction to invoke when button pressed

◆ addRightButton()

void Aether::MessageBox::addRightButton ( std::string  s,
std::function< void()>  f 
)

Add button to bottom right rectangle.

Note
Don't call these multiple times as the previous ones aren't deleted!
Parameters
sbutton label string
ffunction to invoke when button pressed

◆ addTopButton()

void Aether::MessageBox::addTopButton ( std::string  s,
std::function< void()>  f 
)

Add button to top rectangle.

Note
Don't call these multiple times as the previous ones aren't deleted!
Parameters
sbutton label string
ffunction to invoke when button pressed

◆ getBodySize()

void Aether::MessageBox::getBodySize ( int *  w,
int *  h 
)

Get the body size.

Parameters
wpointer to write body width to
hpointer to write body height to

◆ setBody()

void Aether::MessageBox::setBody ( Element e)

Set the body element Does nothing if a body has been set alreadu!

Parameters
ebody element to set

◆ setBodySize()

void Aether::MessageBox::setBodySize ( int  w,
int  h 
)

Set the body size.

Parameters
wnew body width
hnew body height

◆ setLineColour()

void Aether::MessageBox::setLineColour ( Colour  c)

Set the line colour.

Note
Must be called after adding buttons!
Parameters
cnew line colour

◆ setRectangleColour()

void Aether::MessageBox::setRectangleColour ( Colour  c)

Set the rectangle colour.

Parameters
cnew rectangle colour

◆ setTextColour()

void Aether::MessageBox::setTextColour ( Colour  c)

Set the text colour object.

Parameters
cnew text colour

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