mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
FontEditor: Inherit GlyphMapWidget from ScrollableWidget
This makes it easier to work in FontEditor at low resolution. Previously glyph map resized itself and the parent window to accomodate fonts, which isn't ideal. Users typically control window size/position after launch; widgets have to make do.
This commit is contained in:
parent
e8c1288e2c
commit
d115b29a5b
2 changed files with 50 additions and 20 deletions
|
@ -26,25 +26,22 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
#include <LibGUI/ScrollableWidget.h>
|
||||
#include <LibGfx/BitmapFont.h>
|
||||
|
||||
class GlyphMapWidget final : public GUI::Frame {
|
||||
class GlyphMapWidget final : public GUI::ScrollableWidget {
|
||||
C_OBJECT(GlyphMapWidget)
|
||||
public:
|
||||
virtual ~GlyphMapWidget() override;
|
||||
|
||||
void initialize(Gfx::BitmapFont&);
|
||||
|
||||
int selected_glyph() const { return m_selected_glyph; }
|
||||
void set_selected_glyph(int);
|
||||
|
||||
int rows() const { return ceil_div(m_glyph_count, m_columns); }
|
||||
int rows() const { return m_rows; }
|
||||
int columns() const { return m_columns; }
|
||||
|
||||
int preferred_width() const;
|
||||
int preferred_height() const;
|
||||
|
||||
Gfx::BitmapFont& font() { return *m_font; }
|
||||
const Gfx::BitmapFont& font() const { return *m_font; }
|
||||
|
||||
|
@ -53,16 +50,19 @@ public:
|
|||
Function<void(int)> on_glyph_selected;
|
||||
|
||||
private:
|
||||
explicit GlyphMapWidget(Gfx::BitmapFont&);
|
||||
GlyphMapWidget();
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
|
||||
Gfx::IntRect get_outer_rect(int glyph) const;
|
||||
void scroll_to_glyph(int glyph);
|
||||
|
||||
RefPtr<Gfx::BitmapFont> m_font;
|
||||
int m_glyph_count;
|
||||
int m_glyph_count { 384 };
|
||||
int m_columns { 32 };
|
||||
int m_rows { 12 };
|
||||
int m_horizontal_spacing { 2 };
|
||||
int m_vertical_spacing { 2 };
|
||||
int m_selected_glyph { 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue