Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
aurore::Application Class Reference

#include <aurore/core/application.hpp>

Static Public Member Functions

static bool init ()
 
static void setAppId (std::string appId)
 
static const std::string & getAppId ()
 The application ID given to setAppId(), "" by default.
 
static void setCadran (bool on)
 
static bool isCadran ()
 Whether the app is drawn in Cadran's look (see setCadran()).
 
static void createWindow (std::string title)
 
static bool mainLoop ()
 
static Platform * getPlatform ()
 The platform the app runs on (window, inputs, video, audio, fonts), made by init().
 
static AudioPlayer * getAudioPlayer ()
 The platform's sound player.
 
static YGConfig * getYogaConfig ()
 
static NVGcontext * getNVGContext ()
 The nanovg context every view draws with.
 
static void onWindowResized (int width, int height)
 
static void setWindowSize (int width, int height)
 
static void onWindowReposition (int xPos, int yPos)
 
static void setWindowPosition (int xPos, int yPos)
 
static std::vector< Activity * > getActivitiesStack ()
 A copy of the stack of activities, the first pushed first.
 
static void pushActivity (Activity *view, TransitionAnimation animation=TransitionAnimation::FADE)
 
static void replaceActivity (Activity *activity, TransitionAnimation animation=TransitionAnimation::FADE)
 
static bool popActivity (TransitionAnimation animation=TransitionAnimation::FADE, std::function< void(void)> cb=[] {}, bool free=true)
 
static void giveFocus (View *view)
 
static void forgetView (View *view)
 
static void setHighlightIdleFade (bool fade)
 
static void setFocusAnnouncer (std::function< void(const std::string &)> announcer)
 
static void announce (const std::string &text)
 
static const std::string & getLastAnnouncement ()
 
static void setReduceMotion (bool reduce)
 
static bool getReduceMotion ()
 
static bool isReduceMotionSet ()
 The app's own setting alone, without Cadran's.
 
static Time getLastInputTime ()
 
static void setTextScale (float scale)
 
static float getTextScale ()
 
static void registerModel (const std::string &name, DataModel *model)
 
static void unregisterModel (const std::string &name)
 
static DataModel * getModel (const std::string &name)
 
static View * getHoveredView ()
 
static Style getStyle ()
 The metrics in use (aurore::getStyle()).
 
static Theme getTheme ()
 The colours of the variant in use (light or dark), with the theme file's over them.
 
static ThemeVariant getThemeVariant ()
 The variant in use, as the platform reports it.
 
static Event< ThemeVariant > * getThemeChangedEvent ()
 
static bool hasThemeBackground ()
 
static void drawThemeBackground (NVGcontext *vg, float x, float y, float width, float height)
 
static void drawThemeBackground (NVGcontext *vg, float x, float y, float width, float height, float radius)
 
static ImeManager * getImeManager ()
 The platform's text input (the keyboard shown for an EditTextDialog).
 
static bool loadFontFromFile (std::string fontName, std::string filePath)
 
static bool loadFontFromMemory (std::string fontName, void *data, size_t size, bool freeData)
 
static bool loadFontFromMemory (std::string fontName, void *data, size_t size, bool freeData, int faceIndex)
 
static int getFont (std::string fontName)
 
static bool addFontFallback (const std::string &font, const std::string &fallback)
 
static int getDefaultFont ()
 The font a new Label draws with: the regular font (the Chinese one on the Switch).
 
static void notify (const std::string &text, View *leading=nullptr)
 
static void onControllerButtonPressed (enum ControllerButton button, bool repeating)
 
static void onKeyboardPressed (AuroreKeyCombination key, bool repeating)
 Handles a key as the main loop does (the actions registered on keys).
 
static void crash (std::string text)
 
static void quit ()
 Asks the main loop to stop: the next mainLoop() returns false, after the exit events.
 
static void clear ()
 Deletes every activity on the stack and clears the focus.
 
static void blockInputs (bool muteSounds=false)
 
static void unblockInputs ()
 
static bool isInputBlocks ()
 Whether blockInputs() is in force.
 
static const ControllerState & getControllerState ()
 The controller's buttons and sticks as read this frame.
 
static void setCommonFooter (std::string footer)
 A text the app keeps for its footers (the library does not draw it).
 
static std::string * getCommonFooter ()
 
static void setMaximumUIScale (float scale)
 
static float getMaximumUIScale ()
 
static void setGlobalQuit (bool enabled)
 
static void setFPSStatus (bool enabled)
 Whether getFPS() is counted (60 when off).
 
static bool getFPSStatus ()
 
static size_t getFPS ()
 The frames per second over the last second.
 
static void setLimitedFPS (size_t fps)
 
static void setSwapInterval (int interval)
 
static void setAutomaticDeactivation (bool value)
 
static bool getAutomaticDeactivation ()
 See setAutomaticDeactivation().
 
static bool hasActiveEvent ()
 
static void setActiveEvent (bool value)
 Marks the app active now (and asks for a redraw), or no longer.
 
static void setDeactivatedTime (int millisecond)
 After this long without an input, the app is drawn at the deactivated FPS.
 
static void setDeactivatedFPS (int value)
 The frame rate once deactivated (5 by default).
 
static int getDeactivatedFPS ()
 
static double getDeactivatedFrameTime ()
 A frame's time once deactivated, in seconds.
 
static void setRedrawOnDemand (bool enabled)
 
static bool isRedrawOnDemand ()
 See setRedrawOnDemand().
 
static void requestRedraw ()
 
static uint64_t getDrawnFrameCount ()
 
static void setRedrawDebug (bool enabled)
 
static bool isRedrawDebug ()
 See setRedrawDebug().
 
static uint64_t getMissedRedrawCount ()
 
static Rect getLastMissedRedrawArea ()
 
static GenericEvent * getGlobalFocusChangeEvent ()
 Fired with the new focus each time the focus moves.
 
static VoidEvent * getGlobalHintsUpdateEvent ()
 Fired when the footer's hints must be read again (the focus moved, keys swapped).
 
static Event< InputType > * getGlobalInputTypeChangeEvent ()
 Fired when the input type changes (a touch after the buttons, or the reverse).
 
static VoidEvent * getRunLoopEvent ()
 Fired once per main loop iteration, after the frame and the sync tasks.
 
static VoidEvent * getPostFrameEvent ()
 Fired after each frame presented.
 
static VoidEvent * getExitEvent ()
 Fired when the app starts to exit, before the activities are deleted.
 
static VoidEvent * getExitDoneEvent ()
 Fired once the activities and the views left are deleted.
 
static VoidEvent * getWindowSizeChangedEvent ()
 Fired when the window's size changed.
 
static VoidEvent * getWindowCreationDoneEvent ()
 Fired at the end of createWindow().
 
static VoidEvent * getWindowShouldCloseEvent ()
 Fired when the window is closed or quit() was asked, before the exit.
 
static Event< bool > * getWindowFocusChangedEvent ()
 Fired with true or false when the window gains or loses the system's focus.
 
static View * getCurrentFocus ()
 The view that has the focus, or nullptr.
 
static std::string getTitle ()
 The window's title, as given to createWindow().
 
static void registerXMLView (std::string name, XMLViewCreator creator)
 
static bool XMLViewsRegisterContains (std::string name)
 Whether an XML tag is registered (registerXMLView()).
 
static std::vector< std::string > getXMLViewNames ()
 The XML tags registered (registerXMLView).
 
static XMLViewCreator getXMLViewCreator (std::string name)
 The function registered for an XML tag.
 
static std::string getLocale ()
 
static void addToFreeQueue (View *view)
 
static InputType getInputType ()
 
static void setInspectorEnabled (bool enabled)
 
static bool isInspectorEnabled ()
 See setInspectorEnabled().
 
static void setHotReload (bool enabled, const std::string &resourcesDir="")
 
static bool isHotReload ()
 See setHotReload().
 
static bool rebuildActivity ()
 
static void enableDebuggingView (bool enable)
 Draws the debug layer (DebugLayer) over the app.
 
static bool isDebuggingViewEnabled ()
 
static void setSwapInputKeys (bool swap)
 Swaps A and B (and X and Y) for the app's actions, as on a Japanese console.
 
static bool isSwapInputKeys ()
 
static void setDrawCoursor (bool draw)
 Draws the mouse pointer with nanovg (for platforms with no system pointer).
 
static bool isDrawCursor ()
 
static bool isHintsLiteMode ()
 See setHintsLiteMode().
 
static void setHintsLiteMode (const bool value)
 Set hints lite mode, which will only show hints for A button and B button.
 
static void tryDeinitFirstResponder (View *view)
 Stops the touch gestures view is tracking, before it is removed.
 
static void addToWatchedKeys (const AuroreKeyCombination key)
 Reads key each frame from now on (counted: one removeWatchedKeys() per add).
 
static void removeWatchedKeys (const AuroreKeyCombination key)
 See addToWatchedKeys().
 
static void mapKey (AuroreKeyCombination key, ControllerButton button)
 
static void unmapKey (AuroreKeyCombination key)
 
static void clearKeyMap ()
 
static const std::vector< std::pair< AuroreKeyCombination, ControllerButton > > & getKeyMap ()
 

Static Public Attributes

static uint32_t ORIGINAL_WINDOW_WIDTH = 1280
 The design width, in layout units.
 
static uint32_t ORIGINAL_WINDOW_HEIGHT = 720
 The design height.
 
static std::string appId = ""
 See setAppId().
 
static float contentWidth
 The size of the UI in layout units: ORIGINAL_WINDOW_WIDTH wide, as high as the window's ratio gives.
 
static float contentHeight
 
static unsigned windowWidth
 The window's size in pixels.
 
static unsigned windowHeight
 
static int windowXPos
 The window's position on the screen (desktop).
 
static int windowYPos
 
static float windowScale
 Pixels per layout unit (windowWidth / ORIGINAL_WINDOW_WIDTH, capped by setMaximumUIScale()).
 
static float maximumUIScale = 0.0f
 See setMaximumUIScale().
 

Friends

class EditTextDialog
 

Detailed Description

The app: its window, its stack of activities, the focus, the inputs and the main loop. Every member is static: there is one app per process, run from the main thread.

Member Function Documentation

◆ addFontFallback()

static bool aurore::Application::addFontFallback ( const std::string &  font,
const std::string &  fallback 
)
static

Glyphs missing from the font loaded as font are looked up in the one loaded as fallback. False when either is not loaded.

◆ addToFreeQueue()

static void aurore::Application::addToFreeQueue ( View *  view)
static

Deletes view at the end of the current main loop iteration (once no ptrLock() holds it). View::freeView() calls it.

◆ addToWatchedKeys()

static void aurore::Application::addToWatchedKeys ( const AuroreKeyCombination  key)
static

Reads key each frame from now on (counted: one removeWatchedKeys() per add).

◆ announce()

static void aurore::Application::announce ( const std::string &  text)
static

Gives text to the focus announcer, outside of a focus move: a value changed in place (View::announceAccessibilityValue), a toast (notify says its text). Nothing for an empty text. getLastAnnouncement() is the last text given, announcer or not (for tests).

◆ blockInputs()

static void aurore::Application::blockInputs ( bool  muteSounds = false)
static

Blocks any and all user inputs

◆ clear()

static void aurore::Application::clear ( )
static

Deletes every activity on the stack and clears the focus.

◆ clearKeyMap()

static void aurore::Application::clearKeyMap ( )
static

The keyboard keys that press a controller button, on top of Enter (A), Escape (B) and the arrows. By default X, Y, L, R, Shift+L (ZL), Shift+R (ZR), P or + (Plus), M or - (Minus) and Backspace (B); keys are named after their place on a US keyboard (docs/input.md). A key a view registers an action for keeps that action only, and none applies while a text is being typed.

◆ crash()

static void aurore::Application::crash ( std::string  text)
static

"Crashes" the app (displays a fullscreen CrashFrame) Shows text in a dialog that cannot be dismissed, with one button that quits the app: for an error the app cannot go on after. Can be called from any thread.

◆ createWindow()

static void aurore::Application::createWindow ( std::string  title)
static

Creates the application window with the given title. Must be called after calling init().

◆ drawThemeBackground() [1/2]

static void aurore::Application::drawThemeBackground ( NVGcontext *  vg,
float  x,
float  y,
float  width,
float  height 
)
static

Draws what is behind the screens over x, y, width, height: the clear colour, the theme's background image and its veil. For a panel drawn over other views in a translucent surface colour (a drawer over a page), so that it hides them and still shows the picture. Nothing without a background image.

◆ drawThemeBackground() [2/2]

static void aurore::Application::drawThemeBackground ( NVGcontext *  vg,
float  x,
float  y,
float  width,
float  height,
float  radius 
)
static

The same in a shape with round corners of radius, and the strips of the theme's decorations (decor.top, decor.bottom) over it: under a translucent dialog or sheet (View::setThemeArea).

◆ enableDebuggingView()

static void aurore::Application::enableDebuggingView ( bool  enable)
inlinestatic

Draws the debug layer (DebugLayer) over the app.

◆ forgetView()

static void aurore::Application::forgetView ( View *  view)
static

Drops every reference the focus system holds to a view that is being destroyed.

◆ getActivitiesStack()

static std::vector< Activity * > aurore::Application::getActivitiesStack ( )
static

A copy of the stack of activities, the first pushed first.

◆ getAppId()

static const std::string & aurore::Application::getAppId ( )
inlinestatic

The application ID given to setAppId(), "" by default.

◆ getAudioPlayer()

static AudioPlayer * aurore::Application::getAudioPlayer ( )
static

The platform's sound player.

◆ getAutomaticDeactivation()

static bool aurore::Application::getAutomaticDeactivation ( )
static

◆ getCommonFooter()

static std::string * aurore::Application::getCommonFooter ( )
static

◆ getControllerState()

static const ControllerState & aurore::Application::getControllerState ( )
static

The controller's buttons and sticks as read this frame.

◆ getCurrentFocus()

static View * aurore::Application::getCurrentFocus ( )
static

The view that has the focus, or nullptr.

◆ getDeactivatedFPS()

