Project restructuring (fixes macOS builds) (#198)
- Create `Include/` folder for all main projects - Fix some issues here and there (found while moving things) - All includes are now in `Tactility/` subfolder and must be included with that prefix. This fixes issues with clashing POSIX headers (e.g. `<semaphore.h>` versus Tactility's `Semaphore.h`)
This commit is contained in:
committed by
GitHub
parent
7856827ecf
commit
c87200a80d
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
|
||||
#include <Tactility/hal/Configuration.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
#include <Tactility/TactilityConfig.h>
|
||||
|
||||
namespace tt {
|
||||
|
||||
namespace app::launcher { extern const app::AppManifest manifest; }
|
||||
|
||||
/** @brief The configuration for the operating system
|
||||
* It contains the hardware configuration, apps and services
|
||||
*/
|
||||
struct Configuration {
|
||||
/** HAL configuration (drivers) */
|
||||
const hal::Configuration* hardware = nullptr;
|
||||
/** List of user applications */
|
||||
const std::vector<const app::AppManifest*> apps = {};
|
||||
/** List of user services */
|
||||
const std::vector<const service::ServiceManifest*> services = {};
|
||||
/** Optional app to start automatically after the splash screen. */
|
||||
const std::string launcherAppId = app::launcher::manifest.id;
|
||||
/** Optional app to start automatically after the splash screen. */
|
||||
const std::string autoStartAppId = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Attempts to initialize Tactility and all configured hardware.
|
||||
* @param[in] config
|
||||
*/
|
||||
void run(const Configuration& config);
|
||||
|
||||
/**
|
||||
* While technically nullable, this instance is always set if tt_init() succeeds.
|
||||
* @return the Configuration instance that was passed on to tt_init() if init is successful
|
||||
*/
|
||||
const Configuration* _Nullable getConfiguration();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include <sdkconfig.h>
|
||||
#endif
|
||||
|
||||
#define TT_CONFIG_FORCE_ONSCREEN_KEYBOARD false // for development/debug purposes
|
||||
#define TT_SCREENSHOT_MODE false // for taking screenshots (e.g. forces SD card presence and Files tree on simulator)
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#define TT_FEATURE_SCREENSHOT_ENABLED (CONFIG_LV_USE_SNAPSHOT == 1 && CONFIG_SPIRAM_USE_MALLOC == 1)
|
||||
#else // Sim
|
||||
#define TT_FEATURE_SCREENSHOT_ENABLED true
|
||||
#endif
|
||||
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/AppContext.h"
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
// Forward declarations
|
||||
typedef struct _lv_obj_t lv_obj_t;
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
// Forward declarations
|
||||
class AppContext;
|
||||
enum class Result;
|
||||
|
||||
class App {
|
||||
|
||||
private:
|
||||
|
||||
Mutex mutex;
|
||||
|
||||
struct ResultHolder {
|
||||
Result result;
|
||||
std::unique_ptr<Bundle> resultData;
|
||||
|
||||
explicit ResultHolder(Result result) : result(result), resultData(nullptr) {}
|
||||
|
||||
ResultHolder(Result result, std::unique_ptr<Bundle> resultData) :
|
||||
result(result),
|
||||
resultData(std::move(resultData)) {}
|
||||
};
|
||||
|
||||
std::unique_ptr<ResultHolder> resultHolder;
|
||||
|
||||
public:
|
||||
|
||||
App() = default;
|
||||
virtual ~App() = default;
|
||||
|
||||
virtual void onCreate(AppContext& appContext) {}
|
||||
virtual void onDestroy(AppContext& appContext) {}
|
||||
virtual void onShow(AppContext& appContext, lv_obj_t* parent) {}
|
||||
virtual void onHide(AppContext& appContext) {}
|
||||
virtual void onResult(AppContext& appContext, Result result, std::unique_ptr<Bundle> _Nullable resultData) {}
|
||||
|
||||
Mutex& getMutex() { return mutex; }
|
||||
|
||||
bool hasResult() const { return resultHolder != nullptr; }
|
||||
|
||||
void setResult(Result result, std::unique_ptr<Bundle> resultData = nullptr) {
|
||||
auto lockable = getMutex().scoped();
|
||||
lockable->lock(portMAX_DELAY);
|
||||
resultHolder = std::make_unique<ResultHolder>(result, std::move(resultData));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by system to extract the result data when this application is finished.
|
||||
* Note that this removes the data from the class!
|
||||
*/
|
||||
bool moveResult(Result& outResult, std::unique_ptr<Bundle>& outBundle) {
|
||||
auto lockable = getMutex().scoped();
|
||||
lockable->lock(portMAX_DELAY);
|
||||
|
||||
if (resultHolder != nullptr) {
|
||||
outResult = resultHolder->result;
|
||||
outBundle = std::move(resultHolder->resultData);
|
||||
resultHolder = nullptr;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
std::shared_ptr<App> create() { return std::shared_ptr<T>(new T); }
|
||||
|
||||
/**
|
||||
* @brief Start an app
|
||||
* @param[in] id application name or id
|
||||
* @param[in] parameters optional parameters to pass onto the application
|
||||
*/
|
||||
void start(const std::string& id, std::shared_ptr<const Bundle> _Nullable parameters = nullptr);
|
||||
|
||||
/** @brief Stop the currently showing app. Show the previous app if any app was still running. */
|
||||
void stop();
|
||||
|
||||
/** @return the currently running app context (it is only ever null before the splash screen is shown) */
|
||||
std::shared_ptr<app::AppContext> _Nullable getCurrentAppContext();
|
||||
|
||||
/** @return the currently running app (it is only ever null before the splash screen is shown) */
|
||||
std::shared_ptr<app::App> _Nullable getCurrentApp();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
// Forward declarations
|
||||
class App;
|
||||
class Paths;
|
||||
struct AppManifest;
|
||||
enum class Result;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
bool showStatusbar : 1;
|
||||
};
|
||||
unsigned char flags;
|
||||
} Flags;
|
||||
|
||||
/**
|
||||
* The public representation of an application instance.
|
||||
* @warning Do not store references or pointers to these! You can retrieve them via the service registry.
|
||||
*/
|
||||
class AppContext {
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~AppContext() = default;
|
||||
|
||||
public:
|
||||
|
||||
virtual const AppManifest& getManifest() const = 0;
|
||||
virtual std::shared_ptr<const Bundle> getParameters() const = 0;
|
||||
virtual std::unique_ptr<Paths> getPaths() const = 0;
|
||||
|
||||
virtual std::shared_ptr<App> getApp() const = 0;
|
||||
};
|
||||
|
||||
class Paths {
|
||||
|
||||
public:
|
||||
|
||||
Paths() = default;
|
||||
virtual ~Paths() = default;
|
||||
|
||||
/**
|
||||
* Returns the directory path for the data location for an app.
|
||||
* The data directory is intended to survive OS upgrades.
|
||||
* The path will not end with a "/".
|
||||
*/
|
||||
virtual std::string getDataDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the data location for an app.
|
||||
* The data directory is intended to survive OS upgrades.
|
||||
* Configuration data should be stored here.
|
||||
* @param[in] childPath the path without a "/" prefix
|
||||
*/
|
||||
virtual std::string getDataPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getDataPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getDataPathLvgl(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* Returns the directory path for the system location for an app.
|
||||
* The system directory is not intended to survive OS upgrades.
|
||||
* You should not store configuration data here.
|
||||
* The path will not end with a "/".
|
||||
* This is mainly used for core apps (system/boot/settings type).
|
||||
*/
|
||||
virtual std::string getSystemDirectory() const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemDirectory(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemDirectoryLvgl() const = 0;
|
||||
|
||||
/**
|
||||
* Returns the full path for an entry inside the system location for an app.
|
||||
* The data directory is not intended to survive OS upgrades.
|
||||
* You should not store configuration data here.
|
||||
* This is mainly used for core apps (system/boot/settings type).
|
||||
* @param[in] childPath the path without a "/" prefix
|
||||
*/
|
||||
virtual std::string getSystemPath(const std::string& childPath) const = 0;
|
||||
|
||||
/**
|
||||
* @see getSystemPath(), but with LVGL prefix.
|
||||
*/
|
||||
virtual std::string getSystemPathLvgl(const std::string& childPath) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/ManifestRegistry.h"
|
||||
|
||||
#include <Tactility/CoreDefines.h>
|
||||
#include <Tactility/Bundle.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
// Forward declarations
|
||||
typedef struct _lv_obj_t lv_obj_t;
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
class App;
|
||||
class AppContext;
|
||||
|
||||
/** Application types */
|
||||
enum class Type {
|
||||
/** Boot screen, shown before desktop is launched. */
|
||||
Boot,
|
||||
/** A launcher app sits at the root of the app stack after the boot splash is finished */
|
||||
Launcher,
|
||||
/** Apps that generally aren't started from the desktop (e.g. image viewer) */
|
||||
Hidden,
|
||||
/** Standard apps, provided by the system. */
|
||||
System,
|
||||
/** The apps that are launched/shown by the Settings app. The Settings app itself is of type AppTypeSystem. */
|
||||
Settings,
|
||||
/** User-provided apps. */
|
||||
User
|
||||
};
|
||||
|
||||
/** Result status code for application result callback. */
|
||||
enum class Result {
|
||||
Ok = 0U,
|
||||
Cancelled = 1U,
|
||||
Error = 2U
|
||||
};
|
||||
|
||||
class Location {
|
||||
|
||||
private:
|
||||
|
||||
std::string path;
|
||||
Location() = default;
|
||||
explicit Location(const std::string& path) : path(path) {}
|
||||
|
||||
public:
|
||||
|
||||
static Location internal() { return {}; }
|
||||
|
||||
static Location external(const std::string& path) {
|
||||
return Location(path);
|
||||
}
|
||||
|
||||
bool isInternal() const { return path.empty(); }
|
||||
bool isExternal() const { return !path.empty(); }
|
||||
const std::string& getPath() const { return path; }
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<App>(*CreateApp)();
|
||||
|
||||
struct AppManifest {
|
||||
/** The identifier by which the app is launched by the system and other apps. */
|
||||
std::string id = {};
|
||||
|
||||
/** The user-readable name of the app. Used in UI. */
|
||||
std::string name = {};
|
||||
|
||||
/** Optional icon. */
|
||||
std::string icon = {};
|
||||
|
||||
/** App type affects launch behaviour. */
|
||||
Type type = Type::User;
|
||||
|
||||
/** Where the app is located */
|
||||
Location location = Location::internal();
|
||||
|
||||
/** Create the instance of the app */
|
||||
CreateApp createApp = nullptr;
|
||||
};
|
||||
|
||||
struct {
|
||||
bool operator()(const std::shared_ptr<AppManifest>& left, const std::shared_ptr<AppManifest>& right) const { return left->name < right->name; }
|
||||
} SortAppManifestByName;
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include "AppManifest.h"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
typedef void* (*CreateData)();
|
||||
typedef void (*DestroyData)(void* data);
|
||||
typedef void (*OnCreate)(void* appContext, void* _Nullable data);
|
||||
typedef void (*OnDestroy)(void* appContext, void* _Nullable data);
|
||||
typedef void (*OnShow)(void* appContext, void* _Nullable data, lv_obj_t* parent);
|
||||
typedef void (*OnHide)(void* appContext, void* _Nullable data);
|
||||
typedef void (*OnResult)(void* appContext, void* _Nullable data, Result result, Bundle* resultData);
|
||||
|
||||
void setElfAppManifest(
|
||||
const char* name,
|
||||
const char* _Nullable icon,
|
||||
CreateData _Nullable createData,
|
||||
DestroyData _Nullable destroyData,
|
||||
OnCreate _Nullable onCreate,
|
||||
OnDestroy _Nullable onDestroy,
|
||||
OnShow _Nullable onShow,
|
||||
OnHide _Nullable onHide,
|
||||
OnResult _Nullable onResult
|
||||
);
|
||||
|
||||
/**
|
||||
* @return the app ID based on the executable's file path.
|
||||
*/
|
||||
std::string getElfAppId(const std::string& filePath);
|
||||
|
||||
/**
|
||||
* @return true when registration was done, false when app was already registered
|
||||
*/
|
||||
bool registerElfApp(const std::string& filePath);
|
||||
|
||||
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest);
|
||||
|
||||
}
|
||||
#endif // ESP_PLATFORM
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "App.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
struct AppManifest;
|
||||
|
||||
/** Register an application with its manifest */
|
||||
void addApp(const AppManifest& manifest);
|
||||
|
||||
/** Find an application manifest by its id
|
||||
* @param[in] id the manifest id
|
||||
* @return the application manifest if it was found
|
||||
*/
|
||||
_Nullable std::shared_ptr<AppManifest> findAppById(const std::string& id);
|
||||
|
||||
/** @return a list of all registered apps. This includes user and system apps. */
|
||||
std::vector<std::shared_ptr<AppManifest>> getApps();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* Start the app by its ID and provide:
|
||||
* - a title
|
||||
* - a text
|
||||
* - 0, 1 or more buttons
|
||||
*/
|
||||
namespace tt::app::alertdialog {
|
||||
|
||||
/**
|
||||
* Show a dialog with the provided title, message and 0, 1 or more buttons.
|
||||
* @param[in] title the title to show in the toolbar
|
||||
* @param[in] message the message to display
|
||||
* @param[in] buttonLabels the buttons to show
|
||||
*/
|
||||
void start(const std::string& title, const std::string& message, const std::vector<std::string>& buttonLabels);
|
||||
|
||||
/**
|
||||
* Get the index of the button that the user selected.
|
||||
*
|
||||
* @return a value greater than 0 when a selection was done, or -1 when the app was closed clicking one of the selection buttons.
|
||||
*/
|
||||
int32_t getResultIndex(const Bundle& bundle);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <src/display/lv_display.h>
|
||||
|
||||
namespace tt::app::display {
|
||||
|
||||
void setBacklightDuty(uint8_t value);
|
||||
uint8_t getBacklightDuty();
|
||||
void setRotation(lv_display_rotation_t rotation);
|
||||
lv_display_rotation_t getRotation();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/files/View.h"
|
||||
#include "app/files/State.h"
|
||||
#include "app/AppManifest.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <dirent.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
void start();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::app::imageviewer {
|
||||
|
||||
void start(const std::string& file);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* Start the app by its ID and provide:
|
||||
* - a title
|
||||
* - a text
|
||||
*/
|
||||
namespace tt::app::inputdialog {
|
||||
|
||||
void start(const std::string& title, const std::string& message, const std::string& prefilled = "");
|
||||
|
||||
/**
|
||||
* @return the text that was in the field when OK was pressed, or otherwise empty string
|
||||
*/
|
||||
std::string getResult(const Bundle& bundle);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* Start the app by its ID and provide:
|
||||
* - an optional title
|
||||
* - 2 or more items
|
||||
*
|
||||
* If you provide 0 items, the app will auto-close.
|
||||
* If you provide 1 item, the app will auto-close with result index 0
|
||||
*/
|
||||
namespace tt::app::selectiondialog {
|
||||
|
||||
void start(const std::string& title, const std::vector<std::string>& items);
|
||||
|
||||
/**
|
||||
* Get the index of the item that the user selected.
|
||||
*
|
||||
* @return a value greater than 0 when a selection was done, or -1 when the app was closed without selecting an item.
|
||||
*/
|
||||
int32_t getResultIndex(const Bundle& bundle);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::app::textviewer {
|
||||
|
||||
void start(const std::string& file);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
void start();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
bool label_set_text_file(lv_obj_t* label, const char* filepath);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/Display.h>
|
||||
|
||||
namespace tt::lvgl {
|
||||
hal::Display* getDisplay();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* This code relates to the hardware keyboard support also known as "keypads" in LVGL.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
/**
|
||||
* @return true if LVGL is configured with a keypad
|
||||
*/
|
||||
bool keypad_is_available();
|
||||
|
||||
/**
|
||||
* Set the keypad.
|
||||
* @param device the keypad device
|
||||
*/
|
||||
void keypad_set_indev(lv_indev_t* device);
|
||||
|
||||
/**
|
||||
* Activate the keypad for a widget group.
|
||||
* @param group
|
||||
*/
|
||||
void keypad_activate(lv_group_t* group);
|
||||
|
||||
/**
|
||||
* Deactivate the keypad for the current widget group (if any).
|
||||
* You don't have to call this after calling _activate() because widget
|
||||
* cleanup automatically removes itself from the group it belongs to.
|
||||
*/
|
||||
void keypad_deactivate();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Lockable.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
/**
|
||||
* LVGL locking function
|
||||
* @param[in] timeoutMillis timeout in milliseconds. waits forever when 0 is passed.
|
||||
* @warning this works with milliseconds, as opposed to every other FreeRTOS function that works in ticks!
|
||||
* @warning when passing zero, we wait forever, as this is the default behaviour for esp_lvgl_port, and we want it to remain consistent
|
||||
*/
|
||||
typedef bool (*LvglLock)(uint32_t timeoutMillis);
|
||||
typedef void (*LvglUnlock)();
|
||||
|
||||
void syncSet(LvglLock lock, LvglUnlock unlock);
|
||||
|
||||
/**
|
||||
* LVGL locking function
|
||||
* @param[in] timeout as ticks
|
||||
* @warning when passing zero, we wait forever, as this is the default behaviour for esp_lvgl_port, and we want it to remain consistent
|
||||
*/
|
||||
bool lock(TickType_t timeout);
|
||||
void unlock();
|
||||
|
||||
std::shared_ptr<Lockable> getLvglSyncLockable();
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
/**
|
||||
* Create the Tactility spinner widget
|
||||
* @param parent pointer to an object, it will be the parent of the new spinner.
|
||||
* @return the created spinner
|
||||
*/
|
||||
lv_obj_t* spinner_create(lv_obj_t* parent);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/AppContext.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
#define STATUSBAR_ICON_LIMIT 8
|
||||
#define STATUSBAR_ICON_SIZE 20
|
||||
#define STATUSBAR_HEIGHT (STATUSBAR_ICON_SIZE + 4) // 4 extra pixels for border and outline
|
||||
|
||||
lv_obj_t* statusbar_create(lv_obj_t* parent);
|
||||
int8_t statusbar_icon_add(const std::string& image);
|
||||
int8_t statusbar_icon_add();
|
||||
void statusbar_icon_remove(int8_t id);
|
||||
void statusbar_icon_set_image(int8_t id, const std::string& image);
|
||||
void statusbar_icon_set_visibility(int8_t id, bool visible);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
void obj_set_style_bg_blacken(lv_obj_t* obj);
|
||||
void obj_set_style_bg_invisible(lv_obj_t* obj);
|
||||
void obj_set_style_no_padding(lv_obj_t* obj);
|
||||
|
||||
/**
|
||||
* This is to create automatic padding depending on the screen size.
|
||||
* The larger the screen, the more padding it gets.
|
||||
* TODO: It currently only applies a single basic padding, but will be improved later.
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
void obj_set_style_auto_padding(lv_obj_t* obj);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "../app/AppContext.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
#define TOOLBAR_HEIGHT 40
|
||||
#define TOOLBAR_TITLE_FONT_HEIGHT 18
|
||||
#define TOOLBAR_ACTION_LIMIT 4
|
||||
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title);
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, const app::AppContext& app);
|
||||
void toolbar_set_title(lv_obj_t* obj, const std::string& title);
|
||||
void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
|
||||
lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
|
||||
lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj);
|
||||
lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/AppInstance.h"
|
||||
#include "Tactility/app/AppContext.h"
|
||||
|
||||
namespace tt::service::gui {
|
||||
|
||||
typedef struct Gui Gui;
|
||||
|
||||
/**
|
||||
* Set the app viewport in the gui state and request the gui to draw it.
|
||||
* @param[in] app
|
||||
*/
|
||||
void showApp(std::shared_ptr<app::AppContext> app);
|
||||
|
||||
/**
|
||||
* Hide the current app's viewport.
|
||||
* Does not request a re-draw because after hiding the current app,
|
||||
* we always show the previous app, and there is always at least 1 app running.
|
||||
*/
|
||||
void hideApp();
|
||||
|
||||
/**
|
||||
* Show the on-screen keyboard.
|
||||
* @param[in] textarea the textarea to focus the input for
|
||||
*/
|
||||
void keyboardShow(lv_obj_t* textarea);
|
||||
|
||||
/**
|
||||
* Hide the on-screen keyboard.
|
||||
* Has no effect when the keyboard is not visible.
|
||||
*/
|
||||
void keyboardHide();
|
||||
|
||||
/**
|
||||
* The on-screen keyboard is only shown when both of these conditions are true:
|
||||
* - there is no hardware keyboard
|
||||
* - TT_CONFIG_FORCE_ONSCREEN_KEYBOARD is set to true in tactility_config.h
|
||||
* @return if we should show a on-screen keyboard for text input inside our apps
|
||||
*/
|
||||
bool keyboardIsEnabled();
|
||||
|
||||
/**
|
||||
* Glue code for the on-screen keyboard and the hardware keyboard:
|
||||
* - Attach automatic hide/show parameters for the on-screen keyboard.
|
||||
* - Registers the textarea to the default lv_group_t for hardware keyboards.
|
||||
* @param[in] textarea
|
||||
*/
|
||||
void keyboardAddTextArea(lv_obj_t* textarea);
|
||||
|
||||
} // namespace
|
||||
@@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace tt::service::loader {
|
||||
|
||||
// region LoaderEvent for PubSub
|
||||
|
||||
typedef enum {
|
||||
LoaderEventTypeApplicationStarted,
|
||||
LoaderEventTypeApplicationShowing,
|
||||
LoaderEventTypeApplicationHiding,
|
||||
LoaderEventTypeApplicationStopped
|
||||
} LoaderEventType;
|
||||
|
||||
struct LoaderEvent {
|
||||
LoaderEventType type;
|
||||
};
|
||||
|
||||
// endregion LoaderEvent for PubSub
|
||||
|
||||
/**
|
||||
* @brief Start an app
|
||||
* @param[in] id application name or id
|
||||
* @param[in] parameters optional parameters to pass onto the application
|
||||
*/
|
||||
void startApp(const std::string& id, std::shared_ptr<const Bundle> _Nullable parameters = nullptr);
|
||||
|
||||
/** @brief Stop the currently showing app. Show the previous app if any app was still running. */
|
||||
void stopApp();
|
||||
|
||||
/** @return the currently running app context (it is only ever null before the splash screen is shown) */
|
||||
std::shared_ptr<app::AppContext> _Nullable getCurrentAppContext();
|
||||
|
||||
/** @return the currently running app (it is only ever null before the splash screen is shown) */
|
||||
std::shared_ptr<app::App> _Nullable getCurrentApp();
|
||||
|
||||
/**
|
||||
* @brief PubSub for LoaderEvent
|
||||
*/
|
||||
std::shared_ptr<PubSub> getPubsub();
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user