25#include <unordered_map>
74 inline static std::string
appId =
"";
98 static void setCadran(
bool on) { Application::cadran = on; }
100 static bool isCadran() {
return Application::cadran; }
323 static void drawThemeBackground(NVGcontext* vg,
float x,
float y,
float width,
float height,
float radius);
345 static bool loadFontFromMemory(std::string fontName,
void* data,
size_t size,
bool freeData,
int faceIndex);
633 static void setHotReload(
bool enabled,
const std::string& resourcesDir =
"");
648 debuggingViewEnabled = enable;
653 return debuggingViewEnabled;
669 static const std::vector<std::pair<AuroreKeyCombination, ControllerButton>>&
getKeyMap();
674 return swapInputKeys;
691 return hintsLiteMode;
697 hintsLiteMode = value;
710 static void updateHover(
Point position,
bool inside);
711 static void announceFocus(
View* oldFocus,
View* newFocus);
713 inline static std::function<void(
const std::string&)> focusAnnouncer;
714 inline static std::string lastAnnouncement;
715 inline static bool reduceMotion =
false;
716 inline static std::unordered_map<std::string, DataModel*> models;
717 inline static View* hoveredView =
nullptr;
719 inline static bool inited =
false;
720 inline static bool cadran =
true;
721 inline static bool quitRequested =
false;
722 inline static bool debuggingViewEnabled =
false;
723 inline static bool swapInputKeys =
false;
724 inline static bool drawCoursor =
false;
726 inline static Platform* platform =
nullptr;
728 inline static std::string title;
732 inline static std::vector<Activity*> activitiesStack;
733 inline static std::vector<View*> focusStack;
734 inline static std::deque<View*> deletionPool;
736 inline static View* currentFocus =
nullptr;
737 inline static std::vector<TouchState> currentTouchState;
742 static bool setInputType(
InputType type);
745 inline static std::vector<AuroreKeyState> watchedKeys;
746 inline static std::vector<AuroreKeyState> oldWatchedKeys;
747 inline static std::unordered_map<int, int> watchedKeysMap;
748 static std::vector<std::pair<AuroreKeyCombination, ControllerButton>> keyMap;
752 inline static void processInput();
753 inline static bool internalMainLoop();
755 inline static void updateFPS();
757 inline static unsigned blockInputsTokens = 0;
758 inline static bool muteSounds =
false;
760 inline static std::string commonFooter;
762 inline static bool globalQuitEnabled =
false;
764 inline static bool globalFPSToggleEnabled =
false;
765 inline static size_t globalFPS = 60;
766 inline static Time limitedFrameTime = 0;
767 inline static Time frameStartTime = 0;
768 inline static bool hintsLiteMode =
false;
770 inline static bool deactivatedBehavior =
false;
771 inline static bool activeEvent =
false;
772 inline static Time lastActiveTime = 0;
773 inline static Time lastInputTime = 0;
774 inline static bool highlightIdleFade =
false;
775 inline static bool redrawOnDemand =
false;
776 inline static int redrawFrames = 2;
777 inline static Time lastDrawTime = 0;
778 inline static uint64_t drawnFrames = 0;
779 inline static bool redrawDebug =
false;
780 inline static uint64_t missedRedraws = 0;
781 static Rect missedRedrawArea;
782 inline static std::vector<unsigned char> presentedPixels;
783 inline static int presentedWidth = 0, presentedHeight = 0;
784 inline static int deactivatedFPS = 5;
785 inline static int deactivatedTime = 5000000;
787 inline static View* repetitionOldFocus =
nullptr;
790 inline static VoidEvent globalHintsUpdateEvent;
796 inline static VoidEvent windowSizeChangedEvent;
797 inline static VoidEvent windowCreationDoneEvent;
798 inline static VoidEvent windowShouldCloseEvent;
803 inline static uint64_t themeGeneration = 0;
805 static void checkThemeChanged();
810 inline static std::shared_ptr<ThemeImage> themeBackground;
811 inline static std::shared_ptr<ThemeImage> themeBackgroundLoading;
812 static void loadThemeBackground();
813 static void onThemeImageLoaded(
const ThemeImage* image);
814 static void drawThemeBackgroundImage(NVGcontext* vg,
float x,
float y,
float width,
float height,
float radius = 0.0f);
816 inline static std::unordered_map<std::string, XMLViewCreator> xmlViewsRegister;
821 static void frame(
bool present =
true);
822 static void checkSkippedFrame();
830 static bool handleAction(
ActionType type,
int button,
bool repeating);
832 static void registerBuiltInXMLViews();
834 inline static DebugLayer* debugLayer =
nullptr;
#define ACTION_NONE
Definition actions.hpp:102
Definition activity.hpp:45
Definition application.hpp:68
static std::string appId
See setAppId().
Definition application.hpp:74
static bool popActivity(TransitionAnimation animation=TransitionAnimation::FADE, std::function< void(void)> cb=[] {}, bool free=true)
static void setRedrawDebug(bool enabled)
static bool hasActiveEvent()
static float getMaximumUIScale()
static bool isInputBlocks()
Whether blockInputs() is in force.
static float getTextScale()
static int getFont(std::string fontName)
static void setLimitedFPS(size_t fps)
static std::vector< std::string > getXMLViewNames()
The XML tags registered (registerXMLView).
static void addToFreeQueue(View *view)
static void onKeyboardPressed(AuroreKeyCombination key, bool repeating)
Handles a key as the main loop does (the actions registered on keys).
static void unmapKey(AuroreKeyCombination key)
static XMLViewCreator getXMLViewCreator(std::string name)
The function registered for an XML tag.
static void pushActivity(Activity *view, TransitionAnimation animation=TransitionAnimation::FADE)
static bool loadFontFromMemory(std::string fontName, void *data, size_t size, bool freeData)
static void forgetView(View *view)
static Platform * getPlatform()
The platform the app runs on (window, inputs, video, audio, fonts), made by init().
static void drawThemeBackground(NVGcontext *vg, float x, float y, float width, float height, float radius)
static VoidEvent * getRunLoopEvent()
Fired once per main loop iteration, after the frame and the sync tasks.
static void registerXMLView(std::string name, XMLViewCreator creator)
static void notify(const std::string &text, View *leading=nullptr)
static void setDensity(float density)
Definition application.hpp:265
static void setSwapInputKeys(bool swap)
Swaps A and B (and X and Y) for the app's actions, as on a Japanese console.
static void setWindowPosition(int xPos, int yPos)
static void quit()
Asks the main loop to stop: the next mainLoop() returns false, after the exit events.
static bool isHintsLiteMode()
See setHintsLiteMode().
Definition application.hpp:689
static bool getFPSStatus()
static void setFPSStatus(bool enabled)
Whether getFPS() is counted (60 when off).
static std::string getLocale()
static void drawThemeBackground(NVGcontext *vg, float x, float y, float width, float height)
static size_t getFPS()
The frames per second over the last second.
static std::vector< Activity * > getActivitiesStack()
A copy of the stack of activities, the first pushed first.
static void onWindowReposition(int xPos, int yPos)
static std::string getTitle()
The window's title, as given to createWindow().
static void requestRedraw()
static void setHotReload(bool enabled, const std::string &resourcesDir="")
static void setCommonFooter(std::string footer)
A text the app keeps for its footers (the library does not draw it).
static ImeManager * getImeManager()
The platform's text input (the keyboard shown for an EditTextDialog).
static void enableDebuggingView(bool enable)
Draws the debug layer (DebugLayer) over the app.
Definition application.hpp:646
static bool loadFontFromMemory(std::string fontName, void *data, size_t size, bool freeData, int faceIndex)
static void setAppId(std::string appId)
Definition application.hpp:89
static bool getAutomaticDeactivation()
See setAutomaticDeactivation().
static void setInspectorEnabled(bool enabled)
static void unregisterModel(const std::string &name)
static AudioPlayer * getAudioPlayer()
The platform's sound player.
static void removeWatchedKeys(const AuroreKeyCombination key)
See addToWatchedKeys().
static void clear()
Deletes every activity on the stack and clears the focus.
static void setDeactivatedTime(int millisecond)
After this long without an input, the app is drawn at the deactivated FPS.
static bool isReduceMotionSet()
The app's own setting alone, without Cadran's.
Definition application.hpp:242
static void onWindowResized(int width, int height)
static ThemeVariant getThemeVariant()
The variant in use, as the platform reports it.
static bool isSwapInputKeys()
Definition application.hpp:672
static VoidEvent * getWindowShouldCloseEvent()
Fired when the window is closed or quit() was asked, before the exit.
static Time getLastInputTime()
Definition application.hpp:248
static void setFocusAnnouncer(std::function< void(const std::string &)> announcer)
static void clearKeyMap()
static void setWindowSize(int width, int height)
static bool isDebuggingViewEnabled()
Definition application.hpp:651
static void setGlobalQuit(bool enabled)
static VoidEvent * getWindowSizeChangedEvent()
Fired when the window's size changed.
static void setSwapInterval(int interval)
static void mapKey(AuroreKeyCombination key, ControllerButton button)
static bool loadFontFromFile(std::string fontName, std::string filePath)
static void tryDeinitFirstResponder(View *view)
Stops the touch gestures view is tracking, before it is removed.
static void announce(const std::string &text)
static Theme getTheme()
The colours of the variant in use (light or dark), with the theme file's over them.
static bool isRedrawOnDemand()
See setRedrawOnDemand().
static double getDeactivatedFrameTime()
A frame's time once deactivated, in seconds.
static void setDeactivatedFPS(int value)
The frame rate once deactivated (5 by default).
static void blockInputs(bool muteSounds=false)
static uint64_t getDrawnFrameCount()
static void setHighlightIdleFade(bool fade)
static bool isDrawCursor()
Definition application.hpp:683
static VoidEvent * getWindowCreationDoneEvent()
Fired at the end of createWindow().
static uint32_t ORIGINAL_WINDOW_HEIGHT
The design height.
Definition application.hpp:73
static int windowYPos
Definition application.hpp:134
static void setActiveEvent(bool value)
Marks the app active now (and asks for a redraw), or no longer.
static void setTextScale(float scale)
static int getDefaultFont()
The font a new Label draws with: the regular font (the Chinese one on the Switch).
static void setAutomaticDeactivation(bool value)
static NVGcontext * getNVGContext()
The nanovg context every view draws with.
static bool isRedrawDebug()
See setRedrawDebug().
static void setRedrawOnDemand(bool enabled)
static const std::string & getLastAnnouncement()
Definition application.hpp:226
static bool XMLViewsRegisterContains(std::string name)
Whether an XML tag is registered (registerXMLView()).
static bool isHotReload()
See setHotReload().
static void setCadran(bool on)
Definition application.hpp:98
static void onControllerButtonPressed(enum ControllerButton button, bool repeating)
static float contentHeight
Definition application.hpp:128
static void replaceActivity(Activity *activity, TransitionAnimation animation=TransitionAnimation::FADE)
static InputType getInputType()
Definition application.hpp:604
static GenericEvent * getGlobalFocusChangeEvent()
Fired with the new focus each time the focus moves.
static std::string * getCommonFooter()
static bool addFontFallback(const std::string &font, const std::string &fallback)
static VoidEvent * getExitDoneEvent()
Fired once the activities and the views left are deleted.
static void createWindow(std::string title)
static Event< bool > * getWindowFocusChangedEvent()
Fired with true or false when the window gains or loses the system's focus.
static Rect getLastMissedRedrawArea()
static bool hasThemeBackground()
static float maximumUIScale
See setMaximumUIScale().
Definition application.hpp:411
static bool getReduceMotion()
static bool isInspectorEnabled()
See setInspectorEnabled().
static bool rebuildActivity()
static int getDeactivatedFPS()
static DataModel * getModel(const std::string &name)
static uint64_t getMissedRedrawCount()
static float getDensity()
Definition application.hpp:266
static float contentWidth
The size of the UI in layout units: ORIGINAL_WINDOW_WIDTH wide, as high as the window's ratio gives.
Definition application.hpp:128
static unsigned windowHeight
Definition application.hpp:131
static void addToWatchedKeys(const AuroreKeyCombination key)
Reads key each frame from now on (counted: one removeWatchedKeys() per add).
static const std::string & getAppId()
The application ID given to setAppId(), "" by default.
Definition application.hpp:91
static View * getHoveredView()
Definition application.hpp:281
static YGConfig * getYogaConfig()
static View * getCurrentFocus()
The view that has the focus, or nullptr.
static float windowScale
Pixels per layout unit (windowWidth / ORIGINAL_WINDOW_WIDTH, capped by setMaximumUIScale()).
Definition application.hpp:410
static VoidEvent * getGlobalHintsUpdateEvent()
Fired when the footer's hints must be read again (the focus moved, keys swapped).
static int windowXPos
The window's position on the screen (desktop).
Definition application.hpp:134
static void registerModel(const std::string &name, DataModel *model)
static void setDrawCoursor(bool draw)
Draws the mouse pointer with nanovg (for platforms with no system pointer).
Definition application.hpp:678
static Event< ThemeVariant > * getThemeChangedEvent()
static VoidEvent * getPostFrameEvent()
Fired after each frame presented.
static Style getStyle()
The metrics in use (aurore::getStyle()).
Definition application.hpp:284
static void setReduceMotion(bool reduce)
static VoidEvent * getExitEvent()
Fired when the app starts to exit, before the activities are deleted.
static unsigned windowWidth
The window's size in pixels.
Definition application.hpp:131
static void crash(std::string text)
static void setMaximumUIScale(float scale)
static const std::vector< std::pair< AuroreKeyCombination, ControllerButton > > & getKeyMap()
static const ControllerState & getControllerState()
The controller's buttons and sticks as read this frame.
static void setHintsLiteMode(const bool value)
Set hints lite mode, which will only show hints for A button and B button.
Definition application.hpp:695
static bool isCadran()
Whether the app is drawn in Cadran's look (see setCadran()).
Definition application.hpp:100
static void giveFocus(View *view)
static void unblockInputs()
static Event< InputType > * getGlobalInputTypeChangeEvent()
Fired when the input type changes (a touch after the buttons, or the reverse).
static uint32_t ORIGINAL_WINDOW_WIDTH
The design width, in layout units.
Definition application.hpp:72
Definition observable.hpp:222
Definition debug_layer.hpp:26
Definition edit_text_dialog.hpp:9
Definition notification_manager.hpp:44
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
Definition actions.hpp:25
TransitionAnimation
Definition view.hpp:153
@ FADE
the old activity fades away and the new one fades in
void setDensity(float density)
ThemeVariant
The two sets of colours every theme has: light and dark.
Definition theme.hpp:37
std::unordered_map< std::string, int > FontStash
Definition font.hpp:38
std::function< View *(void)> XMLViewCreator
Makes a new view for an XML tag (Application::registerXMLView).
Definition application.hpp:63
int ActionIdentifier
Definition actions.hpp:31
ControllerButton
Definition input.hpp:179
FocusDirection
Focus direction when navigating.
Definition view.hpp:96
InputType
Input types for entire app.
Definition application.hpp:53
@ GAMEPAD
Gamepad or keyboard.
ActionType
Definition actions.hpp:105
Style getStyle()
The app's metrics: what XML reads with @style/….
retro_time_t Time
Definition time.hpp:31
float getDensity()
The density in use (DENSITY_COMFORTABLE by default).
Definition actions.hpp:36
Definition geometry.hpp:26
Definition geometry.hpp:70
A variant's background, as a theme file sets it (docs/themes.md)
Definition theme.hpp:81
Definition theme_image.hpp:49