static int aurore::Application::getDeactivatedFPS ( )
static

◆ getDeactivatedFrameTime()

static double aurore::Application::getDeactivatedFrameTime ( )
static

A frame's time once deactivated, in seconds.

◆ getDefaultFont()

static int aurore::Application::getDefaultFont ( )
static

The font a new Label draws with: the regular font (the Chinese one on the Switch).

◆ getDrawnFrameCount()

static uint64_t aurore::Application::getDrawnFrameCount ( )
static

Number of frames drawn since the start (frames skipped by redraw on demand are not counted).

◆ getExitDoneEvent()

static VoidEvent * aurore::Application::getExitDoneEvent ( )
static

Fired once the activities and the views left are deleted.

◆ getExitEvent()

static VoidEvent * aurore::Application::getExitEvent ( )
static

Fired when the app starts to exit, before the activities are deleted.

◆ getFont()

static int aurore::Application::getFont ( std::string  fontName)
static

Returns the nanovg handle to the given font name, or FONT_INVALID if no such font is currently loaded.

◆ getFPS()

static size_t aurore::Application::getFPS ( )
static

The frames per second over the last second.

◆ getFPSStatus()

static bool aurore::Application::getFPSStatus ( )
static

◆ getGlobalFocusChangeEvent()

static GenericEvent * aurore::Application::getGlobalFocusChangeEvent ( )
static

Fired with the new focus each time the focus moves.

◆ getGlobalHintsUpdateEvent()

static VoidEvent * aurore::Application::getGlobalHintsUpdateEvent ( )
static

Fired when the footer's hints must be read again (the focus moved, keys swapped).

◆ getGlobalInputTypeChangeEvent()

static Event< InputType > * aurore::Application::getGlobalInputTypeChangeEvent ( )
static

Fired when the input type changes (a touch after the buttons, or the reverse).

◆ getHoveredView()

static View * aurore::Application::getHoveredView ( )
inlinestatic

The view under the mouse pointer that has a hover: style (desktop), or nullptr.

◆ getImeManager()

static ImeManager * aurore::Application::getImeManager ( )
static

The platform's text input (the keyboard shown for an EditTextDialog).

◆ getInputType()

static InputType aurore::Application::getInputType ( )
inlinestatic

Returns the current input type.

◆ getKeyMap()

static const std::vector< std::pair< AuroreKeyCombination, ControllerButton > > & aurore::Application::getKeyMap ( )
static

The keyboard keys that press a controller button, on top of Enter (A), Escape (B) and the arrows. By default X, Y, L, R, Shift+L (ZL), Shift+R (ZR), P or + (Plus), M or - (Minus) and Backspace (B); keys are named after their place on a US keyboard (docs/input.md). A key a view registers an action for keeps that action only, and none applies while a text is being typed.

◆ getLastAnnouncement()

static const std::string & aurore::Application::getLastAnnouncement ( )
inlinestatic

◆ getLastInputTime()

static Time aurore::Application::getLastInputTime ( )
inlinestatic

When the last input came (a button, a key, a touch, the mouse), on the clock of getCPUTimeUsec(): what the theme's particles stop after.

◆ getLastMissedRedrawArea()

static Rect aurore::Application::getLastMissedRedrawArea ( )
static

◆ getLocale()

static std::string aurore::Application::getLocale ( )
static

Returns the current system locale.

◆ getMaximumUIScale()

static float aurore::Application::getMaximumUIScale ( )
static

◆ getMissedRedrawCount()

static uint64_t aurore::Application::getMissedRedrawCount ( )
static

With setRedrawDebug(): the number of skipped frames found different from the last frame presented, and the last such area, in the views' coordinates.

◆ getModel()

static DataModel * aurore::Application::getModel ( const std::string &  name)
static

◆ getNVGContext()

static NVGcontext * aurore::Application::getNVGContext ( )
static

The nanovg context every view draws with.

◆ getPlatform()

static Platform * aurore::Application::getPlatform ( )
static

The platform the app runs on (window, inputs, video, audio, fonts), made by init().

◆ getPostFrameEvent()

static VoidEvent * aurore::Application::getPostFrameEvent ( )
static

Fired after each frame presented.

◆ getReduceMotion()

static bool aurore::Application::getReduceMotion ( )
static

◆ getRunLoopEvent()

static VoidEvent * aurore::Application::getRunLoopEvent ( )
static

Fired once per main loop iteration, after the frame and the sync tasks.

◆ getStyle()

static Style aurore::Application::getStyle ( )
inlinestatic

The metrics in use (aurore::getStyle()).

◆ getTextScale()

static float aurore::Application::getTextScale ( )
static

◆ getTheme()

static Theme aurore::Application::getTheme ( )
static

The colours of the variant in use (light or dark), with the theme file's over them.

◆ getThemeChangedEvent()

static Event< ThemeVariant > * aurore::Application::getThemeChangedEvent ( )
static

Fired when the theme changed: another variant (Platform::setThemeVariant), a theme file (Theme::loadFile, Theme::reset) or a colour changed (Theme::addColor). Checked once a frame, before it is drawn; by then every view of the screens took the change (View::onThemeChanged). For what keeps colours of its own.

◆ getThemeVariant()

static ThemeVariant aurore::Application::getThemeVariant ( )
static

The variant in use, as the platform reports it.

◆ getTitle()

static std::string aurore::Application::getTitle ( )
static

The window's title, as given to createWindow().

◆ getWindowCreationDoneEvent()

static VoidEvent * aurore::Application::getWindowCreationDoneEvent ( )
static

Fired at the end of createWindow().

◆ getWindowFocusChangedEvent()

static Event< bool > * aurore::Application::getWindowFocusChangedEvent ( )
static

Fired with true or false when the window gains or loses the system's focus.

◆ getWindowShouldCloseEvent()

static VoidEvent * aurore::Application::getWindowShouldCloseEvent ( )
static

Fired when the window is closed or quit() was asked, before the exit.

◆ getWindowSizeChangedEvent()

static VoidEvent * aurore::Application::getWindowSizeChangedEvent ( )
static

Fired when the window's size changed.

◆ getXMLViewCreator()

static XMLViewCreator aurore::Application::getXMLViewCreator ( std::string  name)
static

The function registered for an XML tag.

◆ getXMLViewNames()

static std::vector< std::string > aurore::Application::getXMLViewNames ( )
static

The XML tags registered (registerXMLView).

◆ getYogaConfig()

static YGConfig * aurore::Application::getYogaConfig ( )
static

The Yoga configuration every view's node is created with (web defaults, yoga's messages in the log).

◆ giveFocus()

static void aurore::Application::giveFocus ( View *  view)
static

Gives the focus to the given view or clears the focus if given nullptr.

◆ hasActiveEvent()

static bool aurore::Application::hasActiveEvent ( )
static

Whether the app is active: an input lately, an animation under way, or no automatic deactivation. Always true on the Switch.

◆ hasThemeBackground()

static bool aurore::Application::hasThemeBackground ( )
static

Whether the theme in use draws a picture behind the screens in the variant in use (its background_image, loaded).

◆ init()

static bool aurore::Application::init ( )
static

Inits the Aurore application. Returns true if it succeeded, false otherwise.

◆ isCadran()

static bool aurore::Application::isCadran ( )
inlinestatic

Whether the app is drawn in Cadran's look (see setCadran()).

◆ isDebuggingViewEnabled()

static bool aurore::Application::isDebuggingViewEnabled ( )
inlinestatic

◆ isDrawCursor()

static bool aurore::Application::isDrawCursor ( )
inlinestatic

◆ isHintsLiteMode()

static bool aurore::Application::isHintsLiteMode ( )
inlinestatic

◆ isHotReload()

static bool aurore::Application::isHotReload ( )
static

◆ isInputBlocks()

static bool aurore::Application::isInputBlocks ( )
static

Whether blockInputs() is in force.

◆ isInspectorEnabled()

static bool aurore::Application::isInspectorEnabled ( )
static

◆ isRedrawDebug()

static bool aurore::Application::isRedrawDebug ( )
static

◆ isRedrawOnDemand()

static bool aurore::Application::isRedrawOnDemand ( )
static

◆ isReduceMotionSet()

static bool aurore::Application::isReduceMotionSet ( )
inlinestatic

The app's own setting alone, without Cadran's.

◆ isSwapInputKeys()

static bool aurore::Application::isSwapInputKeys ( )
inlinestatic

◆ loadFontFromFile()

static bool aurore::Application::loadFontFromFile ( std::string  fontName,
std::string  filePath 
)
static

Loads a font from a given file and stores it in the font stash. A AURORE_ASSET() path ("@res/...") is read from the resources built into the program when they are (USE_LIBROMFS). Returns true if the operation succeeded.

◆ loadFontFromMemory() [1/2]

static bool aurore::Application::loadFontFromMemory ( std::string  fontName,
void *  data,
size_t  size,
bool  freeData 
)
static

Loads a font from a given memory buffer and stores it in the font stash. Returns true if the operation succeeded.

◆ loadFontFromMemory() [2/2]

static bool aurore::Application::loadFontFromMemory ( std::string  fontName,
void *  data,
size_t  size,
bool  freeData,
int  faceIndex 
)
static

The same, with the face at faceIndex of a font collection (.ttc).

◆ mainLoop()

static bool aurore::Application::mainLoop ( )
static

Application main loop iteration. Must be called in an infinite loop until it returns false.

◆ mapKey()

static void aurore::Application::mapKey ( AuroreKeyCombination  key,
ControllerButton  button 
)
static

