1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:17:44 +00:00

Taskbar: Update the start button width when system fonts change

This commit is contained in:
Andreas Kling 2021-07-20 02:26:47 +02:00
parent f5e914fb9f
commit 59b6169b51
2 changed files with 10 additions and 3 deletions

View file

@ -65,9 +65,8 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu)
main_widget.layout()->set_margins({ 3, 3, 1, 1 }); main_widget.layout()->set_margins({ 3, 3, 1, 1 });
m_start_button = GUI::Button::construct("Serenity"); 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_icon_spacing(0);
m_start_button->set_fixed_size(80, 21);
auto app_icon = GUI::Icon::default_icon("ladyball"); auto app_icon = GUI::Icon::default_icon("ladyball");
m_start_button->set_icon(app_icon.bitmap_for_size(16)); m_start_button->set_icon(app_icon.bitmap_for_size(16));
m_start_button->set_menu(m_start_menu); m_start_button->set_menu(m_start_menu);
@ -270,7 +269,7 @@ void TaskbarWindow::event(Core::Event& event)
break; break;
} }
case GUI::Event::FontsChange: 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; break;
} }
Window::event(event); 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)); 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);
}

View file

@ -40,6 +40,8 @@ private:
bool is_window_on_current_virtual_desktop(::Window&) const; bool is_window_on_current_virtual_desktop(::Window&) const;
void virtual_desktop_change_event(unsigned, unsigned); void virtual_desktop_change_event(unsigned, unsigned);
void set_start_button_font(Gfx::Font const&);
NonnullRefPtr<GUI::Menu> m_start_menu; NonnullRefPtr<GUI::Menu> m_start_menu;
RefPtr<GUI::Widget> m_task_button_container; RefPtr<GUI::Widget> m_task_button_container;
RefPtr<Gfx::Bitmap> m_default_icon; RefPtr<Gfx::Bitmap> m_default_icon;