From 541f1de3a81bace0f48f29c04983b93087b7eb9e Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Mon, 29 Nov 2021 10:22:46 -0500 Subject: [PATCH] FontEditor: Add scaled offset members to GlyphEditor Previously these were undescriptive globals making them a bit cryptic. --- .../Applications/FontEditor/GlyphEditorWidget.cpp | 11 ++++------- Userland/Applications/FontEditor/GlyphEditorWidget.h | 4 +++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp index 8c8c935f69..237c26e10c 100644 --- a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp @@ -13,9 +13,6 @@ #include #include -static int x_offset; -static int y_offset; - GlyphEditorWidget::~GlyphEditorWidget() { } @@ -190,8 +187,8 @@ void GlyphEditorWidget::mousedown_event(GUI::MouseEvent& event) for (int x = s_max_width; x < s_max_width + bitmap.width(); x++) for (int y = s_max_height; y < s_max_height + bitmap.height(); y++) m_movable_bits[x][y] = bitmap.bit_at(x - s_max_width, y - s_max_height); - x_offset = (event.x() - 1) / m_scale; - y_offset = (event.y() - 1) / m_scale; + m_scaled_offset_x = (event.x() - 1) / m_scale; + m_scaled_offset_y = (event.y() - 1) / m_scale; move_at_mouse(event); } } @@ -246,8 +243,8 @@ void GlyphEditorWidget::draw_at_mouse(const GUI::MouseEvent& event) void GlyphEditorWidget::move_at_mouse(const GUI::MouseEvent& event) { - int x_delta = ((event.x() - 1) / m_scale) - x_offset; - int y_delta = ((event.y() - 1) / m_scale) - y_offset; + int x_delta = ((event.x() - 1) / m_scale) - m_scaled_offset_x; + int y_delta = ((event.y() - 1) / m_scale) - m_scaled_offset_y; auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap(); if (abs(x_delta) > bitmap.width() || abs(y_delta) > bitmap.height()) return; diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.h b/Userland/Applications/FontEditor/GlyphEditorWidget.h index c743fcdabc..4a83f7c51e 100644 --- a/Userland/Applications/FontEditor/GlyphEditorWidget.h +++ b/Userland/Applications/FontEditor/GlyphEditorWidget.h @@ -72,7 +72,9 @@ private: RefPtr m_font; int m_glyph { 0 }; int m_scale { 10 }; - u8 m_movable_bits[s_max_width * 3][s_max_height * 3] = {}; + int m_scaled_offset_x { 0 }; + int m_scaled_offset_y { 0 }; + u8 m_movable_bits[s_max_width* 3][s_max_height * 3] = {}; Mode m_mode { Paint }; bool m_is_clicking_valid_cell { false }; };