Mercurial > hg > svgui
comparison layer/PaintAssistant.cpp @ 1146:74f2706995b7 3.0-integration
Merge work on unified spectrogram and colour 3d plot caching renderer
author | Chris Cannam |
---|---|
date | Fri, 05 Aug 2016 15:05:02 +0100 |
parents | ee01a4062747 |
children | 1badacff7ab2 |
comparison
equal
deleted
inserted
replaced
1056:b4fd6c67fce5 | 1146:74f2706995b7 |
---|---|
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
14 */ | 14 */ |
15 | 15 |
16 #include "PaintAssistant.h" | 16 #include "PaintAssistant.h" |
17 | |
18 #include "LayerGeometryProvider.h" | |
17 | 19 |
18 #include "base/AudioLevel.h" | 20 #include "base/AudioLevel.h" |
19 | 21 |
20 #include <QPaintDevice> | 22 #include <QPaintDevice> |
21 #include <QPainter> | 23 #include <QPainter> |
205 break; | 207 break; |
206 } | 208 } |
207 | 209 |
208 return vy; | 210 return vy; |
209 } | 211 } |
212 | |
213 void | |
214 PaintAssistant::drawVisibleText(const LayerGeometryProvider *v, | |
215 QPainter &paint, int x, int y, | |
216 QString text, TextStyle style) | |
217 { | |
218 if (style == OutlinedText || style == OutlinedItalicText) { | |
219 | |
220 paint.save(); | |
221 | |
222 if (style == OutlinedItalicText) { | |
223 QFont f(paint.font()); | |
224 f.setItalic(true); | |
225 paint.setFont(f); | |
226 } | |
227 | |
228 QColor penColour, surroundColour, boxColour; | |
229 | |
230 penColour = v->getForeground(); | |
231 surroundColour = v->getBackground(); | |
232 boxColour = surroundColour; | |
233 boxColour.setAlpha(127); | |
234 | |
235 paint.setPen(Qt::NoPen); | |
236 paint.setBrush(boxColour); | |
237 | |
238 QRect r = paint.fontMetrics().boundingRect(text); | |
239 r.translate(QPoint(x, y)); | |
240 // cerr << "drawVisibleText: r = " << r.x() << "," <<r.y() << " " << r.width() << "x" << r.height() << endl; | |
241 paint.drawRect(r); | |
242 paint.setBrush(Qt::NoBrush); | |
243 | |
244 paint.setPen(surroundColour); | |
245 | |
246 for (int dx = -1; dx <= 1; ++dx) { | |
247 for (int dy = -1; dy <= 1; ++dy) { | |
248 if (!(dx || dy)) continue; | |
249 paint.drawText(x + dx, y + dy, text); | |
250 } | |
251 } | |
252 | |
253 paint.setPen(penColour); | |
254 | |
255 paint.drawText(x, y, text); | |
256 | |
257 paint.restore(); | |
258 | |
259 } else { | |
260 | |
261 std::cerr << "ERROR: PaintAssistant::drawVisibleText: Boxed style not yet implemented!" << std::endl; | |
262 } | |
263 } |