Mercurial > hg > svgui
diff view/Pane.cpp @ 320:984c1975f1ff
* Some tidying up to handling of alignment; add alignment status label to
pane; ensure alignment when dragging with mouse as well as when playing
author | Chris Cannam |
---|---|
date | Thu, 25 Oct 2007 14:32:23 +0000 |
parents | c0b9eec70639 |
children | 4f4f38a11cd2 |
line wrap: on
line diff
--- a/view/Pane.cpp Mon Oct 22 14:24:31 2007 +0000 +++ b/view/Pane.cpp Thu Oct 25 14:32:23 2007 +0000 @@ -448,6 +448,12 @@ drawDurationAndRate(r, waveformModel, sampleRate, paint); } + if (waveformModel && + m_manager && + m_manager->getAlignMode()) { + drawAlignmentStatus(r, paint, waveformModel); + } + if (m_manager && m_manager->shouldShowLayerNames()) { drawLayerNames(r, paint); @@ -711,6 +717,59 @@ } void +Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model *model) +{ + const Model *reference = model->getAlignmentReference(); +/* + if (!reference) { + std::cerr << "Pane[" << this << "]::drawAlignmentStatus: No reference" << std::endl; + } else if (reference == model) { + std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is the reference model" << std::endl; + } else { + std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is not the reference" << std::endl; + } +*/ + QString text; + int completion = 100; + + if (reference == model) { + text = tr("Reference"); + } else if (!reference) { + text = tr("Unaligned"); + } else { + completion = model->getAlignmentCompletion(); + if (completion == 0) { + text = tr("Unaligned"); + } else if (completion < 100) { + text = tr("Aligning: %1%").arg(completion); + } else { + text = tr("Aligned"); + } + } + + 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); + + drawVisibleText(paint, m_scaleWidth + 5, + paint.fontMetrics().ascent() + 5, text, OutlinedText); + + paint.restore(); +} + +void +Pane::modelAlignmentCompletionChanged() +{ + View::modelAlignmentCompletionChanged(); + update(QRect(0, 0, 300, 100)); +} + +void Pane::drawLayerNames(QRect r, QPainter &paint) { int fontHeight = paint.fontMetrics().height();