diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-16 17:02:26 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-16 17:02:26 +0200 |
commit | 86361d3d453491b4c9c89d11c5e0c02146d580e3 (patch) | |
tree | 98c8981696a3bb852328230bf718bea667d3008b /Servers | |
parent | 311019d8ee84556cf20fec9f5933d2a26888f753 (diff) | |
download | serenity-86361d3d453491b4c9c89d11c5e0c02146d580e3.zip |
WindowServer: Improve the look of menus.
This patch makes menus stand out a bit more from their background by using
the same kind of shading that Windows 2000 had.
Diffstat (limited to 'Servers')
-rw-r--r-- | Servers/WindowServer/WSMenu.cpp | 13 | ||||
-rw-r--r-- | Servers/WindowServer/WSMenu.h | 2 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowFrame.cpp | 11 | ||||
-rw-r--r-- | Servers/WindowServer/WSWindowManager.cpp | 4 |
4 files changed, 12 insertions, 18 deletions
diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp index 661f8c6967..ba952a11d7 100644 --- a/Servers/WindowServer/WSMenu.cpp +++ b/Servers/WindowServer/WSMenu.cpp @@ -7,6 +7,7 @@ #include <WindowServer/WSAPITypes.h> #include <WindowServer/WSClientConnection.h> #include <SharedGraphics/Painter.h> +#include <SharedGraphics/StylePainter.h> #include <SharedGraphics/Font.h> WSMenu::WSMenu(WSClientConnection* client, int menu_id, String&& name) @@ -38,14 +39,14 @@ int WSMenu::width() const } } - return max(longest, rect_in_menubar().width()) + horizontal_padding(); + return max(longest, rect_in_menubar().width()) + horizontal_padding() + frame_thickness() * 2; } int WSMenu::height() const { if (m_items.is_empty()) return 0; - return (m_items.last()->rect().bottom() - 1) + vertical_padding(); + return (m_items.last()->rect().bottom() - 1) + frame_thickness() * 2; } void WSMenu::redraw() @@ -59,14 +60,14 @@ void WSMenu::redraw() WSWindow& WSMenu::ensure_menu_window() { if (!m_menu_window) { - Point next_item_location(1, vertical_padding() / 2); + Point next_item_location(frame_thickness(), frame_thickness()); for (auto& item : m_items) { int height = 0; if (item->type() == WSMenuItem::Text) height = item_height(); else if (item->type() == WSMenuItem::Separator) height = 7; - item->set_rect({ next_item_location, { width() - 2, height } }); + item->set_rect({ next_item_location, { width() - frame_thickness() * 2, height } }); next_item_location.move_by(0, height); } @@ -86,8 +87,8 @@ void WSMenu::draw() Painter painter(*menu_window()->backing_store()); Rect rect { { }, menu_window()->size() }; - painter.draw_rect(rect, Color::White); - painter.fill_rect(rect.shrunken(2, 2), Color::LightGray); + painter.fill_rect(rect.shrunken(4, 4), Color::LightGray); + StylePainter::paint_menu_frame(painter, rect); for (auto& item : m_items) { if (item->type() == WSMenuItem::Text) { diff --git a/Servers/WindowServer/WSMenu.h b/Servers/WindowServer/WSMenu.h index 028d840b61..2c2362186d 100644 --- a/Servers/WindowServer/WSMenu.h +++ b/Servers/WindowServer/WSMenu.h @@ -55,7 +55,7 @@ public: int height() const; int item_height() const { return 18; } - int vertical_padding() const { return 4; } + int frame_thickness() const { return 2; } int horizontal_padding() const { return left_padding() + right_padding(); } int left_padding() const { return 14; } int right_padding() const { return 14; } diff --git a/Servers/WindowServer/WSWindowFrame.cpp b/Servers/WindowServer/WSWindowFrame.cpp index 6a3b08c1f5..bf511db46c 100644 --- a/Servers/WindowServer/WSWindowFrame.cpp +++ b/Servers/WindowServer/WSWindowFrame.cpp @@ -66,11 +66,6 @@ WSWindowFrame::~WSWindowFrame() { } -static inline Rect menu_window_rect(const Rect& rect) -{ - return rect.inflated(2, 2); -} - Rect WSWindowFrame::title_bar_rect() const { return { 2, 2, m_window.width() + 2, window_titlebar_height }; @@ -109,10 +104,8 @@ void WSWindowFrame::paint(Painter& painter) PainterStateSaver saver(painter); painter.translate(rect().location()); - if (m_window.type() == WSWindowType::Menu) { - painter.draw_rect(menu_window_rect(m_window.rect()), Color::LightGray); + if (m_window.type() == WSWindowType::Menu) return; - } if (m_window.type() == WSWindowType::WindowSwitcher) return; @@ -193,7 +186,7 @@ static Rect frame_rect_for_window_type(WSWindowType type, const Rect& rect) { switch (type) { case WSWindowType::Menu: - return menu_window_rect(rect); + return rect; case WSWindowType::Normal: return { rect.x() - 3, rect.y() - window_titlebar_height - 3, rect.width() + 6, rect.height() + 6 + window_titlebar_height }; case WSWindowType::WindowSwitcher: diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index d62bbdce5b..aef6b73342 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -379,7 +379,7 @@ void WSWindowManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& close_current_menu(); if (!menu.is_empty()) { auto& menu_window = menu.ensure_menu_window(); - menu_window.move_to({ menu.rect_in_menubar().x(), menu.rect_in_menubar().bottom() }); + menu_window.move_to({ menu.rect_in_menubar().x(), menu.rect_in_menubar().bottom() + 2 }); menu_window.set_visible(true); } m_current_menu = menu.make_weak_ptr(); @@ -826,7 +826,7 @@ void WSWindowManager::draw_menubar() auto menubar_rect = this->menubar_rect(); m_back_painter->fill_rect(menubar_rect, Color::LightGray); - m_back_painter->draw_line({ 0, menubar_rect.bottom() }, { menubar_rect.right(), menubar_rect.bottom() }, Color::White); + m_back_painter->draw_line({ 0, menubar_rect.bottom() }, { menubar_rect.right(), menubar_rect.bottom() }, Color::MidGray); int index = 0; for_each_active_menubar_menu([&] (WSMenu& menu) { Color text_color = Color::Black; |