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 isRunning = true;
53 bool exitRequested = false;
54 bool canUseSelectToExit = false;
55
56 int lastFrameTime = 99;
57 SDL_Event needsRender;
58
59 // our main input events
60 InputEvents* events = NULL;
61
62 std::function<void()> windowResizeCallback = NULL; // Called when the window is resized
63
64#if defined(__WIIU__)
65 void processWiiUHomeOverlay();
66#endif
67
68 std::vector<Element*> trash;
69 void recycle();
70
71#if defined(MUSIC)
72 Mix_Music* music = NULL;
73#endif
74};
int width
width and height of this element (must be manually set, isn't usually calculated (but is in some case...
Definition: Element.hpp:118
Element * parent
the parent element (can sometimes be null if it isn't set)
Definition: Element.hpp:102
bool process(InputEvents *event)
process any input that is received for this element
void render(Element *parent)
display the current state of the display