mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-27 01:50:24 +00:00
WindowServer+LibGfx: Make menubar menus slightly larger
Also make sure the left/right padding is equally large.
This commit is contained in:
parent
3020f5efd9
commit
4b6fba1e4c
Notes:
sideshowbarker
2024-07-18 21:04:43 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4b6fba1e4c0
5 changed files with 9 additions and 16 deletions
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace Gfx {
|
||||
|
||||
static constexpr int menu_bar_height = 19;
|
||||
static constexpr int menu_bar_height = 20;
|
||||
|
||||
ClassicWindowTheme::ClassicWindowTheme()
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ IntRect ClassicWindowTheme::menu_bar_rect(WindowType window_type, const IntRect&
|
|||
{
|
||||
if (window_type != WindowType::Normal)
|
||||
return {};
|
||||
return { 4, 4 + title_bar_height(window_type, palette) + 2, window_rect.width(), menu_bar_height * menu_row_count };
|
||||
return { 4, 3 + title_bar_height(window_type, palette) + 2, window_rect.width(), menu_bar_height * menu_row_count };
|
||||
}
|
||||
|
||||
IntRect ClassicWindowTheme::title_bar_rect(WindowType window_type, const IntRect& window_rect, const Palette& palette) const
|
||||
|
@ -209,9 +209,9 @@ IntRect ClassicWindowTheme::frame_rect_for_window(WindowType window_type, const
|
|||
case WindowType::ToolWindow:
|
||||
return {
|
||||
window_rect.x() - 4,
|
||||
window_rect.y() - window_titlebar_height - 6 - menu_row_count * menu_bar_height,
|
||||
window_rect.y() - window_titlebar_height - 5 - menu_row_count * menu_bar_height,
|
||||
window_rect.width() + 8,
|
||||
window_rect.height() + 10 + window_titlebar_height + menu_row_count * menu_bar_height
|
||||
window_rect.height() + 9 + window_titlebar_height + menu_row_count * menu_bar_height
|
||||
};
|
||||
case WindowType::Notification:
|
||||
return {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue