1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:27: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:
Matthew Olsson 2021-04-12 11:47:09 -07:00 committed by Andreas Kling
parent ac238b3bd6
commit 88cfaf7bf0
48 changed files with 282 additions and 187 deletions

View file

@ -242,7 +242,7 @@ int KeysWidget::note_for_event_position(const Gfx::IntPoint& a_point) const
return -1;
auto point = a_point;
point.move_by(-frame_thickness(), -frame_thickness());
point.translate_by(-frame_thickness(), -frame_thickness());
int white_keys = point.x() / white_key_width;
int note = note_from_white_keys(white_keys);

View file

@ -112,7 +112,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
const char* note_name = note_names[note % notes_per_octave];
background_painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft);
note_name_rect.move_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0);
note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0);
if (note % notes_per_octave == 0)
background_painter.draw_text(note_name_rect, String::formatted("{}", note / notes_per_octave + 1), Gfx::TextAlignment::CenterLeft);
}

View file

@ -162,7 +162,7 @@ GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(const GUI::MouseEv
GUI::MouseEvent ImageEditor::event_adjusted_for_layer(const GUI::MouseEvent& event, const Layer& layer) const
{
auto image_position = editor_position_to_image_position(event.position());
image_position.move_by(-layer.location().x(), -layer.location().y());
image_position.translate_by(-layer.location().x(), -layer.location().y());
return {
static_cast<GUI::Event::Type>(event.type()),
Gfx::IntPoint(image_position.x(), image_position.y()),

View file

@ -71,7 +71,7 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event)
auto adjusted_rect = gadget.rect;
if (gadget.is_moving) {
adjusted_rect.move_by(0, gadget.movement_delta.y());
adjusted_rect.translate_by(0, gadget.movement_delta.y());
}
if (gadget.is_moving) {

View file

@ -66,16 +66,16 @@ void MoveTool::on_keydown(GUI::KeyEvent& event)
switch (event.key()) {
case Key_Up:
new_location.move_by(0, -1);
new_location.translate_by(0, -1);
break;
case Key_Down:
new_location.move_by(0, 1);
new_location.translate_by(0, 1);
break;
case Key_Left:
new_location.move_by(-1, 0);
new_location.translate_by(-1, 0);
break;
case Key_Right:
new_location.move_by(1, 0);
new_location.translate_by(1, 0);
break;
default:
return;

View file

@ -96,10 +96,10 @@ void TreeMapWidget::paint_cell_frame(GUI::Painter& painter, const TreeMapNode& n
painter.clear_clip_rect();
painter.add_clip_rect(cell_rect);
Gfx::IntRect text_rect = remainder;
text_rect.move_by(2, 2);
text_rect.translate_by(2, 2);
painter.draw_text(text_rect, node.name(), font(), Gfx::TextAlignment::TopLeft, Color::Black);
if (node_is_leaf(node)) {
text_rect.move_by(0, font().presentation_size() + 1);
text_rect.translate_by(0, font().presentation_size() + 1);
painter.draw_text(text_rect, human_readable_size(node.area()), font(), Gfx::TextAlignment::TopLeft, Color::Black);
}
painter.clear_clip_rect();