mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
FontEditor: Add scaled offset members to GlyphEditor
Previously these were undescriptive globals making them a bit cryptic.
This commit is contained in:
parent
aa09e40eb2
commit
541f1de3a8
2 changed files with 7 additions and 8 deletions
|
@ -13,9 +13,6 @@
|
||||||
#include <LibGfx/Palette.h>
|
#include <LibGfx/Palette.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static int x_offset;
|
|
||||||
static int y_offset;
|
|
||||||
|
|
||||||
GlyphEditorWidget::~GlyphEditorWidget()
|
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 x = s_max_width; x < s_max_width + bitmap.width(); x++)
|
||||||
for (int y = s_max_height; y < s_max_height + bitmap.height(); y++)
|
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);
|
m_movable_bits[x][y] = bitmap.bit_at(x - s_max_width, y - s_max_height);
|
||||||
x_offset = (event.x() - 1) / m_scale;
|
m_scaled_offset_x = (event.x() - 1) / m_scale;
|
||||||
y_offset = (event.y() - 1) / m_scale;
|
m_scaled_offset_y = (event.y() - 1) / m_scale;
|
||||||
move_at_mouse(event);
|
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)
|
void GlyphEditorWidget::move_at_mouse(const GUI::MouseEvent& event)
|
||||||
{
|
{
|
||||||
int x_delta = ((event.x() - 1) / m_scale) - x_offset;
|
int x_delta = ((event.x() - 1) / m_scale) - m_scaled_offset_x;
|
||||||
int y_delta = ((event.y() - 1) / m_scale) - y_offset;
|
int y_delta = ((event.y() - 1) / m_scale) - m_scaled_offset_y;
|
||||||
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
auto bitmap = font().raw_glyph(m_glyph).glyph_bitmap();
|
||||||
if (abs(x_delta) > bitmap.width() || abs(y_delta) > bitmap.height())
|
if (abs(x_delta) > bitmap.width() || abs(y_delta) > bitmap.height())
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -72,7 +72,9 @@ private:
|
||||||
RefPtr<Gfx::BitmapFont> m_font;
|
RefPtr<Gfx::BitmapFont> m_font;
|
||||||
int m_glyph { 0 };
|
int m_glyph { 0 };
|
||||||
int m_scale { 10 };
|
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 };
|
Mode m_mode { Paint };
|
||||||
bool m_is_clicking_valid_cell { false };
|
bool m_is_clicking_valid_cell { false };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue