- Refactor the way apps work: Instead of a C interface, they are now C++ classes. The main reasoning is that attaching data to an app was cumbersome. Having different implementations for different kinds of apps was cumbersome too. (3 or 4 layers of manifest nesting for the TactilityC project) - External apps are still written in C, but they get a createData/destroyData in their manifest, so: - External apps now have their own manifest. - All functions in the original AppManifest are removed and replaced by a single `createApp` function - External apps now automatically register (each app individually!) when they run the first time. As a side-effect they become visible in the `AppList` app! - Adapted all apps for the new interface. - Adapted all internal logic for these changes (Gui, ViewPort, Loader, AppContext, AppInstance, etc.) - Rewrote parts of Loader to use std::shared_ptr to make the code much safer. - Added a refcount check for the `AppInstance` and `App` at the end of their lifecycle. Show warning if refcount is too high.
48 lines
990 B
C++
48 lines
990 B
C++
#include "app/files/View.h"
|
|
#include "app/files/State.h"
|
|
|
|
#include "app/AppContext.h"
|
|
#include "Assets.h"
|
|
#include "service/loader/Loader.h"
|
|
|
|
#include <memory>
|
|
|
|
namespace tt::app::files {
|
|
|
|
#define TAG "files_app"
|
|
|
|
extern const AppManifest manifest;
|
|
|
|
class FilesApp : public App {
|
|
std::unique_ptr<View> view;
|
|
std::shared_ptr<State> state;
|
|
|
|
public:
|
|
FilesApp() {
|
|
state = std::make_shared<State>();
|
|
view = std::make_unique<View>(state);
|
|
}
|
|
|
|
void onShow(AppContext& appContext, lv_obj_t* parent) override {
|
|
view->init(parent);
|
|
}
|
|
|
|
void onResult(AppContext& appContext, Result result, std::unique_ptr<Bundle> bundle) override {
|
|
view->onResult(result, std::move(bundle));
|
|
}
|
|
};
|
|
|
|
extern const AppManifest manifest = {
|
|
.id = "Files",
|
|
.name = "Files",
|
|
.icon = TT_ASSETS_APP_ICON_FILES,
|
|
.type = Type::Hidden,
|
|
.createApp = create<FilesApp>
|
|
};
|
|
|
|
void start() {
|
|
service::loader::startApp(manifest.id);
|
|
}
|
|
|
|
} // namespace
|