-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathShell.h
More file actions
104 lines (83 loc) · 2.88 KB
/
Shell.h
File metadata and controls
104 lines (83 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
#include "MatrixOS.h"
#include "UI/UI.h"
#include "Application.h"
#include "PythonAppDiscovery.h"
// Shell-specific application management structures
enum class ApplicationType : uint8_t {
Native = 0,
Python = 1
};
struct ApplicationEntry {
ApplicationType type;
union {
struct {
Application_Info* info; // Points to Application_Info regardless of type
} native;
struct {
PythonAppDiscovery::PythonAppInfo* info; // Points to PythonAppInfo for Python apps
} python;
};
ApplicationEntry(Application_Info* native_app_info)
: type(ApplicationType::Native) {
native.info = native_app_info;
}
ApplicationEntry(PythonAppDiscovery::PythonAppInfo* py_app_info)
: type(ApplicationType::Python) {
python.info = py_app_info;
}
};
class Shell : public Application {
public:
inline static Application_Info info = {
.name = "Shell",
.author = "203 Systems",
.color = Color(0x00FFAA),
.version = 1,
.visibility = false,
};
// Folder system constants
static constexpr uint8_t FOLDER_COUNT = 6; // Folders 0-5
static constexpr uint8_t FOLDER_HIDDEN = 254; // User hidden apps folder
static constexpr uint8_t FOLDER_INVISIBLE = 255; // System invisible apps folder
struct Folder
{
std::vector<uint32_t> app_ids;
};
Color folder_colors[FOLDER_COUNT] = { // If color is not set, that means folder is not created
Color(0x00FFFF), Color(0x000000), Color(0x000000),
Color(0x000000), Color(0x000000), Color(0x000000)
};
// Folder definitions (0-5)
std::unordered_map<uint8_t, Folder> folders;
// Storage for Python app infos (to keep Application_Info objects alive)
std::vector<PythonAppDiscovery::PythonAppInfo> python_app_infos;
// Shell's view of all applications (native + Python)
std::unordered_map<uint32_t, ApplicationEntry> all_applications;
uint8_t current_folder = 0; // Start with folder 0
uint32_t selected_app_id = 0; // Currently selected app in edit mode (0 = none)
void Setup(const vector<string>& args) override;
void Loop() override;
// Folder system functions
void InitializeFolderSystem();
void TestFileSystem();
uint8_t GetAppFolder(uint32_t app_id, const ApplicationEntry& app_entry);
bool EnableFolder(uint8_t folder_idx, Color color);
void DisableFolder(uint8_t folder_id);
void DeleteFolder(uint8_t folder_id);
void MoveAppToFolder(uint32_t app_id, uint8_t folder_id);
// Python application discovery
#if DEVICE_STORAGE
void DiscoverPythonApps();
#endif
// Helper functions for NVS
void SaveFolderVector(uint8_t folder_id);
void LoadFolderVector(uint8_t folder_id);
void SaveAllFolderVectors();
void CleanupInvalidApps();
// Application launcher functions
void ApplicationLauncher();
void ApplicationLauncherEditing();
void HiddenApplicationLauncher();
void LaunchAnimation(Point origin, Color color);
};