aboutsummaryrefslogtreecommitdiffstats
path: root/app/app_manager.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/app_manager.hpp')
-rw-r--r--app/app_manager.hpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/app_manager.hpp b/app/app_manager.hpp
new file mode 100644
index 0000000..b7783ea
--- /dev/null
+++ b/app/app_manager.hpp
@@ -0,0 +1,45 @@
+#pragma once
+#include <vector>
+#include "base_app.hpp"
+
+// Interface to the app manager. These functions are accessible to other parts of the code, except open_apps, which is managed by the following functions.
+namespace app_mgr {
+ // List of pointers to currently running apps.
+ extern std::vector<BaseApp*> open_apps;
+
+ // Init a new app, that is not running.
+ BaseApp* app_init(int app_id);
+
+ // Allow the running app, referenced by app_id, to invoke its render routine.
+ void app_render(BaseApp* app);
+
+ // Delta is in ms, from time_since_button_press()
+ void app_btnpressed(BaseApp* app, uint gpio, unsigned long delta);
+
+ // This should only be called by pico-watch.cpp before app rendering, to chage the current app.
+ void app_switch(BaseApp* app, int new_appid);
+
+ // Requests the current app to be replaced by an other one. The replacement will be done at the right moment.
+ void app_switch_request(int to_appid);
+
+ // Refresh each app
+ void app_all_bgrefresh();
+
+ // Private functions following. I tried using anonymous namespaces but it was too complicated. I might come back to this later. Just don't use the following internal functions.
+
+ // Check if the specified app (via app_id) is already running.
+ // \return If app is init, pointer to app, else nullptr (more or less 0).
+ BaseApp* app_check_if_init(int app_id);
+
+ // Check the return value of the called application method and act on it.
+ void app_act_on_return_value(BaseApp* app, BaseApp::AppReturnValues return_value);
+
+ // Unconditionally set the new foreground app
+ void new_foreground_app(BaseApp* app);
+
+ // Called by app_init to create the app object.
+ BaseApp* app_create(int app_id);
+
+ // Quit the app referenced by the app_id.
+ void app_destroy(BaseApp* to_erase);
+}
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260