You can now add stuff to show in a window

This commit is contained in:
Rasmus Rasmussen 2026-01-06 19:06:47 +01:00
parent af36f344a5
commit 36dd179def
5 changed files with 27 additions and 33 deletions

View File

@ -13,15 +13,28 @@ public:
void run() override { void run() override {
Serial.println("Counter program started!"); Serial.println("Counter program started!");
WindowContentText text;
text.x = _window->x + 10;
text.y = _window->y + 50;
_window->window_content_text.push_back(text);
while (_running) { while (_running) {
counter++; counter++;
Serial.printf("Counter: %d\n", counter); Serial.printf("Counter: %d\n", counter);
// You can modify the window title // You can modify the window title
if (_window) { if (_window) {
_window->title = "Counter: " + std::to_string(counter); if (!_window->minimized) {
if (!_window->minimized) _window->title = "Counter: " + std::to_string(counter);
for (int i = 0; i < _window->window_content_text.size(); i++) {
_window->window_content_text[i].text = std::to_string(counter);
}
_display_state->update_display.store(true); _display_state->update_display.store(true);
}
} }
vTaskDelay(pdMS_TO_TICKS(1000)); vTaskDelay(pdMS_TO_TICKS(1000));

View File

@ -46,6 +46,12 @@ struct WindowDecoration {
WindowAction action; WindowAction action;
}; };
struct WindowContentText {
int x;
int y;
std::string text;
};
struct Window { struct Window {
int id; int id;
int x; int x;
@ -58,6 +64,7 @@ struct Window {
bool minimized; bool minimized;
std::string title; std::string title;
std::vector<WindowDecoration> window_decorations; std::vector<WindowDecoration> window_decorations;
std::vector<WindowContentText> window_content_text;
}; };
// Base Program class - all programs inherit from this // Base Program class - all programs inherit from this

View File

@ -1,22 +0,0 @@
#include "program_registry.h"
#include <Arduino.h>
void InstalledProgram::do_stuff() {
Serial.println("lol");
}
void InstalledProgram::do_some_other_stuff() {
Serial.println("ASDDSAASDASD");
}
void InstalledProgram::lol() {
Serial.println("ffffrf");
}
void InstalledProgram::omagelol() {
Serial.println("11111");
}
void InstalledProgram::sheeesh() {
Serial.println("44444");
}

View File

@ -1,9 +0,0 @@
#pragma once
struct InstalledProgram {
void do_stuff();
void do_some_other_stuff();
void lol();
void omagelol();
void sheeesh();
};

View File

@ -224,6 +224,10 @@ void Shell::draw_window(Window window) {
// Window content // Window content
tft->draw_box(window.x + 3, window.y + 35, window.width - 6, window.height - 38, COL_WHITE); tft->draw_box(window.x + 3, window.y + 35, window.width - 6, window.height - 38, COL_WHITE);
for (WindowContentText text : window.window_content_text) {
tft->draw_text(text.x, text.y, text.text, COL_BLACK);
}
} }
// ======= Desktop ======= // ======= Desktop =======
@ -368,6 +372,7 @@ int Shell::handle_desktop_click(CLICK_EVENT event) {
win->focused = true; win->focused = true;
win->minimized = false; win->minimized = false;
win->title = item.name; win->title = item.name;
win->window_content_text = {};
// Spawn program using the program_class // Spawn program using the program_class
bool result = _system_manager->spawn_program(win, item.program_class); bool result = _system_manager->spawn_program(win, item.program_class);