Temp before making everything either shitty or fucking awesome
This commit is contained in:
parent
740c8e01c1
commit
9206972133
@ -92,13 +92,6 @@ public:
|
||||
void run() override {
|
||||
_window->x += 150;
|
||||
_window->width -= 50;
|
||||
_window->sprite.setPsram(false);
|
||||
_window->sprite.createSprite(10, 10);
|
||||
_window->sprite.setColorDepth(16);
|
||||
_window->sprite.fillScreen(TFT_BLACK);
|
||||
_window->sprite.fillCircle(50, 50, 40, TFT_RED);
|
||||
_window->hasSprite = true;
|
||||
//_window->sprite.pushSprite(0, 0);
|
||||
|
||||
Serial.println("Settings started!");
|
||||
WindowContentText ram_usage;
|
||||
|
||||
@ -68,21 +68,6 @@ struct Window {
|
||||
std::string title;
|
||||
std::vector<WindowDecoration> window_decorations;
|
||||
std::vector<WindowContentText> window_content_text;
|
||||
bool hasSprite = false;
|
||||
LGFX_Sprite sprite;
|
||||
|
||||
// Constructor that initializes sprite with display pointer
|
||||
Window(LGFX* display) : sprite(display) {
|
||||
id = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
background_color = 0;
|
||||
foreground_color = 0;
|
||||
focused = false;
|
||||
minimized = false;
|
||||
}
|
||||
};
|
||||
|
||||
// Base Program class - all programs inherit from this
|
||||
|
||||
@ -139,7 +139,7 @@ void Shell::create_window(Window* window) {
|
||||
display_state->update_display.store(true);
|
||||
}
|
||||
|
||||
void Shell::close_window(int window_id) {
|
||||
void Shell::close_window(short int window_id) {
|
||||
for (auto it = windows.begin(); it != windows.end(); ++it) {
|
||||
if ((*it)->id == window_id) {
|
||||
windows.erase(it);
|
||||
@ -160,7 +160,7 @@ void Shell::close_window(int window_id) {
|
||||
Helpers::recalculate_taskbar(task_bar_items);
|
||||
}
|
||||
|
||||
void Shell::minimize_window(int window_id) {
|
||||
void Shell::minimize_window(short int window_id) {
|
||||
for (auto it = windows.begin(); it != windows.end(); ++it) {
|
||||
for (int i = 0; i < task_bar_items.size(); ++i) {
|
||||
if ((*it)->id == window_id && (*it)->id == task_bar_items[i].id) {
|
||||
@ -229,11 +229,11 @@ void Shell::draw_window(const Window& window) {
|
||||
tft->draw_text(text.x, text.y, text.text, COL_BLACK, text.size);
|
||||
}
|
||||
|
||||
if (window.hasSprite) tft->push_sprite(window.sprite);
|
||||
tft->push_sprite();
|
||||
}
|
||||
|
||||
// ======= Desktop =======
|
||||
void Shell::draw_background(int color) {
|
||||
void Shell::draw_background(short int color) {
|
||||
tft->fill_screen(color);
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ void Shell::draw_desktop_Item(const DesktopItem& desktop_item) {
|
||||
tft->draw_box(desktop_item.place_x, desktop_item.place_y, desktop_item.icon_size_x, desktop_item.icon_size_y, 0x4648);
|
||||
}
|
||||
|
||||
void Shell::draw_task_bar(int color) {
|
||||
void Shell::draw_task_bar(short int color) {
|
||||
// bar
|
||||
tft->draw_box(0, 293, 480, 40, color);
|
||||
tft->draw_line(0, 294, 480, 294, 0xffff);
|
||||
@ -281,7 +281,7 @@ void Shell::draw_start_menu() {
|
||||
|
||||
}
|
||||
|
||||
int Shell::handle_window_click(CLICK_EVENT event) {
|
||||
short int Shell::handle_window_click(CLICK_EVENT event) {
|
||||
// Iterate BACKWARDS - last window is on top
|
||||
for (int i = windows.size() - 1; i >= 0; i--) {
|
||||
Window* window = windows[i];
|
||||
@ -329,7 +329,7 @@ int Shell::handle_window_click(CLICK_EVENT event) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Shell::handle_desktop_click(CLICK_EVENT event) {
|
||||
short int Shell::handle_desktop_click(CLICK_EVENT event) {
|
||||
for (const auto& item : items) {
|
||||
if (event.x >= item.place_x && event.x <= (item.place_x + item.icon_size_x)
|
||||
&& event.y >= item.place_y && event.y <= (item.place_y + item.icon_size_y)) {
|
||||
@ -342,7 +342,7 @@ int Shell::handle_desktop_click(CLICK_EVENT event) {
|
||||
}
|
||||
|
||||
// Create window
|
||||
Window* win = new Window(&tft->tft);
|
||||
Window* win = new Window();
|
||||
|
||||
WindowDecoration close_btn = {
|
||||
.x_offset = 6,
|
||||
@ -390,7 +390,7 @@ int Shell::handle_desktop_click(CLICK_EVENT event) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Shell::handle_taskbar_click(CLICK_EVENT event) {
|
||||
short int Shell::handle_taskbar_click(CLICK_EVENT event) {
|
||||
for (int i = 0; i < task_bar_items.size(); ++i) {
|
||||
if (event.x >= task_bar_items[i].place_x && event.x <= (task_bar_items[i].place_x + task_bar_items[i].width) && event.y >= task_bar_items[i].place_y && event.y <= (task_bar_items[i].place_y + task_bar_items[i].height)) {
|
||||
for (int j = 0; j < windows.size(); ++j) {
|
||||
|
||||
@ -16,9 +16,9 @@ private:
|
||||
|
||||
SystemManager* _system_manager;
|
||||
|
||||
int handle_window_click(CLICK_EVENT event);
|
||||
int handle_desktop_click(CLICK_EVENT event);
|
||||
int handle_taskbar_click(CLICK_EVENT event);
|
||||
short int handle_window_click(CLICK_EVENT event);
|
||||
short int handle_desktop_click(CLICK_EVENT event);
|
||||
short int handle_taskbar_click(CLICK_EVENT event);
|
||||
bool handle_start_button_click(CLICK_EVENT event);
|
||||
|
||||
public:
|
||||
@ -26,13 +26,13 @@ public:
|
||||
|
||||
// ======= Window =======
|
||||
void create_window(Window* window);
|
||||
void close_window(int window_id);
|
||||
void minimize_window(int window_id);
|
||||
void close_window(short int window_id);
|
||||
void minimize_window(short int window_id);
|
||||
void draw_window(const Window& window);
|
||||
|
||||
// ======= Desktop =======
|
||||
void draw_background(int color);
|
||||
void draw_task_bar(int color);
|
||||
void draw_background(short int color);
|
||||
void draw_task_bar(short int color);
|
||||
void draw_start_menu();
|
||||
void draw_desktop_Item(const DesktopItem& desktop_item);
|
||||
|
||||
|
||||
@ -6,7 +6,12 @@ void TFT_Handler::init(DISPLAY_STATE* display_state) {
|
||||
|
||||
tft.setColorDepth(16);
|
||||
tft.init();
|
||||
tft.setRotation(3);
|
||||
tft.fillScreen(0x0000);
|
||||
|
||||
sprite.setColorDepth(16);
|
||||
sprite.setPsram(true);
|
||||
sprite.createSprite(480, 320);
|
||||
}
|
||||
|
||||
void TFT_Handler::start_draw() {
|
||||
@ -18,12 +23,10 @@ void TFT_Handler::end_draw() {
|
||||
}
|
||||
|
||||
void TFT_Handler::draw_box(short int x, short int y, short int size_x, short int size_y, int color) {
|
||||
tft.setRotation(3);
|
||||
tft.fillRect(x, y, size_x, size_y, color);
|
||||
}
|
||||
|
||||
void TFT_Handler::draw_rect(short int x, short int y, short int size_x, short int size_y, short int thickness, int color) {
|
||||
tft.setRotation(3);
|
||||
tft.drawRect(x, y, size_x, size_y, color);
|
||||
}
|
||||
|
||||
@ -41,6 +44,6 @@ void TFT_Handler::fill_screen(int color) {
|
||||
tft.fillScreen(color);
|
||||
}
|
||||
|
||||
void TFT_Handler::push_sprite(LGFX_Sprite sprite) {
|
||||
void TFT_Handler::push_sprite() {
|
||||
sprite.pushSprite(0, 0);
|
||||
}
|
||||
@ -23,8 +23,10 @@ public:
|
||||
cfg.pin_mosi = 11;
|
||||
cfg.pin_dc = 21;
|
||||
cfg.pin_miso = -1;
|
||||
cfg.freq_write = 40000000;
|
||||
cfg.freq_write = 60000000;
|
||||
cfg.freq_read = 16000000;
|
||||
cfg.use_lock = true;
|
||||
cfg.dma_channel = 1;
|
||||
spi.config(cfg); // *** APPLY CONFIG ***
|
||||
}
|
||||
|
||||
@ -53,6 +55,9 @@ class TFT_Handler {
|
||||
public:
|
||||
LGFX tft;
|
||||
DISPLAY_STATE* _display_state;
|
||||
LGFX_Sprite sprite;
|
||||
|
||||
TFT_Handler() : sprite(&tft) {}
|
||||
|
||||
void init(DISPLAY_STATE* display_state);
|
||||
|
||||
@ -64,6 +69,6 @@ public:
|
||||
void draw_line(short int x1, short int y1, short int x2, short int y2, int color);
|
||||
void draw_text(short int x, short int y, const std::string& str, int color, short int size);
|
||||
void fill_screen(int color);
|
||||
void push_sprite(LGFX_Sprite sprite);
|
||||
void push_sprite();
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user