summaryrefslogtreecommitdiff
path: root/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2021-11-29 10:33:34 -0500
committerAndreas Kling <kling@serenityos.org>2021-11-30 10:51:51 +0100
commite29abc5395b9846aadbb18a74fb4673ebe37d696 (patch)
tree5c29d84b13c449784607ac6dfc957f7b7339b9b9 /Userland/Applications/FontEditor/GlyphEditorWidget.cpp
parent541f1de3a81bace0f48f29c04983b93087b7eb9e (diff)
downloadserenity-e29abc5395b9846aadbb18a74fb4673ebe37d696.zip
LibGfx+FontEditor: Consolidate BitmapFont width and height limits
And make them more self-documenting. Previously these constraints were duplicated across multiple files.
Diffstat (limited to 'Userland/Applications/FontEditor/GlyphEditorWidget.cpp')
-rw-r--r--Userland/Applications/FontEditor/GlyphEditorWidget.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
index 237c26e10c..8e8236f4a2 100644
--- a/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
+++ b/Userland/Applications/FontEditor/GlyphEditorWidget.cpp
@@ -184,9 +184,13 @@ void GlyphEditorWidget::mousedown_event(GUI::MouseEvent& event)
} else {
memset(m_movable_bits, 0, sizeof(m_movable_bits));
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
- 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);
+ for (int x = 0; x < bitmap.width(); x++) {
+ for (int y = 0; y < bitmap.height(); y++) {
+ int movable_x = Gfx::GlyphBitmap::max_width() + x;
+ int movable_y = Gfx::GlyphBitmap::max_height() + y;
+ m_movable_bits[movable_x][movable_y] = bitmap.bit_at(x, y);
+ }
+ }
m_scaled_offset_x = (event.x() - 1) / m_scale;
m_scaled_offset_y = (event.y() - 1) / m_scale;
move_at_mouse(event);
@@ -250,7 +254,9 @@ void GlyphEditorWidget::move_at_mouse(const GUI::MouseEvent& event)
return;
for (int x = 0; x < bitmap.width(); x++) {
for (int y = 0; y < bitmap.height(); y++) {
- bitmap.set_bit_at(x, y, m_movable_bits[s_max_width + x - x_delta][s_max_height + y - y_delta]);
+ int movable_x = Gfx::GlyphBitmap::max_width() + x - x_delta;
+ int movable_y = Gfx::GlyphBitmap::max_height() + y - y_delta;
+ bitmap.set_bit_at(x, y, m_movable_bits[movable_x][movable_y]);
}
}
if (on_glyph_altered)