Skip to content

Commit

Permalink
WindowServer: Tweak window titlebar look somewhat.
Browse files Browse the repository at this point in the history
Add a subtle shadow to the titlebar text. Also make the titlebar one pixel
taller to fully accomodate the 90s "3D frame" effect. :^)
  • Loading branch information
awesomekling committed May 25, 2019
1 parent 34150f0 commit 41ebb3e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
21 changes: 6 additions & 15 deletions Servers/WindowServer/WSWindowFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ WSWindowFrame::~WSWindowFrame()

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
Expand Down Expand Up @@ -144,16 +144,7 @@ void WSWindowFrame::paint(Painter& painter)
PainterStateSaver saver(painter);
painter.translate(rect().location());

if (m_window.type() == WSWindowType::Menu)
return;

if (m_window.type() == WSWindowType::WindowSwitcher)
return;

if (m_window.type() == WSWindowType::Taskbar)
return;

if (m_window.type() == WSWindowType::Tooltip)
if (m_window.type() != WSWindowType::Normal)
return;

auto& window = m_window;
Expand Down Expand Up @@ -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_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.
painter.draw_text(titlebar_title_rect.translated(0, 1), window.title(), wm.window_title_font(), TextAlignment::CenterLeft, title_color);

Expand All @@ -218,14 +209,14 @@ void WSWindowFrame::paint(Painter& painter)
static Rect frame_rect_for_window(WSWindow& window, const Rect& rect)
{
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) {
case WSWindowType::Normal:
return { rect.x() - 3,
rect.y() - window_titlebar_height - 3 + offset,
rect.y() - window_titlebar_height - 4 + offset,
rect.width() + 6,
rect.height() + 6 + window_titlebar_height - offset };
rect.height() + 7 + window_titlebar_height - offset };
default:
return rect;
}
Expand Down
4 changes: 2 additions & 2 deletions SharedGraphics/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ class Color {
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
Expand Down

0 comments on commit 41ebb3e

Please sign in to comment.