mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:07:35 +00:00
Tidy up window border rendering a bit.
This commit is contained in:
parent
bb28c31531
commit
783c64916b
3 changed files with 18 additions and 30 deletions
|
@ -24,6 +24,8 @@ Color::Color(NamedColor named)
|
||||||
case Red: rgb = { 255, 0, 0}; break;
|
case Red: rgb = { 255, 0, 0}; break;
|
||||||
case Green: rgb = { 0, 255, 0}; break;
|
case Green: rgb = { 0, 255, 0}; break;
|
||||||
case Blue: rgb = { 0, 0, 255}; break;
|
case Blue: rgb = { 0, 0, 255}; break;
|
||||||
|
case Yellow: rgb = { 255, 255, 0 }; break;
|
||||||
|
case Magenta: rgb = { 255, 0, 255 }; break;
|
||||||
case DarkGray: rgb = { 64, 64, 64 }; break;
|
case DarkGray: rgb = { 64, 64, 64 }; break;
|
||||||
case MidGray: rgb = { 127, 127, 127 }; break;
|
case MidGray: rgb = { 127, 127, 127 }; break;
|
||||||
case LightGray: rgb = { 192, 192, 192 }; break;
|
case LightGray: rgb = { 192, 192, 192 }; break;
|
||||||
|
|
|
@ -12,6 +12,8 @@ public:
|
||||||
Red,
|
Red,
|
||||||
Green,
|
Green,
|
||||||
Blue,
|
Blue,
|
||||||
|
Yellow,
|
||||||
|
Magenta,
|
||||||
DarkGray,
|
DarkGray,
|
||||||
MidGray,
|
MidGray,
|
||||||
LightGray,
|
LightGray,
|
||||||
|
|
|
@ -6,16 +6,15 @@
|
||||||
#include "EventLoop.h"
|
#include "EventLoop.h"
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
|
|
||||||
static const int windowFrameWidth = 2;
|
|
||||||
static const int windowTitleBarHeight = 16;
|
static const int windowTitleBarHeight = 16;
|
||||||
|
|
||||||
static inline Rect titleBarRectForWindow(const Rect& window)
|
static inline Rect titleBarRectForWindow(const Rect& window)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
window.x() - windowFrameWidth,
|
window.x() - 1,
|
||||||
window.y() - windowTitleBarHeight - windowFrameWidth,
|
window.y() - windowTitleBarHeight,
|
||||||
window.width() + windowFrameWidth * 2,
|
window.width() + 2,
|
||||||
windowTitleBarHeight + windowFrameWidth
|
windowTitleBarHeight
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,9 +22,9 @@ static inline Rect titleBarTitleRectForWindow(const Rect& window)
|
||||||
{
|
{
|
||||||
auto titleBarRect = titleBarRectForWindow(window);
|
auto titleBarRect = titleBarRectForWindow(window);
|
||||||
return {
|
return {
|
||||||
titleBarRect.x() + windowFrameWidth,
|
titleBarRect.x() + 2,
|
||||||
titleBarRect.y(),
|
titleBarRect.y(),
|
||||||
titleBarRect.width() - windowFrameWidth * 2,
|
titleBarRect.width() - 4,
|
||||||
titleBarRect.height()
|
titleBarRect.height()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -36,7 +35,7 @@ static inline Rect borderRectForWindow(const Rect& window)
|
||||||
return { titleBarRect.x() - 1,
|
return { titleBarRect.x() - 1,
|
||||||
titleBarRect.y() - 1,
|
titleBarRect.y() - 1,
|
||||||
titleBarRect.width() + 2,
|
titleBarRect.width() + 2,
|
||||||
windowFrameWidth + windowTitleBarHeight + window.height() + 4
|
windowTitleBarHeight + window.height() + 3
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,27 +88,13 @@ void WindowManager::paintWindowFrame(Window& window)
|
||||||
auto outerRect = outerRectForWindow(window.rect());
|
auto outerRect = outerRectForWindow(window.rect());
|
||||||
auto borderRect = borderRectForWindow(window.rect());
|
auto borderRect = borderRectForWindow(window.rect());
|
||||||
|
|
||||||
Rect bottomRect {
|
Rect inner_border_rect {
|
||||||
window.x() - windowFrameWidth,
|
window.x() - 1,
|
||||||
window.y() + window.height(),
|
window.y() - 1,
|
||||||
window.width() + windowFrameWidth * 2,
|
window.width() + 2,
|
||||||
windowFrameWidth };
|
window.height() + 2
|
||||||
|
|
||||||
Rect leftRect {
|
|
||||||
window.x() - windowFrameWidth,
|
|
||||||
window.y(),
|
|
||||||
windowFrameWidth,
|
|
||||||
window.height()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Rect rightRect {
|
|
||||||
window.x() + window.width(),
|
|
||||||
window.y(),
|
|
||||||
windowFrameWidth,
|
|
||||||
window.height()
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
if (!m_lastDragRect.is_empty()) {
|
if (!m_lastDragRect.is_empty()) {
|
||||||
p.xorRect(m_lastDragRect, Color::Red);
|
p.xorRect(m_lastDragRect, Color::Red);
|
||||||
m_lastDragRect = Rect();
|
m_lastDragRect = Rect();
|
||||||
|
@ -128,9 +113,8 @@ void WindowManager::paintWindowFrame(Window& window)
|
||||||
p.drawRect(outerRect, borderColor);
|
p.drawRect(outerRect, borderColor);
|
||||||
|
|
||||||
p.fillRect(titleBarRect, borderColor);
|
p.fillRect(titleBarRect, borderColor);
|
||||||
p.fillRect(bottomRect, borderColor);
|
|
||||||
p.fillRect(leftRect, borderColor);
|
p.drawRect(inner_border_rect, borderColor);
|
||||||
p.fillRect(rightRect, borderColor);
|
|
||||||
|
|
||||||
p.drawText(titleBarTitleRect, window.title(), Painter::TextAlignment::CenterLeft, titleColor);
|
p.drawText(titleBarTitleRect, window.title(), Painter::TextAlignment::CenterLeft, titleColor);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue