From 987fb1cde9e5b21e6823e4ccc3525c1f4ef1c295 Mon Sep 17 00:00:00 2001 From: rasmus Date: Mon, 15 Dec 2025 19:44:36 +0100 Subject: [PATCH] Temp --- Desktop_Test/Desktop_Test.ino | 2 +- Desktop_Test/desktop_hander.cpp | 25 +++++++++++++++++++------ Desktop_Test/desktop_hander.h | 3 ++- Desktop_Test/input_manager.cpp | 8 ++++---- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Desktop_Test/Desktop_Test.ino b/Desktop_Test/Desktop_Test.ino index 07c1cce..76d3c90 100644 --- a/Desktop_Test/Desktop_Test.ino +++ b/Desktop_Test/Desktop_Test.ino @@ -79,7 +79,7 @@ void setup() { .x = 30, .y = 50, .width = 350, - .height = 250, + .height = 270, .background_color = 0xbdf7, .foreground_color = COL_DARK_BLUE, .focused = true, diff --git a/Desktop_Test/desktop_hander.cpp b/Desktop_Test/desktop_hander.cpp index ab62296..917a552 100644 --- a/Desktop_Test/desktop_hander.cpp +++ b/Desktop_Test/desktop_hander.cpp @@ -55,8 +55,7 @@ void Desktop_Hander::draw_task_bar(int color) { } void Desktop_Hander::draw_desktop_Item(const Desktop_Item& desktop_item) { - tft->draw_box(desktop_item.place_x, desktop_item.place_y, - desktop_item.icon_size_x, desktop_item.icon_size_y, 0x4648); + tft->draw_box(desktop_item.place_x, desktop_item.place_y, desktop_item.icon_size_x, desktop_item.icon_size_y, 0x4648); } void Desktop_Hander::on_click_event(const CLICK_EVENT& event) { @@ -64,10 +63,11 @@ void Desktop_Hander::on_click_event(const CLICK_EVENT& event) { return; } - handle_desktop_click(event); + int id = handle_desktop_click(event); + bool task_bar_clicked = handle_taskbar_click(event); } -void Desktop_Hander::handle_desktop_click(const CLICK_EVENT& event) { +int Desktop_Hander::handle_desktop_click(const CLICK_EVENT& event) { // Check if click is on desktop (not on taskbar or windows) // This is where you'd check if an icon was clicked for (const auto& item : items) { @@ -78,9 +78,22 @@ void Desktop_Hander::handle_desktop_click(const CLICK_EVENT& event) { Serial.print("Desktop item clicked: "); Serial.println(item.id); - + // TODO: Handle icon click (open window, etc.) - break; + return item.id; } } + + return -1; +} + +bool Desktop_Hander::handle_taskbar_click(const CLICK_EVENT& event) { + if (event.x >= 6 && event.x <= (6 + 50) && event.y >= 298 && event.y <= (298 + 18)) { + Serial.println("Taskbar button clicked"); + + // TODO: Handle icon click (open window, etc.) + return true; + } + + return false; } \ No newline at end of file diff --git a/Desktop_Test/desktop_hander.h b/Desktop_Test/desktop_hander.h index ffcde90..f40ab66 100644 --- a/Desktop_Test/desktop_hander.h +++ b/Desktop_Test/desktop_hander.h @@ -11,7 +11,8 @@ private: DISPLAY_STATE* display_state; std::vector items; - void handle_desktop_click(const CLICK_EVENT& event); + int handle_desktop_click(const CLICK_EVENT& event); + bool handle_taskbar_click(const CLICK_EVENT& event); public: void init(TFT_Handler* th, DISPLAY_STATE* ds); diff --git a/Desktop_Test/input_manager.cpp b/Desktop_Test/input_manager.cpp index c76da06..abeee6a 100644 --- a/Desktop_Test/input_manager.cpp +++ b/Desktop_Test/input_manager.cpp @@ -47,22 +47,22 @@ void InputManager::handle_button_press(int buttonIndex) { bool needs_redraw = false; switch(buttonIndex) { - case 0: // Right + case 0: mi.x = (mi.x + 5 > 476) ? 476 : mi.x + 5; needs_redraw = true; break; - case 1: // Down + case 1: mi.y = (mi.y + 5 > 316) ? 316 : mi.y + 5; needs_redraw = true; break; - case 2: // Up + case 2: mi.y = (mi.y - 5 < 0) ? 0 : mi.y - 5; needs_redraw = true; break; - case 3: // Left + case 3: mi.x = (mi.x - 5 < 0) ? 0 : mi.x - 5; needs_redraw = true; break;