PocketPutr/Desktop_Test/desktop_hander.cpp
2025-12-14 13:00:01 +01:00

59 lines
1.2 KiB
C++

#include "desktop_hander.h"
#include "tft_handler.h"
void Desktop_Hander::init(TFT_Handler* th) {
tft = th;
for (int i; i < 5; i++) {
Desktop_Item di = {
.id = i,
.place_x = i * 50 + 1,
.place_y = 10,
.icon_size_x = 45,
.icon_size_y = 50,
};
items.push_back(di);
}
re_draw_desktop();
}
void Desktop_Hander::re_draw_desktop() {
draw_background(0x0410);
draw_task_bar(0xbdf7);
for (const auto& item : items) {
draw_desktop_Item(item);
}
}
void Desktop_Hander::draw_background(int color) {
tft->fill_screen(color);
}
void Desktop_Hander::draw_task_bar(int color) {
// bar
tft->draw_box(0, 293, 480, 40, color);
tft->draw_line(0, 294, 480, 294, 0xffff);
// Outer shadow
tft->draw_box(5, 297, 53, 21, 0x0000);
// Inner shadow
tft->draw_box(6, 298, 51, 19, 0x8410);
// Highlight
tft->draw_box(5, 297, 51, 19, 0xffff);
// Button
tft->draw_box(6, 298, 50, 18, color);
}
void Desktop_Hander::draw_desktop_Item(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);
}
int Desktop_Hander::click_event(CLICK_EVENT event) {
return 0;
}