2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2021-03-26 05:11:44 -03:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
2021-07-29 07:14:12 -03:00
|
|
|
* Copyright (c) 2021, sin-ack <sin-ack@protonmail.com>
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2021-04-13 11:18:20 -03:00
|
|
|
#include "Menubar.h"
|
2021-07-29 07:14:12 -03:00
|
|
|
#include "WindowManager.h"
|
2019-02-11 06:47:10 -02:00
|
|
|
|
2020-02-06 16:03:37 -03:00
|
|
|
namespace WindowServer {
|
|
|
|
|
|
2021-07-29 07:14:12 -03:00
|
|
|
void Menubar::layout_menu(Menu& menu, Gfx::IntRect window_rect)
|
2019-02-11 06:47:10 -02:00
|
|
|
{
|
2021-07-29 07:14:12 -03:00
|
|
|
// FIXME: Maybe move this to the theming system?
|
|
|
|
|
static constexpr auto menubar_menu_margin = 14;
|
2019-02-11 06:47:10 -02:00
|
|
|
|
2021-07-29 07:14:12 -03:00
|
|
|
auto& wm = WindowManager::the();
|
|
|
|
|
auto menubar_rect = Gfx::WindowTheme::current().menubar_rect(Gfx::WindowTheme::WindowType::Normal, window_rect, wm.palette(), 1);
|
2020-02-06 16:03:37 -03:00
|
|
|
|
2021-07-29 07:14:12 -03:00
|
|
|
int text_width = wm.font().width(Gfx::parse_ampersand_string(menu.name()));
|
|
|
|
|
menu.set_rect_in_window_menubar({ m_next_menu_location.x(), 0, text_width + menubar_menu_margin, menubar_rect.height() });
|
|
|
|
|
m_next_menu_location.translate_by(menu.rect_in_window_menubar().width(), 0);
|
2020-03-10 04:56:07 -03:00
|
|
|
}
|
|
|
|
|
|
2020-02-06 16:03:37 -03:00
|
|
|
}
|