The keyboard keys that press a controller button, on top of Enter (A), Escape (B) and the arrows. By default X, Y, L, R, Shift+L (ZL), Shift+R (ZR), P or + (Plus), M or - (Minus) and Backspace (B); keys are named after their place on a US keyboard (docs/input.md). A key a view registers an action for keeps that action only, and none applies while a text is being typed.

◆ notify()

static void aurore::Application::notify ( const std::string &  text,
View *  leading = nullptr 
)
static

Shows a toast with text, and leading (an icon) before it when given; the focus announcer says the text.

◆ onControllerButtonPressed()

static void aurore::Application::onControllerButtonPressed ( enum ControllerButton  button,
bool  repeating 
)
static

Handles a controller button as the main loop does: the focused view's actions first, then the focus moves. For the platforms and the test harness.

◆ onKeyboardPressed()

static void aurore::Application::onKeyboardPressed ( AuroreKeyCombination  key,
bool  repeating 
)
static

Handles a key as the main loop does (the actions registered on keys).

◆ onWindowReposition()

static void aurore::Application::onWindowReposition ( int  xPos,
int  yPos 
)
static

Called by the video context when the content window is Repositioned

◆ onWindowResized()

static void aurore::Application::onWindowResized ( int  width,
int  height 
)
static

Called by the video context when the content window is resized

◆ popActivity()

static bool aurore::Application::popActivity ( TransitionAnimation  animation = TransitionAnimation::FADE,
std::function< void(void)>  cb = [] {},
bool  free = true 
)
static

Pops the last pushed activity from the stack and gives focus back where it was before.

return false if no actifity to pop.

◆ pushActivity()

static void aurore::Application::pushActivity ( Activity *  view,
TransitionAnimation  animation = TransitionAnimation::FADE 
)
static

Pushes a view on this applications's view stack.

The view will automatically be resized to take the whole screen.

The view will gain focus if applicable.

The first activity to be pushed cannot be popped.

◆ quit()

static void aurore::Application::quit ( )
static

Asks the main loop to stop: the next mainLoop() returns false, after the exit events.

◆ rebuildActivity()

static bool aurore::Application::rebuildActivity ( )
static

Builds the content of the activity on top again from its createContentView(), as hot reload does. False when it cannot (an activity given its view in its constructor) or the new content throws while being made (its XML, onContentAvailable(), or a tab shown, made when it takes the focus): the old one then stays, with the focus, and the error is shown in a notification.

◆ registerModel()

static void aurore::Application::registerModel ( const std::string &  name,
DataModel *  model 
)
static

The data models XML bindings read (View::bind, bind="text: name.key"), by name, for every screen. An Activity's own (Activity::registerModel) come first. The model must outlive its registration.

◆ registerXMLView()

static void aurore::Application::registerXMLView ( std::string  name,
XMLViewCreator  creator 
)
static

Registers a view to be created from XML. You must give the name of the XML node as well as a function that creates the view.

If you need attributes, register them with the given functions in the view class constructor directly. They will be called one by one after the view is instantiated.

You should not add any children in the function, it is already taken care of.

◆ removeWatchedKeys()

static void aurore::Application::removeWatchedKeys ( const AuroreKeyCombination  key)
static

◆ replaceActivity()

static void aurore::Application::replaceActivity ( Activity *  activity,
TransitionAnimation  animation = TransitionAnimation::FADE 
)
static

Pushes the activity in place of the one on top, in one transition: the one replaced is not shown again on the way, nor given the focus back later, and is deleted once the new one is shown (a wizard's next step, a sign-in screen giving way to the home screen). With an empty stack it is a push.

◆ requestRedraw()

static void aurore::Application::requestRedraw ( )
static

Asks for the next frames to be drawn, with redraw on demand.

◆ setActiveEvent()

static void aurore::Application::setActiveEvent ( bool  value)
static

Marks the app active now (and asks for a redraw), or no longer.

◆ setAppId()

static void aurore::Application::setAppId ( std::string  appId)
inlinestatic

Sets the application ID reported to the windowing system (Wayland app_id / X11 WM_CLASS). Desktop environments use it to associate the window with its .desktop entry, which is required for showing the correct icon in the taskbar. Must be called before createWindow().

◆ setAutomaticDeactivation()

static void aurore::Application::setAutomaticDeactivation ( bool  value)
static

If the value is set to true, the program will limit FPS to Application::DeactivatedFPS after Application::DeactivatedTime milliseconds of inactivity.

default is false;

◆ setCadran()

static void aurore::Application::setCadran ( bool  on)
inlinestatic

Aurore draws every app in Cadran's look (docs/cadran.md): init() and createWindow() start it. false, before init(), keeps Aurore's own look instead.

◆ setCommonFooter()

static void aurore::Application::setCommonFooter ( std::string  footer)
static

A text the app keeps for its footers (the library does not draw it).

◆ setDeactivatedFPS()

static void aurore::Application::setDeactivatedFPS ( int  value)
static

The frame rate once deactivated (5 by default).

◆ setDeactivatedTime()

static void aurore::Application::setDeactivatedTime ( int  millisecond)
static

After this long without an input, the app is drawn at the deactivated FPS.

◆ setDrawCoursor()

static void aurore::Application::setDrawCoursor ( bool  draw)
inlinestatic

Draws the mouse pointer with nanovg (for platforms with no system pointer).

◆ setFocusAnnouncer()

static void aurore::Application::setFocusAnnouncer ( std::function< void(const std::string &)>  announcer)
static

Called with the focused view's description (View:: getAccessibilityDescription: "Save, button") each time the focus moves: where a screen reader, a text-to-speech engine or a log plugs in. Nothing by default; an empty function removes it.

◆ setFPSStatus()

static void aurore::Application::setFPSStatus ( bool  enabled)
static

Whether getFPS() is counted (60 when off).

◆ setGlobalQuit()

static void aurore::Application::setGlobalQuit ( bool  enabled)
static

Sets whether BUTTON_START will globally be used to close the application.

◆ setHighlightIdleFade()

static void aurore::Application::setHighlightIdleFade ( bool  fade)
static

When on, the focus highlight fades out after a moment without any button pressed (0.8 s, then 0.4 s), and comes back at the next one: for a screen watched more than browsed (a player, a slideshow). Off by default.

◆ setHintsLiteMode()

static void aurore::Application::setHintsLiteMode ( const bool  value)
inlinestatic

Set hints lite mode, which will only show hints for A button and B button.

◆ setHotReload()

static void aurore::Application::setHotReload ( bool  enabled,
const std::string &  resourcesDir = "" 
)
static

Hot reload, on a desktop (docs/hot_reload.md): the XML files the activity on top was built from, and the files read by Theme::loadFile(), are watched, and the activity is built again when one of them changes (the focus is put back where it was when it can be). resourcesDir, when given, is a resources folder (the app's sources' resources/) the XML files are read from in place of the ones built in (libromfs) or copied next to the app. Off by default; AURORE_HOT_RELOAD=1, or AURORE_HOT_RELOAD=<resources folder>, in the environment turns it on at init(). Does nothing on the consoles.

◆ setInspectorEnabled()

static void aurore::Application::setInspectorEnabled ( bool  enabled)
static

The built-in inspector (docs/inspector.md): F12 on a keyboard, or both sticks pressed in together (L3 + R3) on a controller, opens it over the screen with the view tree, the focus chain, the yoga box and the theme values of a view, and the frame's timings. Off by default; the AURORE_INSPECTOR CMake option, or AURORE_INSPECTOR=1 in the environment on a desktop, turns it on at init(). Closed, it only watches for its toggle.

◆ setLimitedFPS()

static void aurore::Application::setLimitedFPS ( size_t  fps)
static

Set the FPS limit

Parameters
fps0 to disable limit

◆ setMaximumUIScale()

static void aurore::Application::setMaximumUIScale ( float  scale)
static

Caps how large the UI is allowed to grow relative to the design size. Set to 0 to disable the cap.

◆ setRedrawDebug()

static void aurore::Application::setRedrawDebug ( bool  enabled)
static

Debugging redraw on demand: each frame it skips is drawn all the same, without being presented, and compared with the last frame presented. A difference is something that changed on screen without asking for a redraw (a missing invalidate() or requestRedraw()): it is logged as a warning, with the area and the views drawn there (once per area). Reads every frame back: slow, and OpenGL drivers only. Off by default; AURORE_REDRAW_DEBUG=1 in the environment turns it on (desktop).

◆ setRedrawOnDemand()

static void aurore::Application::setRedrawOnDemand ( bool  enabled)
static

Redraw on demand: a frame is drawn only when something may have changed on screen (an input, a running animation, a sync or delayed task that ran, a view's layout invalidated, a window resized, or requestRedraw()), and at least once a second. On the other frames the inputs are still read, but nothing is drawn or presented, which saves most of the CPU and GPU time of an idle screen.

A view that changes how it looks without any of these (a colour set from a timer of its own...) calls requestRedraw().

default is false: every frame is drawn.

◆ setReduceMotion()

static void aurore::Application::setReduceMotion ( bool  reduce)
static

Reduced motion: the movements that are only there for show are skipped (the transition= of views, the highlight's glide, the scrolling of lists and of texts cut short, the toasts' and dropdowns' slide, the switch cells' bounce; Cadran's entrances, glides and breathing glow). Off by default. getReduceMotion(), which transitions read, is also true while Cadran's effects leave movement out (Preferences › Visual effects "reduced", the lighter effects in hand, AURORE_STILL_FOCUS); the highlight's glide follows the app's setting only.

◆ setSwapInputKeys()

static void aurore::Application::setSwapInputKeys ( bool  swap)
static

Swaps A and B (and X and Y) for the app's actions, as on a Japanese console.

◆ setSwapInterval()

static void aurore::Application::setSwapInterval ( int  interval)
static

Set the swap interval Must be called after createWindow. On some platforms, it is impossible to set it back to 0 after setting it to a non-zero values, so you can use VideoContext::swapInterval = 0; (#include "aurore/core/video.hpp") before creating the window.

Test results:

Platforms that always vsync (interval: 1):

iOS18/GLES3/SDL PS4/GLES2/SDL

Platforms that only support enable and disable vsync (interval: 0,1):

Android9/GLES2/SDL macOS13.0+/GL3.2/GLFW (will fixed to 120fps with vsync enabled, https://github.com/glfw/glfw/pull/2277) Windows11/GL3.2/GLFW Linux Wayland/GL3.2/GLFW

Platforms that not support disable vsync (interval: 1,2,3,4):

Windows11/D3D11/GLFW Switch/DEKO3D

Platforms that support arbitrary values (interval: 0,1,2,3,4):

PsVita/GXM PsVita/GLES2/SDL macOS13.0+/GL3.2/SDL Linux X11/GL3.2/GLFW Linux X11/GL3.2/SDL Linux Wayland/GL3.2/SDL Switch/GL4.3/GLFW Switch/GL4.3/SDL

Parameters
interval0 to disable vsync

◆ setTextScale()

static void aurore::Application::setTextScale ( float  scale)
static

Every Label drawn scale times its size (Label::setFontScale), and the screens laid out again for it at once (every view told through View::onTextScaleChanged). 1 by default; Cadran's text size setting goes through here.

◆ setWindowPosition()

static void aurore::Application::setWindowPosition ( int  xPos,
int  yPos 
)
static

Do not call this function, use it internally. Called when the video context is ready (to setup the initial window position).

◆ setWindowSize()

static void aurore::Application::setWindowSize ( int  width,
int  height 
)
static

Do not call this function, use it internally. Called when the video context is ready (to setup the initial content scaling).

◆ tryDeinitFirstResponder()

static void aurore::Application::tryDeinitFirstResponder ( View *  view)
static

Stops the touch gestures view is tracking, before it is removed.

◆ unblockInputs()

static void aurore::Application::unblockInputs ( )
static

Unblocks inputs after a call to blockInputs()

◆ unmapKey()

static void aurore::Application::unmapKey ( AuroreKeyCombination  key)
static

The keyboard keys that press a controller button, on top of Enter (A), Escape (B) and the arrows. By default X, Y, L, R, Shift+L (ZL), Shift+R (ZR), P or + (Plus), M or - (Minus) and Backspace (B); keys are named after their place on a US keyboard (docs/input.md). A key a view registers an action for keeps that action only, and none applies while a text is being typed.

◆ unregisterModel()

static void aurore::Application::unregisterModel ( const std::string &  name)
static

◆ XMLViewsRegisterContains()

static bool aurore::Application::XMLViewsRegisterContains ( std::string  name)
static

Whether an XML tag is registered (registerXMLView()).

Friends And Related Symbol Documentation

◆ EditTextDialog

friend class EditTextDialog
friend

Member Data Documentation

◆ appId

std::string aurore::Application::appId = ""
inlinestatic

See setAppId().

◆ contentHeight

float aurore::Application::contentHeight
static

◆ contentWidth

float aurore::Application::contentWidth
inlinestatic

The size of the UI in layout units: ORIGINAL_WINDOW_WIDTH wide, as high as the window's ratio gives.

◆ maximumUIScale

float aurore::Application::maximumUIScale = 0.0f
inlinestatic

◆ ORIGINAL_WINDOW_HEIGHT

uint32_t aurore::Application::ORIGINAL_WINDOW_HEIGHT = 720
inlinestatic

The design height.

◆ ORIGINAL_WINDOW_WIDTH

uint32_t aurore::Application::ORIGINAL_WINDOW_WIDTH = 1280
inlinestatic

The design width, in layout units.

◆ windowHeight

unsigned aurore::Application::windowHeight
static

◆ windowScale

float aurore::Application::windowScale
inlinestatic

Pixels per layout unit (windowWidth / ORIGINAL_WINDOW_WIDTH, capped by setMaximumUIScale()).

◆ windowWidth

unsigned aurore::Application::windowWidth
inlinestatic

The window's size in pixels.

◆ windowXPos

int aurore::Application::windowXPos
inlinestatic

The window's position on the screen (desktop).

◆ windowYPos

int aurore::Application::windowYPos
static

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