Mercurial > hg > svgui
diff view/Pane.cpp @ 326:4f4f38a11cd2
* Factor out uses of "Sonic Visualiser" in "common" code to applicationName()
* Add ability to show work title + artist in top-left of pane (thinking of Vect
but may be useful in SV in future)
* A few other generalisations useful for Vect
author | Chris Cannam |
---|---|
date | Fri, 09 Nov 2007 17:46:58 +0000 |
parents | 984c1975f1ff |
children | 29fcf125f98b |
line wrap: on
line diff
--- a/view/Pane.cpp Wed Nov 07 16:52:52 2007 +0000 +++ b/view/Pane.cpp Fri Nov 09 17:46:58 2007 +0000 @@ -24,6 +24,9 @@ #include "base/TextAbbrev.h" #include "layer/WaveformLayer.h" +//!!! ugh +#include "data/model/WaveFileModel.h" + #include <QPaintEvent> #include <QPainter> #include <QBitmap> @@ -313,6 +316,10 @@ return false; } + if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) { + return false; + } + if (layer == getSelectedLayer() && !shouldIlluminateLocalSelection(discard, b0, b1)) { @@ -410,6 +417,8 @@ bool haveSomeTimeXAxis = false; const Model *waveformModel = 0; // just for reporting purposes + const Model *workModel = 0; + for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { --vi; if (!haveSomeTimeXAxis && (*vi)->hasTimeXAxis()) { @@ -417,8 +426,17 @@ } if (dynamic_cast<WaveformLayer *>(*vi)) { waveformModel = (*vi)->getModel(); + workModel = waveformModel; + } else { + Model *m = (*vi)->getModel(); + if (dynamic_cast<WaveFileModel *>(m)) { + workModel = m; + } else if (m && dynamic_cast<WaveFileModel *>(m->getSourceModel())) { + workModel = m->getSourceModel(); + } } - if (waveformModel && haveSomeTimeXAxis) break; + + if (waveformModel && workModel && haveSomeTimeXAxis) break; } m_scaleWidth = 0; @@ -427,7 +445,9 @@ drawVerticalScale(r, topLayer, paint); } - if (m_identifyFeatures && topLayer) { + if (m_identifyFeatures && + m_manager && m_manager->shouldIlluminateLocalFeatures() && + topLayer) { drawFeatureDescription(topLayer, paint); } @@ -448,10 +468,19 @@ drawDurationAndRate(r, waveformModel, sampleRate, paint); } - if (waveformModel && + bool haveWorkTitle = false; + + if (workModel && + m_manager && + m_manager->shouldShowWorkTitle()) { + drawWorkTitle(r, paint, workModel); + haveWorkTitle = true; + } + + if (workModel && m_manager && m_manager->getAlignMode()) { - drawAlignmentStatus(r, paint, waveformModel); + drawAlignmentStatus(r, paint, workModel, haveWorkTitle); } if (m_manager && @@ -717,7 +746,8 @@ } void -Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model *model) +Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model *model, + bool down) { const Model *reference = model->getAlignmentReference(); /* @@ -747,17 +777,23 @@ } } - int w = paint.fontMetrics().width(text), h = paint.fontMetrics().height(); - if (r.top() > h + 5 || r.left() > w + m_scaleWidth + 5) return; - paint.save(); QFont font(paint.font()); font.setBold(true); paint.setFont(font); - if (completion < 100) paint.setPen(Qt::red); + if (completion < 100) paint.setBrush(Qt::red); + + int y = 5; + if (down) y += paint.fontMetrics().height(); + int w = paint.fontMetrics().width(text); + int h = paint.fontMetrics().height(); + if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { + paint.restore(); + return; + } drawVisibleText(paint, m_scaleWidth + 5, - paint.fontMetrics().ascent() + 5, text, OutlinedText); + paint.fontMetrics().ascent() + y, text, OutlinedText); paint.restore(); } @@ -770,6 +806,37 @@ } void +Pane::drawWorkTitle(QRect r, QPainter &paint, const Model *model) +{ + QString title = model->getTitle(); + QString maker = model->getMaker(); + if (title == "") return; + + QString text = title; + if (maker != "") { + text = tr("%1 - %2").arg(title).arg(maker); + } + + paint.save(); + QFont font(paint.font()); + font.setItalic(true); + paint.setFont(font); + + int y = 5; + int w = paint.fontMetrics().width(text); + int h = paint.fontMetrics().height(); + if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) { + paint.restore(); + return; + } + + drawVisibleText(paint, m_scaleWidth + 5, + paint.fontMetrics().ascent() + y, text, OutlinedText); + + paint.restore(); +} + +void Pane::drawLayerNames(QRect r, QPainter &paint) { int fontHeight = paint.fontMetrics().height(); @@ -1363,7 +1430,8 @@ bool updating = false; - if (getSelectedLayer()) { + if (getSelectedLayer() && + m_manager->shouldIlluminateLocalFeatures()) { bool previouslyIdentifying = m_identifyFeatures; m_identifyFeatures = true;