1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

HexEditor: Store annotations in a Model

A model is necessary for displaying a list of them in the UI. We might
as well make that their home.
This commit is contained in:
Sam Atkins 2024-01-30 11:08:41 +00:00 committed by Sam Atkins
parent a54952795a
commit 8cac2e89a9
8 changed files with 157 additions and 46 deletions

View file

@ -347,7 +347,7 @@ void HexEditor::mousemove_event(GUI::MouseEvent& event)
if (maybe_offset_data.has_value()) {
set_override_cursor(Gfx::StandardCursor::IBeam);
m_hovered_annotation = m_document->closest_annotation_at(maybe_offset_data->offset);
m_hovered_annotation = m_document->annotations().closest_annotation_at(maybe_offset_data->offset);
} else {
set_override_cursor(Gfx::StandardCursor::None);
m_hovered_annotation.clear();
@ -631,7 +631,7 @@ void HexEditor::paint_event(GUI::PaintEvent& event)
return;
auto const cell = m_document->get(byte_position);
auto const annotation = m_document->closest_annotation_at(byte_position);
auto const annotation = m_document->annotations().closest_annotation_at(byte_position);
Gfx::IntRect hex_display_rect_high_nibble {
frame_thickness() + offset_margin_width() + j * cell_width() + 2 * m_padding,
@ -933,7 +933,7 @@ void HexEditor::show_delete_annotation_dialog(Annotation& annotation)
{
auto result = GUI::MessageBox::show(window(), "Delete this annotation?"sv, "Delete annotation?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
if (result == GUI::Dialog::ExecResult::Yes) {
m_document->delete_annotation(annotation);
m_document->annotations().delete_annotation(annotation);
update();
}
}