Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
RootDisplay.hpp
1#pragma once
2#include "Element.hpp"
3
4#include "colorspaces.hpp"
5#include <unordered_map>
6
7#if defined(_3DS) || defined(_3DS_MOCK)
8#define ICON_SIZE 48
9#else
10#define ICON_SIZE 150
11#endif
12
13#define SCREEN_WIDTH RootDisplay::screenWidth
14#define SCREEN_HEIGHT RootDisplay::screenHeight
15
16class RootDisplay : public Element
17{
18public:
20 virtual ~RootDisplay();
21
22 bool process(InputEvents* event);
23 void render(Element* parent);
24
25 void update();
26 int mainLoop();
27
28 void initMusic();
29 void startMusic();
30
31 void setScreenResolution(int width, int height);
32
33 static CST_Renderer* renderer;
34 static CST_Window* window;
35 static RootDisplay* mainDisplay;
36
37 static void switchSubscreen(Element* next);
38 static Element* subscreen;
39 static Element* nextsubscreen;
40
41 // dimensions of the screen, which can be modified
42 static int screenWidth;
43 static int screenHeight;
44 static float dpiScale;
45
46 // if enabled, the cursor will pulse when idle
47 // this uses more energy and forces more redraws
48 // TODO: enable or disable based on battery level or user preference
49 static bool idleCursorPulsing;
50
51 static bool isDebug;
52 bool canUseSelectToExit = false;
53
54 int lastFrameTime = 99;
55 SDL_Event needsRender;
56
57 // our main input events
58 InputEvents* events = NULL;
59
60 std::function<void()> windowResizeCallback = NULL; // Called when the window is resized
61
62 std::vector<Element*> trash;
63 void recycle();
64
65 void requestQuit();
66
67#if !defined(SIMPLE_SDL2)
68 Mix_Music* music = NULL;
69#endif
70
71private:
72 // these bools are managed by RootDisplay mainLoop, and should not be modified
73 // to break out. Instead, call requestQuit() which will update it if needed
74 bool hasRequestedQuit = false;
75 bool isAppRunning = true;
76};
int width
width and height of this element (must be manually set, isn't usually calculated (but is in some case...
Definition: Element.hpp:120
Element * parent
the parent element (can sometimes be null if it isn't set)
Definition: Element.hpp:104
bool process(InputEvents *event)
process any input that is received for this element
void render(Element *parent)
display the current state of the display