From 44a4c2ceba03d16f1f360cd5a573adb548bd01c1 Mon Sep 17 00:00:00 2001 From: rasmus Date: Sat, 17 Jan 2026 11:13:34 +0100 Subject: [PATCH] Works even more now --- Desktop_Test/example_programs.h | 13 +++++++------ Desktop_Test/tft_handler.cpp | 6 ++++++ Desktop_Test/tft_handler.h | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Desktop_Test/example_programs.h b/Desktop_Test/example_programs.h index 12181f8..b7109e5 100644 --- a/Desktop_Test/example_programs.h +++ b/Desktop_Test/example_programs.h @@ -69,7 +69,12 @@ public: } if (text.selected && event.event == CLICK_EVENTS::KEYBOARD) { + if ((text.x + text.width) >= (_window->x + _window->width)) { + text.text += "\n"; + Serial.println("Aight"); + } text.text += event.character; + _tft->get_text_bounds(text.text, text.size, text.width, text.height); } } } @@ -90,15 +95,11 @@ public: text.selected = false; text.text = "asddsa"; + _tft->get_text_bounds(text.text, text.size, text.width, text.height); + _window->window_content_text.push_back(text); while (_running) { - for (WindowContentText text : _window->window_content_text) { - if (text.selected) { - - } - } - vTaskDelay(pdMS_TO_TICKS(1)); } } diff --git a/Desktop_Test/tft_handler.cpp b/Desktop_Test/tft_handler.cpp index 26637fe..0382120 100644 --- a/Desktop_Test/tft_handler.cpp +++ b/Desktop_Test/tft_handler.cpp @@ -58,4 +58,10 @@ void TFT_Handler::fill_screen(short color) { void TFT_Handler::push_sprite() { sprite.pushSprite(0, 0); +} + +void TFT_Handler::get_text_bounds(const std::string& str, short size, short& width, short& height) { + sprite.setTextSize(size); + width = sprite.textWidth(str.c_str()); + height = sprite.fontHeight() * size; } \ No newline at end of file diff --git a/Desktop_Test/tft_handler.h b/Desktop_Test/tft_handler.h index d1882b8..9fb77bf 100644 --- a/Desktop_Test/tft_handler.h +++ b/Desktop_Test/tft_handler.h @@ -68,4 +68,5 @@ public: void draw_button(short x, short y, short size_x, short size_y, short color, bool pressed, std::string str); void fill_screen(short color); void push_sprite(); + void get_text_bounds(const std::string& str, short size, short& width, short& height); };