Aether
SDL2 based UI Framework for NX
|
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. | |
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.
|
strong |
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).
name | Name to give window (optional) |
width | Width of window (optional) |
height | Height of window (optional) |
log | Handler to log messages (optional) |
void Aether::Window::addOverlay | ( | Overlay * | ovl | ) |
Add the given overlay to the window, placing it on top of existing ones.
ovl | Overlay to show |
int Aether::Window::holdDelay | ( | ) |
Returns the current value for 'hold delay' (see setHoldDelay()).
bool Aether::Window::loop | ( | ) |
void Aether::Window::popScreen | ( | ) |
Pop a screen from the stack at the next loop.
void Aether::Window::pushScreen | ( | ) |
Push the current screen onto the stack at the next loop.
void Aether::Window::setBackgroundColour | ( | const Colour & | col | ) |
Set the colour used to clear the screen between frames. The alpha channel is ignored.
col | Colour to fill screen with |
bool Aether::Window::setBackgroundImage | ( | const std::string & | path | ) |
Set an image to use as the background. Pass an empty string to remove.
path | Path to an image file. |
void Aether::Window::setFadeIn | ( | const bool | fade | ) |
Enable a fade in animation.
fade | Whether to show the fade animation on window load |
void Aether::Window::setFadeOut | ( | const bool | fade | ) |
Enable a fade out animation.
fade | Whether to show the fade animation on window exit |
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.
path | Path to a .ttf file |
void Aether::Window::setFontSpacing | ( | const double | spacing | ) |
Set the spacing between wrapped lines of text.
spacing | Height of one line in terms of font size (1.1 by default). |
void Aether::Window::setHighlightAnimation | ( | const std::function< Colour(const uint32_t)> & | func | ) |
Set the function used to animate the highlight border.
func | Function which returns a colour given the runtime (in ms). |
void Aether::Window::setHighlightBackground | ( | const Colour & | col | ) |
Set the background colour used for highlighting an element.
col | Background highlight colour |
void Aether::Window::setHighlightOverlay | ( | const Colour & | col | ) |
Set the colour used to highlight an element when selected.
col | Highlight colour |
void Aether::Window::setHoldDelay | ( | const int | ms | ) |
Set the time to wait before firing duplicate button events due to a button being held down.
ms | Event interval (in ms) |
void Aether::Window::showDebugInfo | ( | const bool | show | ) |
Set whether debugging information is shown.
show | Whether to show info on screen. |
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.
screen | Screen to show |