summaryrefslogtreecommitdiff
path: root/Userland/Services/Taskbar
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-07-20 02:26:47 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-20 02:48:29 +0200
commit59b6169b5184bd34b842d4d644acb5d4aadbc559 (patch)
tree9555c018eb1fb751d9fd5cd43c23070913da03c7 /Userland/Services/Taskbar
parentf5e914fb9f2239cd3ede07b31143212c1e9b65b2 (diff)
downloadserenity-59b6169b5184bd34b842d4d644acb5d4aadbc559.zip
Taskbar: Update the start button width when system fonts change
Diffstat (limited to 'Userland/Services/Taskbar')
-rw-r--r--Userland/Services/Taskbar/TaskbarWindow.cpp11
-rw-r--r--Userland/Services/Taskbar/TaskbarWindow.h2
2 files changed, 10 insertions, 3 deletions
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<GUI::Menu> 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<GUI::Menu> m_start_menu;
RefPtr<GUI::Widget> m_task_button_container;
RefPtr<Gfx::Bitmap> m_default_icon;