Luna/wind/Window.cpp

38 lines
725 B
C++

#include "Window.h"
#include <luna/Utf8.h>
#include <os/File.h>
#include <sys/mman.h>
#include <ui/Font.h>
#include <ui/Image.h>
LinkedList<Window> g_windows;
void Window::draw(ui::Canvas& screen)
{
dirty = false;
auto window = screen.subcanvas(surface);
window.copy(pixels, surface.width);
}
void Window::focus()
{
// Bring the window to the front of the list.
g_windows.remove(this);
g_windows.append(this);
}
Window::Window(ui::Rect r, String&& n) : surface(r), name(move(n))
{
auto font = ui::Font::default_font();
titlebar = ui::Rect { 0, 0, 0, 0 };
g_windows.append(this);
}
Window::~Window()
{
usize size = surface.width * surface.height * 4;
munmap(pixels, size);
}