Serenity Operating System
1/*
2 * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
3 * Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#include "Menubar.h"
9#include "WindowManager.h"
10
11namespace WindowServer {
12
13void Menubar::layout_menu(Menu& menu, Gfx::IntRect window_rect)
14{
15 // FIXME: Maybe move this to the theming system?
16 static constexpr auto menubar_menu_margin = 14;
17
18 auto& wm = WindowManager::the();
19 auto menubar_rect = Gfx::WindowTheme::current().menubar_rect(Gfx::WindowTheme::WindowType::Normal, Gfx::WindowTheme::WindowMode::Other, window_rect, wm.palette(), 1);
20
21 int text_width = wm.font().width(Gfx::parse_ampersand_string(menu.name()));
22 menu.set_rect_in_window_menubar({ m_next_menu_location.x(), 0, text_width + menubar_menu_margin, menubar_rect.height() });
23 m_next_menu_location.translate_by(menu.rect_in_window_menubar().width(), 0);
24}
25
26}