RhythmGame 1.4.3
Loading...
Searching...
No Matches
Lr2BitmapFontTexture.h
Go to the documentation of this file.
1#pragma once
2
3#include <QColor>
4#include <QImage>
5#include <QQuickItem>
6#include <QRectF>
7#include <QSizeF>
8#include <QString>
9#include <QtQml/qqmlregistration.h>
10
11class Lr2BitmapFontTexture : public QQuickItem {
12 Q_OBJECT
13 QML_ELEMENT
14 Q_PROPERTY(QString fontPath READ fontPath WRITE setFontPath NOTIFY fontPathChanged)
15 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
16 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
18 Q_PROPERTY(int alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
19 Q_PROPERTY(bool uppercase READ uppercase WRITE setUppercase NOTIFY uppercaseChanged)
20 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
21 Q_PROPERTY(qreal naturalWidth READ naturalWidth NOTIFY naturalSizeChanged)
22 Q_PROPERTY(qreal naturalHeight READ naturalHeight NOTIFY naturalSizeChanged)
23 Q_PROPERTY(qreal textureHeight READ textureHeight NOTIFY naturalSizeChanged)
24
25public:
26 explicit Lr2BitmapFontTexture(QQuickItem* parent = nullptr);
27
28 QString fontPath() const;
29 void setFontPath(const QString& value);
30
31 QString text() const;
32 void setText(const QString& value);
33
34 QColor textColor() const;
35 void setTextColor(const QColor& value);
36
37 int textureFilter() const;
38 void setTextureFilter(int value);
39
40 int alignment() const;
41 void setAlignment(int value);
42
43 bool uppercase() const;
44 void setUppercase(bool value);
45
46 bool isActive() const;
47 void setActive(bool value);
48
49 qreal naturalWidth() const;
50 qreal naturalHeight() const;
51 qreal textureHeight() const;
52
53signals:
62
63protected:
64 QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) override;
65 void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override;
66
67private:
68 QRectF renderRect() const;
69 bool updateRenderedText();
70 void rebuildImage();
71 static bool colorNeedsTint(const QColor& color);
72 static QImage tintedImage(const QImage& image, const QColor& color);
73
74 QString m_fontPath;
75 QString m_text;
76 QString m_renderedText;
77 QImage m_baseImage;
78 QColor m_textColor = Qt::white;
79 QImage m_image;
80 QSizeF m_naturalSize;
81 int m_textureFilter = 1;
82 int m_alignment = 0;
83 bool m_uppercase = false;
84 bool m_active = true;
85 bool m_textureDirty = true;
86};
double value
Definition BmsNotesData.cpp:35
Definition Lr2BitmapFontTexture.h:11
void setTextColor(const QColor &value)
Definition Lr2BitmapFontTexture.cpp:78
void setAlignment(int value)
Definition Lr2BitmapFontTexture.cpp:109
QML_ELEMENTQString fontPath
Definition Lr2BitmapFontTexture.h:14
qreal naturalWidth
Definition Lr2BitmapFontTexture.h:21
qreal textureHeight
Definition Lr2BitmapFontTexture.h:23
int alignment
Definition Lr2BitmapFontTexture.h:18
void setActive(bool value)
Definition Lr2BitmapFontTexture.cpp:139
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
Definition Lr2BitmapFontTexture.cpp:210
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
Definition Lr2BitmapFontTexture.cpp:163
bool uppercase
Definition Lr2BitmapFontTexture.h:19
void setUppercase(bool value)
Definition Lr2BitmapFontTexture.cpp:123
QColor textColor
Definition Lr2BitmapFontTexture.h:16
QString text
Definition Lr2BitmapFontTexture.h:15
bool active
Definition Lr2BitmapFontTexture.h:20
int textureFilter
Definition Lr2BitmapFontTexture.h:17
void setFontPath(const QString &value)
Definition Lr2BitmapFontTexture.cpp:48
void setText(const QString &value)
Definition Lr2BitmapFontTexture.cpp:62
bool isActive() const
Definition Lr2BitmapFontTexture.cpp:135
void setTextureFilter(int value)
Definition Lr2BitmapFontTexture.cpp:94
qreal naturalHeight
Definition Lr2BitmapFontTexture.h:22