From 59b6169b5184bd34b842d4d644acb5d4aadbc559 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 20 Jul 2021 02:26:47 +0200 Subject: Taskbar: Update the start button width when system fonts change --- Userland/Services/Taskbar/TaskbarWindow.cpp | 11 ++++++++--- Userland/Services/Taskbar/TaskbarWindow.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'Userland/Services/Taskbar') diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index 543ef75ea9..d6a2e7a990 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -65,9 +65,8 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr start_menu) main_widget.layout()->set_margins({ 3, 3, 1, 1 }); m_start_button = GUI::Button::construct("Serenity"); - m_start_button->set_font(Gfx::FontDatabase::default_font().bold_variant()); + set_start_button_font(Gfx::FontDatabase::default_font().bold_variant()); m_start_button->set_icon_spacing(0); - m_start_button->set_fixed_size(80, 21); auto app_icon = GUI::Icon::default_icon("ladyball"); m_start_button->set_icon(app_icon.bitmap_for_size(16)); m_start_button->set_menu(m_start_menu); @@ -270,7 +269,7 @@ void TaskbarWindow::event(Core::Event& event) break; } case GUI::Event::FontsChange: - m_start_button->set_font(Gfx::FontDatabase::default_font().bold_variant()); + set_start_button_font(Gfx::FontDatabase::default_font().bold_variant()); break; } Window::event(event); @@ -413,3 +412,9 @@ void TaskbarWindow::virtual_desktop_change_event(unsigned current_row, unsigned button->set_visible(is_window_on_current_virtual_desktop(window)); }); } + +void TaskbarWindow::set_start_button_font(Gfx::Font const& font) +{ + m_start_button->set_font(font); + m_start_button->set_fixed_size(font.width(m_start_button->text()) + 30, 21); +} diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h index a7d307bb19..a7464a925b 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.h +++ b/Userland/Services/Taskbar/TaskbarWindow.h @@ -40,6 +40,8 @@ private: bool is_window_on_current_virtual_desktop(::Window&) const; void virtual_desktop_change_event(unsigned, unsigned); + void set_start_button_font(Gfx::Font const&); + NonnullRefPtr m_start_menu; RefPtr m_task_button_container; RefPtr m_default_icon; -- cgit v1.2.3