You can now add stuff to show in a window
This commit is contained in:
parent
af36f344a5
commit
36dd179def
@ -12,6 +12,13 @@ private:
|
||||
public:
|
||||
void run() override {
|
||||
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) {
|
||||
counter++;
|
||||
@ -19,9 +26,15 @@ public:
|
||||
|
||||
// You can modify the window title
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
|
||||
@ -46,6 +46,12 @@ struct WindowDecoration {
|
||||
WindowAction action;
|
||||
};
|
||||
|
||||
struct WindowContentText {
|
||||
int x;
|
||||
int y;
|
||||
std::string text;
|
||||
};
|
||||
|
||||
struct Window {
|
||||
int id;
|
||||
int x;
|
||||
@ -58,6 +64,7 @@ struct Window {
|
||||
bool minimized;
|
||||
std::string title;
|
||||
std::vector<WindowDecoration> window_decorations;
|
||||
std::vector<WindowContentText> window_content_text;
|
||||
};
|
||||
|
||||
// Base Program class - all programs inherit from this
|
||||
|
||||
@ -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");
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
struct InstalledProgram {
|
||||
void do_stuff();
|
||||
void do_some_other_stuff();
|
||||
void lol();
|
||||
void omagelol();
|
||||
void sheeesh();
|
||||
};
|
||||
@ -224,6 +224,10 @@ void Shell::draw_window(Window window) {
|
||||
|
||||
// Window content
|
||||
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 =======
|
||||
@ -368,6 +372,7 @@ int Shell::handle_desktop_click(CLICK_EVENT event) {
|
||||
win->focused = true;
|
||||
win->minimized = false;
|
||||
win->title = item.name;
|
||||
win->window_content_text = {};
|
||||
|
||||
// Spawn program using the program_class
|
||||
bool result = _system_manager->spawn_program(win, item.program_class);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user