Luna/gui/wind/Window.cpp

38 lines
756 B
C++
Raw Permalink Normal View History

2023-08-03 15:38:49 +00:00
#include "Window.h"
#include "Layer.h"
#include <luna/Utf8.h>
#include <os/File.h>
#include <sys/mman.h>
#include <ui/Font.h>
#include <ui/Image.h>
2023-08-03 15:38:49 +00:00
void Window::draw(ui::Canvas& screen)
{
dirty = false;
auto window = screen.subcanvas(surface);
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.
layer->windows.remove(this);
layer->windows.append(this);
2023-08-03 15:38:49 +00:00
}
Window::Window(ui::Rect r, RefString&& n) : surface(r), name(move(n))
2023-08-03 15:38:49 +00:00
{
auto font = ui::Font::default_font();
titlebar = ui::Rect { 0, 0, 0, 0 };
l_global.windows.append(this);
layer = &l_global;
2023-08-03 15:38:49 +00:00
}
2023-08-14 16:15:29 +00:00
Window::~Window()
{
usize size = surface.width * surface.height * 4;
munmap(pixels, size);
}