Enable different copies of otherwise identical text renderers

Needed when using computeWidth() because it messes up draw() rendering.
This commit is contained in:
David Rowe 2014-11-07 08:56:50 -08:00
parent 3323ac11ff
commit 02f6f6769b
2 changed files with 6 additions and 4 deletions

View file

@ -37,12 +37,13 @@ static uint qHash(const TextRenderer::Properties& key, uint seed = 0) {
}
static bool operator==(const TextRenderer::Properties& p1, const TextRenderer::Properties& p2) {
return p1.font == p2.font && p1.effect == p2.effect && p1.effectThickness == p2.effectThickness && p1.color == p2.color;
return p1.font == p2.font && p1.effect == p2.effect && p1.effectThickness == p2.effectThickness && p1.color == p2.color
&& p1.copy == p2.copy;
}
TextRenderer* TextRenderer::getInstance(const char* family, int pointSize, int weight, bool italic,
EffectType effect, int effectThickness, const QColor& color) {
Properties properties = { QFont(family, pointSize, weight, italic), effect, effectThickness, color };
EffectType effect, int effectThickness, const QColor& color, int copy) {
Properties properties = { QFont(family, pointSize, weight, italic), effect, effectThickness, color, copy };
TextRenderer*& instance = _instances[properties];
if (!instance) {
instance = new TextRenderer(properties);

View file

@ -50,10 +50,11 @@ public:
EffectType effect;
int effectThickness;
QColor color;
int copy; // Use to separate renderers that are otherwise identical.
};
static TextRenderer* getInstance(const char* family, int pointSize = -1, int weight = -1, bool italic = false,
EffectType effect = NO_EFFECT, int effectThickness = 1, const QColor& color = QColor(255, 255, 255));
EffectType effect = NO_EFFECT, int effectThickness = 1, const QColor& color = QColor(255, 255, 255), int copy = 0);
~TextRenderer();