mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
FontEditor: Add move glyph tool
When toggled on, glyphs can now be repositioned within the glyph editor by dragging the mouse
This commit is contained in:
parent
44cd121e30
commit
bada590b91
5 changed files with 101 additions and 8 deletions
|
@ -10,9 +10,17 @@
|
|||
#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:
|
||||
enum Mode {
|
||||
Paint,
|
||||
Move
|
||||
};
|
||||
|
||||
virtual ~GlyphEditorWidget() override;
|
||||
|
||||
void initialize(Gfx::BitmapFont&);
|
||||
|
@ -34,6 +42,9 @@ public:
|
|||
int scale() const { return m_scale; }
|
||||
void set_scale(int scale);
|
||||
|
||||
Mode mode() const { return m_mode; }
|
||||
void set_mode(Mode mode) { m_mode = mode; }
|
||||
|
||||
Function<void(int)> on_glyph_altered;
|
||||
Function<void(bool finalize)> on_undo_event;
|
||||
|
||||
|
@ -42,10 +53,15 @@ private:
|
|||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void enter_event(Core::Event&) override;
|
||||
|
||||
void draw_at_mouse(const GUI::MouseEvent&);
|
||||
void move_at_mouse(const GUI::MouseEvent&);
|
||||
|
||||
RefPtr<Gfx::BitmapFont> m_font;
|
||||
int m_glyph { 0 };
|
||||
int m_scale { 10 };
|
||||
u8 m_movable_bits[s_max_width * 3][s_max_height * 3] = {};
|
||||
Mode m_mode { Paint };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue