Files
ladybird/Applications/FontEditor/GlyphEditorWidget.h
Andreas Kling f2580dcfeb FontEditor: Remove weird focus rects and optimize repaint while drawing.
I added focus rects to these widgets because I had just started working on
focus support and I was excited but it doesn't really make sense for these
things to have focus rects. :^)

While I was here I also optimized the repaint code to only update the edited
glyph in the glyph map when editing its pixels.
2019-04-06 15:28:06 +02:00

32 lines
837 B
C++

#include <LibGUI/GWidget.h>
#include <AK/Function.h>
class GlyphEditorWidget final : public GWidget {
public:
GlyphEditorWidget(Font&, GWidget* parent);
virtual ~GlyphEditorWidget() override;
byte glyph() const { return m_glyph; }
void set_glyph(byte);
int preferred_width() const;
int preferred_height() const;
Font& font() { return *m_font; }
const Font& font() const { return *m_font; }
Function<void(byte)> on_glyph_altered;
private:
virtual void paint_event(GPaintEvent&) override;
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual bool accepts_focus() const override { return true; }
void draw_at_mouse(const GMouseEvent&);
RetainPtr<Font> m_font;
byte m_glyph { 0 };
int m_scale { 10 };
};