Class · aurore
aurore::Application
#include <aurore/core/application.hpp>
class aurore::ApplicationDescription
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.
Static functions 130
static void mapKey(AuroreKeyCombination key, ControllerButton button) 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.
application.hpp:724static void unmapKey(AuroreKeyCombination key) 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.
application.hpp:725The 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.
application.hpp:726static const std::vector< std::pair< AuroreKeyCombination, ControllerButton > > & getKeyMap() 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.
application.hpp:727Inits the Aurore application. Returns true if it succeeded, false otherwise.
application.hpp:116Sets 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().
application.hpp:125The application ID given to setAppId(), "" by default.
application.hpp:127Aurore draws every app in Cadran's look (docs/cadran.md): init() and createWindow() start it. false, before init(), keeps Aurore's own look instead.
application.hpp:134Whether the app is drawn in Cadran's look (see setCadran()).
application.hpp:136Creates the application window with the given title. Must be called after calling init().
application.hpp:142Application main loop iteration. Must be called in an infinite loop until it returns false.
application.hpp:148static Platform * getPlatform() The platform the app runs on (window, inputs, video, audio, fonts), made by init().
application.hpp:151static AudioPlayer * getAudioPlayer() The platform's sound player.
application.hpp:153The Yoga configuration every view's node is created with (web defaults, yoga's messages in the log).
application.hpp:159The nanovg context every view draws with.
application.hpp:162Called by the video context when the content window is resized
application.hpp:177Do not call this function, use it internally. Called when the video context is ready (to setup the initial content scaling).
application.hpp:183Called by the video context when the content window is Repositioned
application.hpp:188Do not call this function, use it internally. Called when the video context is ready (to setup the initial window position).
application.hpp:194static std::vector< Activity * > getActivitiesStack() A copy of the stack of activities, the first pushed first.
application.hpp:197static void pushActivity( Activity *view,TransitionAnimation animation = TransitionAnimation::FADE)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.
application.hpp:209static void replaceActivity( Activity *activity,TransitionAnimation animation = TransitionAnimation::FADE)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.
application.hpp:218static bool popActivity( TransitionAnimation animation = TransitionAnimation::FADE,std::function< void(void)> cb = [] {},bool free = true)Pops the last pushed activity from the stack and gives focus back where it was before.
return false if no actifity to pop.
application.hpp:226static void giveFocus(View *view) Gives the focus to the given view or clears the focus if given nullptr.
application.hpp:233static void forgetView(View *view) Drops every reference the focus system holds to a view that is being destroyed.
application.hpp:239When 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.
application.hpp:247Called 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.
application.hpp:255Gives 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).
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.
application.hpp:277The app's own setting alone, without Cadran's.
application.hpp:280static Time getLastInputTime() 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.
application.hpp:286Every 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.
The density of the lengths (aurore::setDensity): DENSITY_COMFORTABLE by default, DENSITY_COMPACT, DENSITY_DENSE for a small screen. The text keeps its size (setTextScale). Read when the views are made: set it before the first screen; AURORE_DENSITY gives it on the desktop.
application.hpp:303static WidthClass getWidthClass() The class of the screen's width now (widthClassOf(contentWidth)). XML reads it when a view is made; a view that lays itself out in code reads it there too, and the window size changed event says when it may have changed. ORIGINAL_WINDOW_WIDTH sets it for a small screen (480 on a 320-pixel one); AURORE_DESIGN_SIZE=480x360 tries it on the desktop.
application.hpp:313static void usePreset(const LayoutPreset &preset) Lays every screen out for preset (PRESET_SMALL_SCREEN on a small screen): its design size, density and text scale. Before init(); a platform may give one (Platform::getLayoutPreset), the app's wins, and AURORE_PRESET (small or standard) wins over both on the desktop.
The text scale of the preset in use (1 without one): what Cadran's text size setting multiplies.
application.hpp:324static void registerModel(const std::string &name, DataModel *model) 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.
application.hpp:331static View * getHoveredView() The view under the mouse pointer that has a hover: style (desktop), or nullptr.
application.hpp:339static Style getStyle() The metrics in use (aurore::getStyle()).
application.hpp:342static Theme getTheme() The colours of the variant in use (light or dark), with the theme file's over them.
application.hpp:348static ThemeVariant getThemeVariant() The variant in use, as the platform reports it.
application.hpp:350static Event< ThemeVariant > * getThemeChangedEvent() 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.
application.hpp:359Whether the theme in use draws a picture behind the screens in the variant in use (its background_image, loaded).
application.hpp:365Draws 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.
static void drawThemeBackground( NVGcontext *vg,float x,float y,float width,float height,float radius)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).
static ImeManager * getImeManager() The platform's text input (the keyboard shown for an EditTextDialog).
application.hpp:384Loads 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.
application.hpp:392Loads a font from a given memory buffer and stores it in the font stash. Returns true if the operation succeeded.
application.hpp:398static bool loadFontFromMemory( std::string fontName,void *data,size_t size,bool freeData,int faceIndex)The same, with the face at faceIndex of a font collection (.ttc).
Returns the nanovg handle to the given font name, or FONT_INVALID if no such font is currently loaded.
application.hpp:409Glyphs missing from the font loaded as font are looked up in the one loaded as fallback. False when either is not loaded.
The font a new Label draws with: the regular font (the Chinese one on the Switch).
application.hpp:418static void notify(const std::string &text, View *leading = nullptr) Shows a toast with text, and leading (an icon) before it when given; the focus announcer says the text.
static void onControllerButtonPressed( enum ControllerButton button,bool repeating)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.
application.hpp:426static void onKeyboardPressed(AuroreKeyCombination key, bool repeating) Handles a key as the main loop does (the actions registered on keys).
application.hpp:429"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.
Asks the main loop to stop: the next mainLoop() returns false, after the exit events.
application.hpp:442Deletes every activity on the stack and clears the focus.
application.hpp:444Blocks any and all user inputs
application.hpp:449Unblocks inputs after a call to blockInputs()
application.hpp:455Whether blockInputs() is in force.
application.hpp:458static const ControllerState & getControllerState() The controller's buttons and sticks as read this frame.
application.hpp:461Caps how large the UI is allowed to grow relative to the design size. Set to 0 to disable the cap.
application.hpp:475Sets whether BUTTON_START will globally be used to close the application.
application.hpp:481Whether getFPS() is counted (60 when off).
application.hpp:484The frames per second over the last second.
application.hpp:487Set 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
If the value is set to true, the program will limit FPS to Application::DeactivatedFPS after Application::DeactivatedTime milliseconds of inactivity.
default is false;
application.hpp:537Whether the app is active: an input lately, an animation under way, or no automatic deactivation. Always true on the Switch.
application.hpp:542Marks the app active now (and asks for a redraw), or no longer.
application.hpp:544After this long without an input, the app is drawn at the deactivated FPS.
application.hpp:546The frame rate once deactivated (5 by default).
application.hpp:548A frame's time once deactivated, in seconds.
application.hpp:551Redraw 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.
application.hpp:566Asks for the next frames to be drawn, with redraw on demand.
application.hpp:573Number of frames drawn since the start (frames skipped by redraw on demand are not counted).
application.hpp:579Debugging 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).
application.hpp:590With setRedrawDebug(): the number of skipped frames found different from the last frame presented, and the last such area, in the views' coordinates.
application.hpp:599static GenericEvent * getGlobalFocusChangeEvent() Fired with the new focus each time the focus moves.
application.hpp:603static VoidEvent * getGlobalHintsUpdateEvent() Fired when the footer's hints must be read again (the focus moved, keys swapped).
application.hpp:605Fired when the input type changes (a touch after the buttons, or the reverse).
application.hpp:607static VoidEvent * getRunLoopEvent() Fired once per main loop iteration, after the frame and the sync tasks.
application.hpp:609static VoidEvent * getPostFrameEvent() Fired after each frame presented.
application.hpp:611static VoidEvent * getExitEvent() Fired when the app starts to exit, before the activities are deleted.
application.hpp:613static VoidEvent * getExitDoneEvent() Fired once the activities and the views left are deleted.
application.hpp:615static VoidEvent * getWindowSizeChangedEvent() Fired when the window's size changed.
application.hpp:617static VoidEvent * getWindowCreationDoneEvent() Fired at the end of createWindow().
application.hpp:619static VoidEvent * getWindowShouldCloseEvent() Fired when the window is closed or quit() was asked, before the exit.
application.hpp:621static Event< bool > * getWindowFocusChangedEvent() Fired with true or false when the window gains or loses the system's focus.
application.hpp:623static View * getCurrentFocus() The view that has the focus, or nullptr.
application.hpp:626The window's title, as given to createWindow().
application.hpp:629static void registerXMLView(std::string name, XMLViewCreator creator) 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.
application.hpp:640Whether an XML tag is registered (registerXMLView()).
application.hpp:643The XML tags registered (registerXMLView).
application.hpp:646static XMLViewCreator getXMLViewCreator(std::string name) The function registered for an XML tag.
application.hpp:648Returns the current system locale.
application.hpp:653static void addToFreeQueue(View *view) Deletes view at the end of the current main loop iteration (once no ptrLock() holds it). View::freeView() calls it.
static InputType getInputType() Returns the current input type.
application.hpp:662The 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.
application.hpp:676Hot 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.
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.
application.hpp:701Draws the debug layer (DebugLayer) over the app.
application.hpp:704Swaps A and B (and X and Y) for the app's actions, as on a Japanese console.
application.hpp:715Draws the mouse pointer with nanovg (for platforms with no system pointer).
application.hpp:736Set hints lite mode, which will only show hints for A button and B button.
application.hpp:753static 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) Static attributes 13
The design width, in layout units.
application.hpp:108The design height.
application.hpp:109The size of the UI in layout units: ORIGINAL_WINDOW_WIDTH wide, as high as the window's ratio gives.
application.hpp:164usePreset() called by the app
application.hpp:166The window's size in pixels.
application.hpp:169The window's position on the screen (desktop).
application.hpp:172Pixels per layout unit (windowWidth / ORIGINAL_WINDOW_WIDTH, capped by setMaximumUIScale()).
application.hpp:468Friends 1
Read from Aurore's headers by Doxygen at each build · library/include