mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:07:35 +00:00
LibGfx: Unify Rect, Point, and Size
This commit unifies methods and method/param names between the above classes, as well as adds [[nodiscard]] and ALWAYS_INLINE where appropriate. It also renamed the various move_by methods to translate_by, as that more closely matches the transformation terminology.
This commit is contained in:
parent
ac238b3bd6
commit
88cfaf7bf0
48 changed files with 282 additions and 187 deletions
|
@ -138,7 +138,7 @@ void Compositor::compose()
|
|||
auto invalidate_rect = dirty_rect.intersected(frame_rect);
|
||||
if (!invalidate_rect.is_empty()) {
|
||||
auto inner_rect_offset = window.rect().location() - frame_rect.location();
|
||||
invalidate_rect.move_by(-(frame_rect.location() + inner_rect_offset));
|
||||
invalidate_rect.translate_by(-(frame_rect.location() + inner_rect_offset));
|
||||
window.invalidate_no_notify(invalidate_rect);
|
||||
m_invalidated_window = true;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ void Compositor::compose()
|
|||
if (!wm.dnd_text().is_empty()) {
|
||||
auto text_rect = dnd_rect;
|
||||
if (wm.dnd_bitmap())
|
||||
text_rect.move_by(wm.dnd_bitmap()->width() + 8, 0);
|
||||
text_rect.translate_by(wm.dnd_bitmap()->width() + 8, 0);
|
||||
back_painter.draw_text(text_rect, wm.dnd_text(), Gfx::TextAlignment::CenterLeft, wm.palette().selection_text());
|
||||
}
|
||||
if (wm.dnd_bitmap()) {
|
||||
|
|
|
@ -133,7 +133,7 @@ Window& Menu::ensure_menu_window()
|
|||
else if (item.type() == MenuItem::Separator)
|
||||
height = 8;
|
||||
item.set_rect({ next_item_location, { width - frame_thickness() * 2, height } });
|
||||
next_item_location.move_by(0, height);
|
||||
next_item_location.translate_by(0, height);
|
||||
}
|
||||
|
||||
int window_height_available = Screen::the().height() - frame_thickness() * 2;
|
||||
|
@ -236,7 +236,7 @@ void Menu::draw()
|
|||
painter.blit_filtered(icon_rect.location().translated(1, 1), *item.icon(), item.icon()->rect(), [&shadow_color](auto) {
|
||||
return shadow_color;
|
||||
});
|
||||
icon_rect.move_by(-1, -1);
|
||||
icon_rect.translate_by(-1, -1);
|
||||
}
|
||||
if (item.is_enabled())
|
||||
painter.blit(icon_rect.location(), *item.icon(), item.icon()->rect());
|
||||
|
|
|
@ -123,7 +123,7 @@ void Screen::on_receive_mouse_data(const MousePacket& packet)
|
|||
{
|
||||
auto prev_location = m_physical_cursor_location / m_scale_factor;
|
||||
if (packet.is_relative) {
|
||||
m_physical_cursor_location.move_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor);
|
||||
m_physical_cursor_location.translate_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor);
|
||||
dbgln_if(WSSCREEN_DEBUG, "Screen: New Relative mouse point @ {}", m_physical_cursor_location);
|
||||
} else {
|
||||
m_physical_cursor_location = { packet.x * physical_width() / 0xffff, packet.y * physical_height() / 0xffff };
|
||||
|
|
|
@ -541,7 +541,7 @@ bool Window::invalidate_no_notify(const Gfx::IntRect& rect, bool with_frame)
|
|||
|
||||
auto outer_rect = frame().render_rect();
|
||||
auto inner_rect = rect;
|
||||
inner_rect.move_by(position());
|
||||
inner_rect.translate_by(position());
|
||||
// FIXME: This seems slightly wrong; the inner rect shouldn't intersect the border part of the outer rect.
|
||||
inner_rect.intersect(outer_rect);
|
||||
if (inner_rect.is_empty())
|
||||
|
@ -976,7 +976,7 @@ void Window::set_menubar(Menubar* menubar)
|
|||
m_menubar->for_each_menu([&](Menu& menu) {
|
||||
int text_width = wm.font().width(Gfx::parse_ampersand_string(menu.name()));
|
||||
menu.set_rect_in_window_menubar({ next_menu_location.x(), 0, text_width + menubar_menu_margin, menubar_rect.height() });
|
||||
next_menu_location.move_by(menu.rect_in_window_menubar().width(), 0);
|
||||
next_menu_location.translate_by(menu.rect_in_window_menubar().width(), 0);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -301,7 +301,7 @@ void WindowFrame::paint_menubar(Gfx::Painter& painter)
|
|||
auto text_rect = menu.rect_in_window_menubar();
|
||||
Color text_color = palette.window_text();
|
||||
if (MenuManager::the().is_open(menu))
|
||||
text_rect.move_by(1, 1);
|
||||
text_rect.translate_by(1, 1);
|
||||
bool paint_as_pressed = MenuManager::the().is_open(menu);
|
||||
bool paint_as_hovered = !paint_as_pressed && &menu == MenuManager::the().hovered_menu();
|
||||
if (paint_as_pressed || paint_as_hovered) {
|
||||
|
@ -546,7 +546,7 @@ void WindowFrame::invalidate(Gfx::IntRect relative_rect)
|
|||
{
|
||||
auto frame_rect = rect();
|
||||
auto window_rect = m_window.rect();
|
||||
relative_rect.move_by(frame_rect.x() - window_rect.x(), frame_rect.y() - window_rect.y());
|
||||
relative_rect.translate_by(frame_rect.x() - window_rect.x(), frame_rect.y() - window_rect.y());
|
||||
m_dirty = true;
|
||||
m_window.invalidate(relative_rect, true);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue