mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:28:13 +00:00
Start adding a Window class.
This commit is contained in:
parent
bd6172e3c7
commit
415c4b90c5
12 changed files with 159 additions and 55 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "WindowManager.h"
|
||||
#include "Painter.h"
|
||||
#include "Widget.h"
|
||||
#include "Window.h"
|
||||
#include "AbstractScreen.h"
|
||||
|
||||
WindowManager& WindowManager::the()
|
||||
|
@ -19,44 +20,43 @@ WindowManager::~WindowManager()
|
|||
|
||||
void WindowManager::paintWindowFrames()
|
||||
{
|
||||
for (auto* widget : m_windows) {
|
||||
paintWindowFrame(*widget);
|
||||
}
|
||||
for (auto* window : m_windows)
|
||||
paintWindowFrame(*window);
|
||||
}
|
||||
|
||||
void WindowManager::paintWindowFrame(Widget& widget)
|
||||
void WindowManager::paintWindowFrame(Window& window)
|
||||
{
|
||||
Painter p(*AbstractScreen::the().rootWidget());
|
||||
|
||||
printf("WM: paintWindowFrame %s{%p}, rect: %d,%d %dx%d\n", widget.className(), &widget, widget.rect().x(), widget.rect().y(), widget.rect().width(), widget.rect().height());
|
||||
printf("WM: paintWindowFrame {%p}, rect: %d,%d %dx%d\n", &window, window.rect().x(), window.rect().y(), window.rect().width(), window.rect().height());
|
||||
|
||||
static const int windowFrameWidth = 2;
|
||||
static const int windowTitleBarHeight = 16;
|
||||
|
||||
Rect topRect {
|
||||
widget.x() - windowFrameWidth,
|
||||
widget.y() - windowTitleBarHeight - windowFrameWidth,
|
||||
widget.width() + windowFrameWidth * 2,
|
||||
window.x() - windowFrameWidth,
|
||||
window.y() - windowTitleBarHeight - windowFrameWidth,
|
||||
window.width() + windowFrameWidth * 2,
|
||||
windowTitleBarHeight + windowFrameWidth };
|
||||
|
||||
Rect bottomRect {
|
||||
widget.x() - windowFrameWidth,
|
||||
widget.y() + widget.height(),
|
||||
widget.width() + windowFrameWidth * 2,
|
||||
window.x() - windowFrameWidth,
|
||||
window.y() + window.height(),
|
||||
window.width() + windowFrameWidth * 2,
|
||||
windowFrameWidth };
|
||||
|
||||
Rect leftRect {
|
||||
widget.x() - windowFrameWidth,
|
||||
widget.y(),
|
||||
window.x() - windowFrameWidth,
|
||||
window.y(),
|
||||
windowFrameWidth,
|
||||
widget.height()
|
||||
window.height()
|
||||
};
|
||||
|
||||
Rect rightRect {
|
||||
widget.x() + widget.width(),
|
||||
widget.y(),
|
||||
window.x() + window.width(),
|
||||
window.y(),
|
||||
windowFrameWidth,
|
||||
widget.height()
|
||||
window.height()
|
||||
};
|
||||
|
||||
static const Color windowBorderColor(0x00, 0x00, 0x80);
|
||||
|
@ -66,7 +66,7 @@ void WindowManager::paintWindowFrame(Widget& widget)
|
|||
topRect.x() - 1,
|
||||
topRect.y() - 1,
|
||||
topRect.width() + 2,
|
||||
windowFrameWidth + windowTitleBarHeight + widget.height() + 4
|
||||
windowFrameWidth + windowTitleBarHeight + window.rect().height() + 4
|
||||
};
|
||||
p.drawRect(borderRect, Color(255, 255, 255));
|
||||
borderRect.inflate(2, 2);
|
||||
|
@ -77,16 +77,29 @@ void WindowManager::paintWindowFrame(Widget& widget)
|
|||
p.fillRect(leftRect, windowBorderColor);
|
||||
p.fillRect(rightRect, windowBorderColor);
|
||||
|
||||
p.drawText(topRect, widget.windowTitle(), Painter::TextAlignment::Center, windowTitleColor);
|
||||
p.drawText(topRect, window.title(), Painter::TextAlignment::Center, windowTitleColor);
|
||||
}
|
||||
|
||||
void WindowManager::addWindow(Widget& widget)
|
||||
void WindowManager::addWindow(Window& window)
|
||||
{
|
||||
m_windows.set(&widget);
|
||||
m_windows.set(&window);
|
||||
}
|
||||
|
||||
void WindowManager::notifyTitleChanged(Widget&)
|
||||
void WindowManager::notifyTitleChanged(Window& window)
|
||||
{
|
||||
AbstractScreen::the().rootWidget()->update();
|
||||
printf("[WM] ]Window{%p} title set to '%s'\n", &window, window.title().characters());
|
||||
}
|
||||
|
||||
void WindowManager::notifyRectChanged(Window& window, const Rect& oldRect, const Rect& newRect)
|
||||
{
|
||||
printf("[WM] Window %p rect changed (%d,%d %dx%d) -> (%d,%d %dx%d)\n",
|
||||
&window,
|
||||
oldRect.x(),
|
||||
oldRect.y(),
|
||||
oldRect.width(),
|
||||
oldRect.height(),
|
||||
newRect.x(),
|
||||
newRect.y(),
|
||||
newRect.width(),
|
||||
newRect.height());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue