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:
|
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++;
|
||||||
@ -19,9 +26,15 @@ public:
|
|||||||
|
|
||||||
// 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));
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
// 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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user