2023-08-03 15:38:49 +00:00
|
|
|
#include "Window.h"
|
2023-08-04 14:08:58 +00:00
|
|
|
#include <luna/Utf8.h>
|
|
|
|
#include <os/File.h>
|
2023-08-14 18:08:05 +00:00
|
|
|
#include <sys/mman.h>
|
2023-08-04 14:08:58 +00:00
|
|
|
#include <ui/Font.h>
|
2023-08-04 19:17:50 +00:00
|
|
|
#include <ui/Image.h>
|
2023-08-03 15:38:49 +00:00
|
|
|
|
|
|
|
LinkedList<Window> g_windows;
|
|
|
|
|
|
|
|
void Window::draw(ui::Canvas& screen)
|
|
|
|
{
|
2023-08-14 18:08:05 +00:00
|
|
|
dirty = false;
|
|
|
|
|
2023-08-04 14:08:58 +00:00
|
|
|
auto window = screen.subcanvas(surface);
|
2024-03-31 11:38:39 +00:00
|
|
|
window.copy(pixels, surface.width);
|
2023-08-03 15:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Window::focus()
|
|
|
|
{
|
|
|
|
// Bring the window to the front of the list.
|
|
|
|
g_windows.remove(this);
|
|
|
|
g_windows.append(this);
|
|
|
|
}
|
|
|
|
|
2023-12-27 11:56:40 +00:00
|
|
|
Window::Window(ui::Rect r, String&& n) : surface(r), name(move(n))
|
2023-08-03 15:38:49 +00:00
|
|
|
{
|
2023-08-04 14:08:58 +00:00
|
|
|
auto font = ui::Font::default_font();
|
2023-12-27 11:56:40 +00:00
|
|
|
titlebar = ui::Rect { 0, 0, 0, 0 };
|
2023-08-03 15:38:49 +00:00
|
|
|
g_windows.append(this);
|
|
|
|
}
|
2023-08-14 16:15:29 +00:00
|
|
|
|
2023-08-14 18:08:05 +00:00
|
|
|
Window::~Window()
|
|
|
|
{
|
2023-12-27 11:56:40 +00:00
|
|
|
usize size = surface.width * surface.height * 4;
|
2023-08-14 18:08:05 +00:00
|
|
|
|
|
|
|
munmap(pixels, size);
|
|
|
|
}
|