From 02f6f6769b36361d3619fa8d0f4bd8389f6b118e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 7 Nov 2014 08:56:50 -0800 Subject: [PATCH] Enable different copies of otherwise identical text renderers Needed when using computeWidth() because it messes up draw() rendering. --- interface/src/ui/TextRenderer.cpp | 7 ++++--- interface/src/ui/TextRenderer.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/TextRenderer.cpp b/interface/src/ui/TextRenderer.cpp index 69df609ba9..f64f895d81 100644 --- a/interface/src/ui/TextRenderer.cpp +++ b/interface/src/ui/TextRenderer.cpp @@ -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); diff --git a/interface/src/ui/TextRenderer.h b/interface/src/ui/TextRenderer.h index bcb0ce8890..b3a3e98b1d 100644 --- a/interface/src/ui/TextRenderer.h +++ b/interface/src/ui/TextRenderer.h @@ -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();