mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:57:41 +00:00
WindowServer: Tweak window titlebar look somewhat.
Add a subtle shadow to the titlebar text. Also make the titlebar one pixel taller to fully accomodate the 90s "3D frame" effect. :^)
This commit is contained in:
parent
34150f0836
commit
41ebb3eba3
2 changed files with 8 additions and 17 deletions
|
@ -113,7 +113,7 @@ WSWindowFrame::~WSWindowFrame()
|
||||||
|
|
||||||
Rect WSWindowFrame::title_bar_rect() const
|
Rect WSWindowFrame::title_bar_rect() const
|
||||||
{
|
{
|
||||||
return { 3, 2, m_window.width(), window_titlebar_height };
|
return { 3, 3, m_window.width(), window_titlebar_height };
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect WSWindowFrame::title_bar_icon_rect() const
|
Rect WSWindowFrame::title_bar_icon_rect() const
|
||||||
|
@ -144,16 +144,7 @@ void WSWindowFrame::paint(Painter& painter)
|
||||||
PainterStateSaver saver(painter);
|
PainterStateSaver saver(painter);
|
||||||
painter.translate(rect().location());
|
painter.translate(rect().location());
|
||||||
|
|
||||||
if (m_window.type() == WSWindowType::Menu)
|
if (m_window.type() != WSWindowType::Normal)
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_window.type() == WSWindowType::WindowSwitcher)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_window.type() == WSWindowType::Taskbar)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_window.type() == WSWindowType::Tooltip)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& window = m_window;
|
auto& window = m_window;
|
||||||
|
@ -204,7 +195,7 @@ void WSWindowFrame::paint(Painter& painter)
|
||||||
painter.draw_line({ titlebar_title_rect.right() + 4, titlebar_inner_rect.y() + i }, { leftmost_button_rect.left() - 3, titlebar_inner_rect.y() + i }, border_color);
|
painter.draw_line({ titlebar_title_rect.right() + 4, titlebar_inner_rect.y() + i }, { leftmost_button_rect.left() - 3, titlebar_inner_rect.y() + i }, border_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter.draw_text(titlebar_title_rect.translated(1, 2), window.title(), wm.window_title_font(), TextAlignment::CenterLeft, border_color.darkened(0.4));
|
||||||
// FIXME: The translated(0, 1) wouldn't be necessary if we could center text based on its baseline.
|
// FIXME: The translated(0, 1) wouldn't be necessary if we could center text based on its baseline.
|
||||||
painter.draw_text(titlebar_title_rect.translated(0, 1), window.title(), wm.window_title_font(), TextAlignment::CenterLeft, title_color);
|
painter.draw_text(titlebar_title_rect.translated(0, 1), window.title(), wm.window_title_font(), TextAlignment::CenterLeft, title_color);
|
||||||
|
|
||||||
|
@ -218,14 +209,14 @@ void WSWindowFrame::paint(Painter& painter)
|
||||||
static Rect frame_rect_for_window(WSWindow& window, const Rect& rect)
|
static Rect frame_rect_for_window(WSWindow& window, const Rect& rect)
|
||||||
{
|
{
|
||||||
auto type = window.type();
|
auto type = window.type();
|
||||||
auto offset = !window.show_titlebar() ? window_titlebar_height : 0;
|
auto offset = !window.show_titlebar() ? (window_titlebar_height + 1) : 0;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WSWindowType::Normal:
|
case WSWindowType::Normal:
|
||||||
return { rect.x() - 3,
|
return { rect.x() - 3,
|
||||||
rect.y() - window_titlebar_height - 3 + offset,
|
rect.y() - window_titlebar_height - 4 + offset,
|
||||||
rect.width() + 6,
|
rect.width() + 6,
|
||||||
rect.height() + 6 + window_titlebar_height - offset };
|
rect.height() + 7 + window_titlebar_height - offset };
|
||||||
default:
|
default:
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,9 +79,9 @@ public:
|
||||||
return Color(gray, gray, gray, alpha());
|
return Color(gray, gray, gray, alpha());
|
||||||
}
|
}
|
||||||
|
|
||||||
Color darkened() const
|
Color darkened(float amount = 0.5) const
|
||||||
{
|
{
|
||||||
return Color(red() * 0.8, green() * 0.8, blue() * 0.8, alpha());
|
return Color(red() * amount, green() * amount, blue() * amount, alpha());
|
||||||
}
|
}
|
||||||
|
|
||||||
Color lightened() const
|
Color lightened() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue