mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
Userland: Use Rect::centered_within() where useful
This commit is contained in:
parent
43220568b0
commit
087bd7f767
9 changed files with 15 additions and 34 deletions
|
@ -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);
|
||||
|
|
|
@ -35,9 +35,7 @@ void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event)
|
|||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(event.rect());
|
||||
|
||||
auto bottom_arrow_rect = m_arrow_bitmap->rect();
|
||||
bottom_arrow_rect.center_within(rect());
|
||||
bottom_arrow_rect.translate_by(0, m_arrow_bitmap->height() / 2);
|
||||
auto bottom_arrow_rect = m_arrow_bitmap->rect().centered_within(rect()).translated(0, m_arrow_bitmap->height() / 2);
|
||||
|
||||
painter.blit_filtered(bottom_arrow_rect.location(), *m_arrow_bitmap, m_arrow_bitmap->rect(), [&](Color color) {
|
||||
return m_inverted ? color.inverted() : color;
|
||||
|
|
|
@ -75,8 +75,7 @@ PaletteWidget::PaletteWidget()
|
|||
m_secondary_color_widget->set_fill_with_background_color(true);
|
||||
|
||||
m_primary_color_widget = add<GUI::Frame>();
|
||||
Gfx::IntRect rect { 0, 0, 38, 15 };
|
||||
rect.center_within(m_secondary_color_widget->relative_rect());
|
||||
auto rect = Gfx::IntRect(0, 0, 38, 15).centered_within(m_secondary_color_widget->relative_rect());
|
||||
m_primary_color_widget->set_relative_rect(rect);
|
||||
m_primary_color_widget->set_fill_with_background_color(true);
|
||||
|
||||
|
|
|
@ -137,15 +137,13 @@ void PreviewWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
for (auto& button : buttons) {
|
||||
Gfx::StylePainter::paint_button(painter, button.rect, m_preview_palette, Gfx::ButtonStyle::Normal, false);
|
||||
auto bitmap_rect = button.bitmap->rect();
|
||||
bitmap_rect.center_within(button.rect);
|
||||
auto bitmap_rect = button.bitmap->rect().centered_within(button.rect);
|
||||
painter.blit(bitmap_rect.location(), *button.bitmap, button.bitmap->rect());
|
||||
}
|
||||
};
|
||||
|
||||
Gfx::IntRect active_rect { 0, 0, 320, 240 };
|
||||
active_rect.center_within(frame_inner_rect());
|
||||
Gfx::IntRect inactive_rect = active_rect.translated(-20, -20);
|
||||
auto active_rect = Gfx::IntRect(0, 0, 320, 240).centered_within(frame_inner_rect());
|
||||
auto inactive_rect = active_rect.translated(-20, -20);
|
||||
|
||||
paint_window("Inactive window", inactive_rect, Gfx::WindowTheme::WindowState::Inactive, *m_active_window_icon);
|
||||
paint_window("Active window", active_rect, Gfx::WindowTheme::WindowState::Active, *m_inactive_window_icon);
|
||||
|
@ -153,9 +151,7 @@ void PreviewWidget::paint_event(GUI::PaintEvent& event)
|
|||
|
||||
void PreviewWidget::resize_event(GUI::ResizeEvent&)
|
||||
{
|
||||
Gfx::IntRect gallery_rect { 0, 0, 320, 240 };
|
||||
gallery_rect.center_within(rect());
|
||||
m_gallery->set_relative_rect(gallery_rect);
|
||||
m_gallery->set_relative_rect(Gfx::IntRect(0, 0, 320, 240).centered_within(rect()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue