Userland: Use Rect::centered_within() where useful

This commit is contained in:
Andreas Kling 2021-08-30 22:18:20 +02:00
commit 087bd7f767
Notes: sideshowbarker 2024-07-18 05:03:13 +09:00
9 changed files with 15 additions and 34 deletions

View file

@ -126,8 +126,7 @@ void MonitorWidget::redraw_desktop_if_needed()
auto scaled_bitmap = m_wallpaper_bitmap->scaled(sw, sh);
if (m_desktop_wallpaper_mode == "center") {
Gfx::IntRect centered_rect { {}, scaled_size };
centered_rect.center_within(m_desktop_bitmap->rect());
auto centered_rect = Gfx::IntRect({}, scaled_size).centered_within(m_desktop_bitmap->rect());
painter.blit(centered_rect.location(), *scaled_bitmap, scaled_bitmap->rect());
} else if (m_desktop_wallpaper_mode == "tile") {
painter.draw_tiled_bitmap(m_desktop_bitmap->rect(), *scaled_bitmap);