Holy shit it actually worked lol
This commit is contained in:
parent
f56a7fa9f2
commit
526ba71d57
@ -67,7 +67,7 @@ void setup() {
|
|||||||
.y_offset = 5,
|
.y_offset = 5,
|
||||||
.width = 25,
|
.width = 25,
|
||||||
.height = 25,
|
.height = 25,
|
||||||
.action = WindowAction::CLOSE,
|
.action = WindowAction::MINIMIZE,
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<WindowDecoration> wdec;
|
std::vector<WindowDecoration> wdec;
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#include "window.h"
|
||||||
#include "GLOBALS.h"
|
#include "GLOBALS.h"
|
||||||
#include "window_manager.h"
|
#include "window_manager.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -56,11 +57,18 @@ void WindowManager::draw_window(const Window& window) {
|
|||||||
// Decorations
|
// Decorations
|
||||||
tft->draw_box(window.x + 3, window.y + 3, window.width - 6, 30, window.foreground_color);
|
tft->draw_box(window.x + 3, window.y + 3, window.width - 6, 30, window.foreground_color);
|
||||||
|
|
||||||
// Close button
|
|
||||||
tft->draw_box(window.x + 6, window.y + 5, 25, 25, COL_RED);
|
|
||||||
|
|
||||||
|
for (auto it = window.window_decorations.begin(); it != window.window_decorations.end(); ++it) {
|
||||||
|
if (it->action == WindowAction::CLOSE) {
|
||||||
|
// Close button
|
||||||
|
tft->draw_box(window.x + it->x_offset, window.y + it->y_offset, it->height, it->width, COL_RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it->action == WindowAction::MINIMIZE) {
|
||||||
// Minimize button
|
// Minimize button
|
||||||
tft->draw_box(window.x + 6 + 30, window.y + 5, 25, 25, COL_LIGHT_GREY);
|
tft->draw_box(window.x + it->x_offset, window.y + it->y_offset, it->height, it->width, COL_LIGHT_GREY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Window title
|
// Window title
|
||||||
tft->draw_text(window.x + 6 + 65, window.y + 10, window.title.c_str());
|
tft->draw_text(window.x + 6 + 65, window.y + 10, window.title.c_str());
|
||||||
@ -86,10 +94,21 @@ int WindowManager::handle_window_click(const CLICK_EVENT& event) {
|
|||||||
if (event.x >= window.x && event.x <= (window.x + window.width) &&
|
if (event.x >= window.x && event.x <= (window.x + window.width) &&
|
||||||
event.y >= window.y && event.y <= (window.y + window.height)) {
|
event.y >= window.y && event.y <= (window.y + window.height)) {
|
||||||
|
|
||||||
|
Serial.println("lol");
|
||||||
|
|
||||||
|
for (auto it = window.window_decorations.begin(); it != window.window_decorations.end(); ++it) {
|
||||||
|
int x = window.x + it->x_offset;
|
||||||
|
int y = window.y + it->y_offset;
|
||||||
|
Serial.printf("x: %i y: %i\n", x, y);
|
||||||
|
if (event.x >= x && event.x <= (x + it->width) && event.y >= y && event.y <= (y + it->height) && it->action == WindowAction::CLOSE) {
|
||||||
|
Serial.println("lollllll");
|
||||||
|
close_window(window.id);
|
||||||
|
return window.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (window.focused) return -1;
|
if (window.focused) return -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Unfocus all windows
|
// Unfocus all windows
|
||||||
for (auto& win : windows) {
|
for (auto& win : windows) {
|
||||||
win.focused = false;
|
win.focused = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user