diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-11 14:14:49 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-11 14:14:49 +0100 |
commit | 8d0bfa62fd6d06a135535b5175d852e011b0ad44 (patch) | |
tree | f5e87ae3fab24c4c128893e4168a81bf2220ca72 /WindowServer | |
parent | 3c863e0ffaf0e4835da06cd63fbde54305fd90c3 (diff) | |
download | serenity-8d0bfa62fd6d06a135535b5175d852e011b0ad44.zip |
WindowServer: Add a bunch of horizontal padding to menu items.
All right, this looks a lot nicer. :^)
Diffstat (limited to 'WindowServer')
-rw-r--r-- | WindowServer/WSMenu.cpp | 14 | ||||
-rw-r--r-- | WindowServer/WSMenu.h | 5 |
2 files changed, 11 insertions, 8 deletions
diff --git a/WindowServer/WSMenu.cpp b/WindowServer/WSMenu.cpp index e176655850..01fac116ea 100644 --- a/WindowServer/WSMenu.cpp +++ b/WindowServer/WSMenu.cpp @@ -34,14 +34,14 @@ int WSMenu::width() const longest = max(longest, font().width(item->text())); } - return max(longest, rect_in_menubar().width()) + padding() * 2; + return max(longest, rect_in_menubar().width()) + horizontal_padding(); } int WSMenu::height() const { if (m_items.is_empty()) return 0; - return (m_items.last()->rect().bottom() - 1) + padding(); + return (m_items.last()->rect().bottom() - 1) + vertical_padding(); } void WSMenu::redraw() @@ -54,14 +54,14 @@ void WSMenu::redraw() WSWindow& WSMenu::ensure_menu_window() { if (!m_menu_window) { - Point next_item_location(padding() / 2, padding() / 2); + Point next_item_location(1, vertical_padding() / 2); 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() - padding(), height } }); + item->set_rect({ next_item_location, { width() - 2, height } }); next_item_location.move_by(0, height); } @@ -90,10 +90,10 @@ void WSMenu::draw() painter.fill_rect(item->rect(), Color(0, 0, 104)); text_color = Color::White; } - painter.draw_text(item->rect(), item->text(), TextAlignment::CenterLeft, text_color); + painter.draw_text(item->rect().translated(left_padding(), 0), item->text(), TextAlignment::CenterLeft, text_color); } else if (item->type() == WSMenuItem::Separator) { - Point p1(padding(), item->rect().center().y()); - Point p2(width() - padding(), item->rect().center().y()); + Point p1(1, item->rect().center().y()); + Point p2(width() - 2, item->rect().center().y()); painter.draw_line(p1, p2, Color::MidGray); } } diff --git a/WindowServer/WSMenu.h b/WindowServer/WSMenu.h index 4ace65c07d..99eef768a3 100644 --- a/WindowServer/WSMenu.h +++ b/WindowServer/WSMenu.h @@ -48,7 +48,10 @@ public: int height() const; int item_height() const { return 16; } - int padding() const { return 4; } + int vertical_padding() const { return 4; } + int horizontal_padding() const { return left_padding() + right_padding(); } + int left_padding() const { return 14; } + int right_padding() const { return 14; } void on_window_message(WSMessage&); void draw(); |