feat: add AppRegistry, RootLayout, UIHandler, and UIApp classes for improved UI management

This commit is contained in:
GW_MC
2026-01-24 10:39:16 +08:00
parent d248557614
commit 6ad55c7efc
5 changed files with 422 additions and 0 deletions

39
main/ui/app_registry.h Normal file
View File

@@ -0,0 +1,39 @@
#pragma once
#include "ui/ui_app.h"
#include <vector>
/**
* @brief Registry for all available apps
*
* This singleton class maintains a list of all registered
* AppDescriptor instances, allowing the UIHandler or other
* components to query available apps.
*/
class AppRegistry {
public:
static AppRegistry& instance() {
static AppRegistry registry;
return registry;
}
AppRegistry(const AppRegistry&) = delete;
void operator=(const AppRegistry&) = delete;
AppRegistry(AppRegistry&&) = delete;
void operator=(AppRegistry&&) = delete;
// Register a new app descriptor
// The registry takes ownership of the descriptor pointer.
void register_app(AppDescriptor* app_descriptor) {
_app_descriptors.push_back(app_descriptor);
}
const std::vector<AppDescriptor*>& get_app_descriptors() const {
return _app_descriptors;
}
private:
AppRegistry() = default;
~AppRegistry() = default;
std::vector<AppDescriptor*> _app_descriptors = {};
};