1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:17:35 +00:00

WindowServer+LibGfx: Make menubar menus slightly larger

Also make sure the left/right padding is equally large.
This commit is contained in:
Andreas Kling 2021-03-26 14:24:04 +01:00
parent 3020f5efd9
commit 4b6fba1e4c
5 changed files with 9 additions and 16 deletions

View file

@ -70,8 +70,6 @@ public:
callback(item);
}
Gfx::IntRect text_rect_in_window_menubar() const { return m_text_rect_in_window_menubar; }
void set_text_rect_in_window_menubar(const Gfx::IntRect& rect) { m_text_rect_in_window_menubar = rect; }
Gfx::IntRect rect_in_window_menubar() const { return m_rect_in_window_menubar; }
void set_rect_in_window_menubar(const Gfx::IntRect& rect) { m_rect_in_window_menubar = rect; }
@ -141,7 +139,6 @@ private:
int m_menu_id { 0 };
String m_name;
Gfx::IntRect m_rect_in_window_menubar;
Gfx::IntRect m_text_rect_in_window_menubar;
NonnullOwnPtrVector<MenuItem> m_items;
RefPtr<Window> m_menu_window;

View file

@ -50,7 +50,7 @@ public:
bool has_open_menu() const { return !m_open_menu_stack.is_empty(); }
Gfx::IntRect menubar_rect() const;
static int menubar_menu_margin() { return 13; }
static int menubar_menu_margin() { return 14; }
void set_needs_window_resize();

View file

@ -949,15 +949,11 @@ void Window::set_menubar(MenuBar* menubar)
m_menubar = menubar;
if (m_menubar) {
auto& wm = WindowManager::the();
Gfx::IntPoint next_menu_location { MenuManager::menubar_menu_margin() / 2, 0 };
Gfx::IntPoint next_menu_location { 0, 0 };
auto menubar_rect = Gfx::WindowTheme::current().menu_bar_rect(Gfx::WindowTheme::WindowType::Normal, rect(), wm.palette(), 1);
m_menubar->for_each_menu([&](Menu& menu) {
int text_width = wm.font().width(menu.name());
menu.set_rect_in_window_menubar({ next_menu_location.x() - MenuManager::menubar_menu_margin() / 2, 0, text_width + MenuManager::menubar_menu_margin(), menubar_rect.height() });
Gfx::IntRect text_rect { next_menu_location.translated(0, 1), { text_width, menubar_rect.height() - 3 } };
menu.set_text_rect_in_window_menubar(text_rect);
menu.set_rect_in_window_menubar({ next_menu_location.x(), 0, text_width + MenuManager::menubar_menu_margin(), menubar_rect.height() });
next_menu_location.move_by(menu.rect_in_window_menubar().width(), 0);
return IterationDecision::Continue;
});

View file

@ -311,7 +311,7 @@ void WindowFrame::paint_menubar(Gfx::Painter& painter)
painter.translate(menubar_rect.location());
m_window.menubar()->for_each_menu([&](Menu& menu) {
auto text_rect = menu.text_rect_in_window_menubar();
auto text_rect = menu.rect_in_window_menubar();
Color text_color = palette.window_text();
if (MenuManager::the().is_open(menu))
text_rect.move_by(1, 1);
@ -324,7 +324,7 @@ void WindowFrame::paint_menubar(Gfx::Painter& painter)
text_rect,
menu.name(),
font,
Gfx::TextAlignment::CenterLeft,
Gfx::TextAlignment::Center,
text_color);
return IterationDecision::Continue;
});