102 lines
1.9 KiB
C++
102 lines
1.9 KiB
C++
#pragma once
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "GLOBALS.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// Forward declarations
|
|
class Shell;
|
|
class TFT_Handler;
|
|
|
|
struct TaskBarItem {
|
|
int id;
|
|
int place_x;
|
|
int place_y;
|
|
int width;
|
|
int height;
|
|
int offset_x;
|
|
bool focused;
|
|
std::string name;
|
|
};
|
|
|
|
struct DesktopItem {
|
|
int id;
|
|
int place_x;
|
|
int place_y;
|
|
int icon_size_x;
|
|
int icon_size_y;
|
|
std::string name;
|
|
std::string program_class; // Which program class to instantiate
|
|
};
|
|
|
|
enum class WindowAction {
|
|
EXIT = 1,
|
|
FILE = 2,
|
|
HELP = 3,
|
|
MINIMIZE = 4,
|
|
CLOSE = 5,
|
|
};
|
|
|
|
struct WindowDecoration {
|
|
int x_offset;
|
|
int y_offset;
|
|
int width;
|
|
int height;
|
|
WindowAction action;
|
|
};
|
|
|
|
struct WindowContentText {
|
|
int x;
|
|
int y;
|
|
int size;
|
|
std::string text;
|
|
};
|
|
|
|
struct Window {
|
|
int id;
|
|
int x;
|
|
int y;
|
|
int width;
|
|
int height;
|
|
int background_color;
|
|
int foreground_color;
|
|
bool focused;
|
|
bool minimized;
|
|
std::string title;
|
|
std::vector<WindowDecoration> window_decorations;
|
|
std::vector<WindowContentText> window_content_text;
|
|
};
|
|
|
|
// Base Program class - all programs inherit from this
|
|
class Program {
|
|
protected:
|
|
Window* _window;
|
|
Shell* _shell;
|
|
TFT_Handler* _tft;
|
|
DISPLAY_STATE* _display_state;
|
|
TaskHandle_t _task_handle;
|
|
int _id;
|
|
std::string _name;
|
|
bool _running;
|
|
|
|
static void task_wrapper(void* pvParameters);
|
|
|
|
public:
|
|
Program();
|
|
virtual ~Program();
|
|
|
|
// Initialize the program with its window and shell reference
|
|
void init(int id, std::string name, Window* window, Shell* shell, TFT_Handler* tft, DISPLAY_STATE* display_state);
|
|
|
|
// Override this in your specific programs
|
|
virtual void run() = 0;
|
|
|
|
// Called when the program should stop
|
|
virtual void close();
|
|
|
|
// Getters
|
|
int get_id() const { return _id; }
|
|
std::string get_name() const { return _name; }
|
|
Window* get_window() const { return _window; }
|
|
}; |