1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:57:35 +00:00

HexEditor: Extract some content-width calculations

We repeat the same calculations a lot, and it's easy to make mistakes.

m_address_bar_width and offset_margin_width() have basically the same
purpose, but both are a little wrong. This removes the former, but
we'll get to the latter soon.
This commit is contained in:
Sam Atkins 2024-02-05 17:23:13 +00:00 committed by Sam Atkins
parent 4dc3816853
commit c4dc150ed7
2 changed files with 18 additions and 16 deletions

View file

@ -102,7 +102,6 @@ private:
RefPtr<GUI::Action> m_edit_annotation_action;
RefPtr<GUI::Action> m_delete_annotation_action;
static constexpr int m_address_bar_width = 90;
static constexpr int m_padding = 5;
void scroll_position_into_view(size_t position);
@ -113,6 +112,10 @@ private:
size_t cell_width() const { return character_width() * 3; }
size_t offset_margin_width() const { return 80; }
int offset_area_width() const { return offset_margin_width() + m_padding; }
int hex_area_width() const { return m_padding + m_bytes_per_row * cell_width() + m_padding; }
int text_area_width() const { return m_padding + m_bytes_per_row * character_width() + m_padding; }
struct OffsetData {
size_t offset;
EditMode panel;