#pragma once #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "GLOBALS.h" #include #include #include #include "tft_handler.h" // Forward declarations class Shell; class TFT_Handler; struct TaskBarItem { short int id; short int place_x; short int place_y; short int width; short int height; short int offset_x; bool focused; std::string name; }; struct DesktopItem { short int id; short int place_x; short int place_y; short int icon_size_x; short 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 { short int x_offset; short int y_offset; short int width; short int height; WindowAction action; }; struct WindowContentText { short int x; short int y; short int size; std::string text; }; struct Window { short int id; short int x; short int y; short int width; short int height; short int background_color; short int foreground_color; bool focused; bool minimized; std::string title; std::vector window_decorations; std::vector window_content_text; bool hasSprite = false; LGFX_Sprite sprite; // Constructor that initializes sprite with display pointer Window(LGFX* display) : sprite(display) { id = 0; x = 0; y = 0; width = 0; height = 0; background_color = 0; foreground_color = 0; focused = false; minimized = false; } }; // 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; short int _id; std::string _name; bool _running; CALIBRATION_IDLE _calibration_idle; static void task_wrapper(void* pvParameters); public: Program(); virtual ~Program(); // Initialize the program with its window and shell reference void init(short int id, const std::string& name, Window* window, Shell* shell, TFT_Handler* tft, DISPLAY_STATE* display_state, CALIBRATION_IDLE calibration_idle); // 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; } };