| 1 |
#pragma once |
| 2 |
|
| 3 |
#include <QAbstractScrollArea> |
| 4 |
#include <QStaticText> |
| 5 |
|
| 6 |
#include "glyph.h" |
| 7 |
|
| 8 |
class GlyphsView : public QAbstractScrollArea |
| 9 |
{ |
| 10 |
Q_OBJECT |
| 11 |
|
| 12 |
public: |
| 13 |
explicit GlyphsView(QWidget *parent = nullptr); |
| 14 |
|
| 15 |
void setFontInfo(const FontInfo &fi); |
| 16 |
void setGlyph(int idx, const Glyph &glyph); |
| 17 |
#ifdef WITH_FREETYPE |
| 18 |
void setFTGlyph(int idx, const Glyph &glyph); |
| 19 |
#endif |
| 20 |
#ifdef WITH_HARFBUZZ |
| 21 |
void setHBGlyph(int idx, const Glyph &glyph); |
| 22 |
#endif |
| 23 |
|
| 24 |
void setDrawBboxes(const bool flag); |
| 25 |
void setDrawGlyphs(const bool flag); |
| 26 |
void setDrawFTGlyphs(const bool flag); |
| 27 |
void setDrawHBGlyphs(const bool flag); |
| 28 |
|
| 29 |
private: |
| 30 |
void paintEvent(QPaintEvent *); |
| 31 |
void drawGrid(QPainter &p, const double cellHeight); |
| 32 |
|
| 33 |
void mousePressEvent(QMouseEvent *e); |
| 34 |
void mouseMoveEvent(QMouseEvent *e); |
| 35 |
void mouseReleaseEvent(QMouseEvent *e); |
| 36 |
void wheelEvent(QWheelEvent *e); |
| 37 |
|
| 38 |
void resizeEvent(QResizeEvent *); |
| 39 |
|
| 40 |
void updateScrollBars(); |
| 41 |
|
| 42 |
private: |
| 43 |
QPoint m_mousePressPos; |
| 44 |
QPoint m_origOffset; |
| 45 |
|
| 46 |
double m_scale = 0.05; |
| 47 |
bool m_drawBboxes = true; |
| 48 |
bool m_drawGlyphs = true; |
| 49 |
bool m_drawFTGlyphs = false; |
| 50 |
bool m_drawHBGlyphs = false; |
| 51 |
|
| 52 |
FontInfo m_fontInfo; |
| 53 |
QVector<Glyph> m_glyphs; |
| 54 |
#ifdef WITH_FREETYPE |
| 55 |
QVector<Glyph> m_ftGlyphs; |
| 56 |
#endif |
| 57 |
#ifdef WITH_HARFBUZZ |
| 58 |
QVector<Glyph> m_hbGlyphs; |
| 59 |
#endif |
| 60 |
QVector<QStaticText> m_indexes; |
| 61 |
}; |