Mercurial > hg > svgui
comparison widgets/LevelPanWidget.cpp @ 941:d6acb8e36605 tonioni
Simpler colours in level pan widget
author | Chris Cannam |
---|---|
date | Tue, 31 Mar 2015 14:08:06 +0100 |
parents | 77110abca8a1 |
children | 125748a569fa |
comparison
equal
deleted
inserted
replaced
940:77110abca8a1 | 941:d6acb8e36605 |
---|---|
310 double tw = ceil(rect.width() / (maxPan * 2. * 10.)); | 310 double tw = ceil(rect.width() / (maxPan * 2. * 10.)); |
311 double th = ceil(rect.height() / (maxLevel * 10.)); | 311 double th = ceil(rect.height() / (maxLevel * 10.)); |
312 return std::min(th, tw); | 312 return std::min(th, tw); |
313 } | 313 } |
314 | 314 |
315 static QColor | |
316 level_to_colour(int level) | |
317 { | |
318 assert(maxLevel == 4); | |
319 if (level == 0) return Qt::black; | |
320 else if (level == 1) return QColor(80, 0, 0); | |
321 else if (level == 2) return QColor(160, 0, 0); | |
322 else if (level == 3) return QColor(255, 0, 0); | |
323 else return QColor(255, 255, 0); | |
324 } | |
325 | |
315 void | 326 void |
316 LevelPanWidget::renderTo(QPaintDevice *dev, QRectF rect, bool asIfEditable) const | 327 LevelPanWidget::renderTo(QPaintDevice *dev, QRectF rect, bool asIfEditable) const |
317 { | 328 { |
318 QPainter paint(dev); | 329 QPainter paint(dev); |
319 ColourMapper mapper(ColourMapper::Sunset, 0, maxLevel); | |
320 | 330 |
321 paint.setRenderHint(QPainter::Antialiasing, true); | 331 paint.setRenderHint(QPainter::Antialiasing, true); |
322 | 332 |
323 QPen pen; | 333 QPen pen; |
324 | 334 |
354 pen.setCapStyle(Qt::FlatCap); | 364 pen.setCapStyle(Qt::FlatCap); |
355 paint.setPen(pen); | 365 paint.setPen(pen); |
356 | 366 |
357 for (int level = 0; level <= m_level; ++level) { | 367 for (int level = 0; level <= m_level; ++level) { |
358 if (isEnabled()) { | 368 if (isEnabled()) { |
359 paint.setBrush(mapper.map(level)); | 369 paint.setBrush(level_to_colour(level)); |
360 } | 370 } |
361 QRectF clr = cellLightRect(rect, level, m_pan); | 371 QRectF clr = cellLightRect(rect, level, m_pan); |
362 if (m_includeMute && m_level == 0) { | 372 if (m_includeMute && m_level == 0) { |
363 paint.drawLine(clr.topLeft(), clr.bottomRight()); | 373 paint.drawLine(clr.topLeft(), clr.bottomRight()); |
364 paint.drawLine(clr.bottomLeft(), clr.topRight()); | 374 paint.drawLine(clr.bottomLeft(), clr.topRight()); |