mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47: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
|
@ -142,7 +142,7 @@ bool BlockBox::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsi
|
|||
if (!is_scrollable())
|
||||
return false;
|
||||
auto new_offset = m_scroll_offset;
|
||||
new_offset.move_by(0, wheel_delta);
|
||||
new_offset.translate_by(0, wheel_delta);
|
||||
set_scroll_offset(new_offset);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -550,7 +550,7 @@ static Gfx::FloatRect rect_in_coordinate_space(const Box& box, const Box& contex
|
|||
for (auto* ancestor = box.parent(); ancestor; ancestor = ancestor->parent()) {
|
||||
if (is<Box>(*ancestor)) {
|
||||
auto offset = downcast<Box>(*ancestor).effective_offset();
|
||||
rect.move_by(offset);
|
||||
rect.translate_by(offset);
|
||||
}
|
||||
if (ancestor == &context_box)
|
||||
break;
|
||||
|
|
|
@ -154,7 +154,7 @@ const Gfx::FloatRect Box::absolute_rect() const
|
|||
{
|
||||
Gfx::FloatRect rect { effective_offset(), size() };
|
||||
for (auto* block = containing_block(); block; block = block->containing_block()) {
|
||||
rect.move_by(block->effective_offset());
|
||||
rect.translate_by(block->effective_offset());
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ void ButtonBox::paint(PaintContext& context, PaintPhase phase)
|
|||
|
||||
auto text_rect = enclosing_int_rect(absolute_rect());
|
||||
if (m_being_pressed)
|
||||
text_rect.move_by(1, 1);
|
||||
text_rect.translate_by(1, 1);
|
||||
context.painter().draw_text(text_rect, dom_node().value(), font(), Gfx::TextAlignment::Center, context.palette().button_text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ void FrameBox::paint(PaintContext& context, PaintPhase phase)
|
|||
|
||||
if constexpr (HIGHLIGHT_FOCUSED_FRAME_DEBUG) {
|
||||
if (dom_node().content_frame()->is_focused_frame()) {
|
||||
context.painter().draw_rect(absolute_rect().to<int>(), Color::Cyan);
|
||||
context.painter().draw_rect(absolute_rect().to_type<int>(), Color::Cyan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ bool ImageBox::renders_as_alt_text() const
|
|||
|
||||
void ImageBox::frame_did_set_viewport_rect(const Gfx::IntRect& viewport_rect)
|
||||
{
|
||||
m_image_loader.set_visible_in_viewport(viewport_rect.to<float>().intersects(absolute_rect()));
|
||||
m_image_loader.set_visible_in_viewport(viewport_rect.to_type<float>().intersects(absolute_rect()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode)
|
|||
// Shift subsequent sibling fragments to the right to adjust for change in width.
|
||||
for (size_t j = i + 1; j < line_box.fragments().size(); ++j) {
|
||||
auto offset = line_box.fragments()[j].offset();
|
||||
offset.move_by(diff, 0);
|
||||
offset.translate_by(diff, 0);
|
||||
line_box.fragments()[j].set_offset(offset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ const Gfx::FloatRect LineBoxFragment::absolute_rect() const
|
|||
{
|
||||
Gfx::FloatRect rect { {}, size() };
|
||||
rect.set_location(m_layout_node.containing_block()->absolute_position());
|
||||
rect.move_by(offset());
|
||||
rect.translate_by(offset());
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ bool Node::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned
|
|||
if (!containing_block->is_scrollable())
|
||||
return false;
|
||||
auto new_offset = containing_block->scroll_offset();
|
||||
new_offset.move_by(0, wheel_delta);
|
||||
new_offset.translate_by(0, wheel_delta);
|
||||
containing_block->set_scroll_offset(new_offset);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue