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

The Window is the root element, which initializes Aether and contains all of the screens/elements to render. It also handles received events and passes them down the tree. More...

#include <Window.hpp>

Public Types

enum  ScreenOperation { ScreenOperation::Push, ScreenOperation::Pop, ScreenOperation::Set }
 Types of operations to perform on the screen stack. More...
 

Public Member Functions

 Window (const std::string &name, const unsigned int width, const unsigned int height, const LogHandler &log)
 Initializes an Aether instance. There should only ever be one Window instantiated at once (ideally once for the entire program). More...
 
void showDebugInfo (const bool show)
 Set whether debugging information is shown. More...
 
void setFadeIn (const bool fade)
 Enable a fade in animation. More...
 
void setFadeOut (const bool fade)
 Enable a fade out animation. More...
 
void setBackgroundColour (const Colour &col)
 Set the colour used to clear the screen between frames. The alpha channel is ignored. More...
 
bool setBackgroundImage (const std::string &path)
 Set an image to use as the background. Pass an empty string to remove. More...
 
void setFont (const std::string &path)
 Set a custom font to use for text rendering. Pass an empty string to revert back to internal fonts. More...
 
void setFontSpacing (const double spacing)
 Set the spacing between wrapped lines of text. More...
 
void setHighlightAnimation (const std::function< Colour(const uint32_t)> &func)
 Set the function used to animate the highlight border. More...
 
void setHighlightBackground (const Colour &col)
 Set the background colour used for highlighting an element. More...
 
void setHighlightOverlay (const Colour &col)
 Set the colour used to highlight an element when selected. More...
 
int holdDelay ()
 Returns the current value for 'hold delay' (see setHoldDelay()). More...
 
void setHoldDelay (const int ms)
 Set the time to wait before firing duplicate button events due to a button being held down. More...
 
void addOverlay (Overlay *ovl)
 Add the given overlay to the window, placing it on top of existing ones. More...
 
void pushScreen ()
 Push the current screen onto the stack at the next loop. More...
 
void popScreen ()
 Pop a screen from the stack at the next loop. More...
 
void removeScreen ()
 Remove the screen set with showScreen() immediately from the window. This does not wait until the next loop, unlike other screen manipulation methods.
 
void showScreen (Screen *screen)
 Set the screen to show (takes effect at next loop). Ths does not alter the screen stack in anyway; it simply replaces the current screen. More...
 
bool loop ()
 Handles rendering the current screen and events. This should be called until it returns false. More...
 
void exit ()
 Stop the main loop().
 
 ~Window ()
 Cleans up Aether.
 

Detailed Description

The Window is the root element, which initializes Aether and contains all of the screens/elements to render. It also handles received events and passes them down the tree.

Note
Any added screens are not deleted, it is up to you to do so before deleting the Window object.

Member Enumeration Documentation

◆ ScreenOperation

Types of operations to perform on the screen stack.

Enumerator
Push 

Push screen on the stack

Pop 

Pop a screen from the stack

Set 

Set the screen as active

Constructor & Destructor Documentation

◆ Window()

Aether::Window::Window ( const std::string &  name,
const unsigned int  width,
const unsigned int  height,
const LogHandler &  log 
)

Initializes an Aether instance. There should only ever be one Window instantiated at once (ideally once for the entire program).

Note
The construction parameters are ignored on some platforms.
Parameters
nameName to give window (optional)
widthWidth of window (optional)
heightHeight of window (optional)
logHandler to log messages (optional)

Member Function Documentation

◆ addOverlay()

void Aether::Window::addOverlay ( Overlay ovl)

Add the given overlay to the window, placing it on top of existing ones.

Note
Overlays aren't deleted when closed, that is your responsibility.
Parameters
ovlOverlay to show

◆ holdDelay()

int Aether::Window::holdDelay ( )

Returns the current value for 'hold delay' (see setHoldDelay()).

Returns
Milliseconds waited between firing duplicate button events

◆ loop()

bool Aether::Window::loop ( )

Handles rendering the current screen and events. This should be called until it returns false.

Returns
Whether Aether is 'running' (i.e. there is a screen to show and exit() hasn't been called).

◆ popScreen()

void Aether::Window::popScreen ( )

Pop a screen from the stack at the next loop.

Note
The popped screen is not 'loaded' (i.e. onLoad() is not called)

◆ pushScreen()

void Aether::Window::pushScreen ( )

Push the current screen onto the stack at the next loop.

Note
The pushed screen is not 'unloaded' (i.e. onUnload() is not called)

◆ setBackgroundColour()

void Aether::Window::setBackgroundColour ( const Colour col)

Set the colour used to clear the screen between frames. The alpha channel is ignored.

Parameters
colColour to fill screen with

◆ setBackgroundImage()

bool Aether::Window::setBackgroundImage ( const std::string &  path)

Set an image to use as the background. Pass an empty string to remove.

Note
An image always overrides the background colour.
Parameters
pathPath to an image file.
Returns
Whether successful or not.

◆ setFadeIn()

void Aether::Window::setFadeIn ( const bool  fade)

Enable a fade in animation.

Parameters
fadeWhether to show the fade animation on window load

◆ setFadeOut()

void Aether::Window::setFadeOut ( const bool  fade)

Enable a fade out animation.

Parameters
fadeWhether to show the fade animation on window exit

◆ setFont()

void Aether::Window::setFont ( const std::string &  path)

Set a custom font to use for text rendering. Pass an empty string to revert back to internal fonts.

Parameters
pathPath to a .ttf file

◆ setFontSpacing()

void Aether::Window::setFontSpacing ( const double  spacing)

Set the spacing between wrapped lines of text.

Parameters
spacingHeight of one line in terms of font size (1.1 by default).

◆ setHighlightAnimation()

void Aether::Window::setHighlightAnimation ( const std::function< Colour(const uint32_t)> &  func)

Set the function used to animate the highlight border.

Parameters
funcFunction which returns a colour given the runtime (in ms).

◆ setHighlightBackground()

void Aether::Window::setHighlightBackground ( const Colour col)

Set the background colour used for highlighting an element.

Parameters
colBackground highlight colour

◆ setHighlightOverlay()

void Aether::Window::setHighlightOverlay ( const Colour col)

Set the colour used to highlight an element when selected.

Parameters
colHighlight colour

◆ setHoldDelay()

void Aether::Window::setHoldDelay ( const int  ms)

Set the time to wait before firing duplicate button events due to a button being held down.

Parameters
msEvent interval (in ms)

◆ showDebugInfo()

void Aether::Window::showDebugInfo ( const bool  show)

Set whether debugging information is shown.

Parameters
showWhether to show info on screen.

◆ showScreen()

void Aether::Window::showScreen ( Screen screen)

Set the screen to show (takes effect at next loop). Ths does not alter the screen stack in anyway; it simply replaces the current screen.

Parameters
screenScreen to show

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