summaryrefslogtreecommitdiff
path: root/Userland/Applications
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
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')
-rw-r--r--Userland/Applications/FontEditor/GlyphEditorWidget.cpp14
-rw-r--r--Userland/Applications/FontEditor/GlyphEditorWidget.h5
-rw-r--r--Userland/Applications/FontEditor/NewFontDialog.cpp9
-rw-r--r--Userland/Applications/FontEditor/UndoGlyph.h2
4 files changed, 15 insertions, 15 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)
diff --git a/Userland/Applications/FontEditor/GlyphEditorWidget.h b/Userland/Applications/FontEditor/GlyphEditorWidget.h
index 4a83f7c51e..fab2a25fdc 100644
--- a/Userland/Applications/FontEditor/GlyphEditorWidget.h
+++ b/Userland/Applications/FontEditor/GlyphEditorWidget.h
@@ -10,9 +10,6 @@
#include <LibGUI/Frame.h>
#include <LibGfx/BitmapFont.h>
-static constexpr int s_max_width = 32;
-static constexpr int s_max_height = 36;
-
class GlyphEditorWidget final : public GUI::Frame {
C_OBJECT(GlyphEditorWidget)
public:
@@ -74,7 +71,7 @@ private:
int m_scale { 10 };
int m_scaled_offset_x { 0 };
int m_scaled_offset_y { 0 };
- u8 m_movable_bits[s_max_width* 3][s_max_height * 3] = {};
+ u8 m_movable_bits[Gfx::GlyphBitmap::max_width() * 3][Gfx::GlyphBitmap::max_height() * 3] {};
Mode m_mode { Paint };
bool m_is_clicking_valid_cell { false };
};
diff --git a/Userland/Applications/FontEditor/NewFontDialog.cpp b/Userland/Applications/FontEditor/NewFontDialog.cpp
index 28be069c04..91c296080b 100644
--- a/Userland/Applications/FontEditor/NewFontDialog.cpp
+++ b/Userland/Applications/FontEditor/NewFontDialog.cpp
@@ -23,9 +23,6 @@
#include <LibGfx/FontStyleMapping.h>
#include <LibGfx/Palette.h>
-static constexpr int s_max_width = 32;
-static constexpr int s_max_height = 36;
-
namespace GUI {
class GlyphPreviewWidget final : public Frame {
@@ -120,7 +117,7 @@ private:
int m_glyph_width { 20 };
int m_mean_line { 2 };
int m_baseline { 16 };
- u8 m_bits[s_max_width][s_max_height] {};
+ u8 m_bits[Gfx::GlyphBitmap::max_width()][Gfx::GlyphBitmap::max_height()] {};
};
}
@@ -172,8 +169,8 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window)
m_glyph_height_spinbox->set_value(20);
m_glyph_width_spinbox->set_value(20);
- m_glyph_height_spinbox->set_max(s_max_height);
- m_glyph_width_spinbox->set_max(s_max_width);
+ m_glyph_height_spinbox->set_max(Gfx::GlyphBitmap::max_height());
+ m_glyph_width_spinbox->set_max(Gfx::GlyphBitmap::max_width());
m_mean_line_spinbox->set_value(2);
m_baseline_spinbox->set_value(16);
m_mean_line_spinbox->set_max(max(m_glyph_height_spinbox->value() - 2, 0));
diff --git a/Userland/Applications/FontEditor/UndoGlyph.h b/Userland/Applications/FontEditor/UndoGlyph.h
index eb432d2106..dd8db85191 100644
--- a/Userland/Applications/FontEditor/UndoGlyph.h
+++ b/Userland/Applications/FontEditor/UndoGlyph.h
@@ -45,7 +45,7 @@ public:
private:
size_t m_code_point;
RefPtr<Gfx::BitmapFont> m_font;
- u8 m_bits[32][36] = {};
+ u8 m_bits[Gfx::GlyphBitmap::max_width()][Gfx::GlyphBitmap::max_height()] {};
u8 m_width { 0 };
mutable u8 m_restored_width { 0 };
mutable u32 m_restored_code_point { 0 };