Mercurial > hg > svgui
diff layer/PaintAssistant.cpp @ 1216:dc2af6616c83
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:50 +0000 |
parents | 1badacff7ab2 |
children | dc6457ac4d07 |
line wrap: on
line diff
--- a/layer/PaintAssistant.cpp Fri Mar 04 12:23:31 2016 +0000 +++ b/layer/PaintAssistant.cpp Fri Jan 13 10:29:50 2017 +0000 @@ -15,7 +15,10 @@ #include "PaintAssistant.h" +#include "LayerGeometryProvider.h" + #include "base/AudioLevel.h" +#include "base/Strings.h" #include <QPaintDevice> #include <QPainter> @@ -79,7 +82,7 @@ text = QString("%1").arg(meterdbs[i]); if (i == n) text = "0dB"; if (i == 0) { - text = "-Inf"; + text = Strings::minus_infinity; val = 0.0; } break; @@ -89,7 +92,7 @@ text = QString("%1").arg(-(10*n) + i * 10); if (i == n) text = "0dB"; if (i == 0) { - text = "-Inf"; + text = Strings::minus_infinity; val = 0.0; } break; @@ -207,3 +210,55 @@ return vy; } + +void +PaintAssistant::drawVisibleText(const LayerGeometryProvider *v, + QPainter &paint, int x, int y, + QString text, TextStyle style) +{ + if (style == OutlinedText || style == OutlinedItalicText) { + + paint.save(); + + if (style == OutlinedItalicText) { + QFont f(paint.font()); + f.setItalic(true); + paint.setFont(f); + } + + QColor penColour, surroundColour, boxColour; + + penColour = v->getForeground(); + surroundColour = v->getBackground(); + boxColour = surroundColour; + boxColour.setAlpha(127); + + paint.setPen(Qt::NoPen); + paint.setBrush(boxColour); + + QRect r = paint.fontMetrics().boundingRect(text); + r.translate(QPoint(x, y)); +// cerr << "drawVisibleText: r = " << r.x() << "," <<r.y() << " " << r.width() << "x" << r.height() << endl; + paint.drawRect(r); + paint.setBrush(Qt::NoBrush); + + paint.setPen(surroundColour); + + for (int dx = -1; dx <= 1; ++dx) { + for (int dy = -1; dy <= 1; ++dy) { + if (!(dx || dy)) continue; + paint.drawText(x + dx, y + dy, text); + } + } + + paint.setPen(penColour); + + paint.drawText(x, y, text); + + paint.restore(); + + } else { + + std::cerr << "ERROR: PaintAssistant::drawVisibleText: Boxed style not yet implemented!" << std::endl; + } +}