Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
319:2a50c1ecc990 | 320:984c1975f1ff |
---|---|
446 m_manager && | 446 m_manager && |
447 m_manager->shouldShowDuration()) { | 447 m_manager->shouldShowDuration()) { |
448 drawDurationAndRate(r, waveformModel, sampleRate, paint); | 448 drawDurationAndRate(r, waveformModel, sampleRate, paint); |
449 } | 449 } |
450 | 450 |
451 if (waveformModel && | |
452 m_manager && | |
453 m_manager->getAlignMode()) { | |
454 drawAlignmentStatus(r, paint, waveformModel); | |
455 } | |
456 | |
451 if (m_manager && | 457 if (m_manager && |
452 m_manager->shouldShowLayerNames()) { | 458 m_manager->shouldShowLayerNames()) { |
453 drawLayerNames(r, paint); | 459 drawLayerNames(r, paint); |
454 } | 460 } |
455 | 461 |
706 | 712 |
707 int x = width()/2 + 4; | 713 int x = width()/2 + 4; |
708 | 714 |
709 drawVisibleText(paint, x, y, text, OutlinedText); | 715 drawVisibleText(paint, x, y, text, OutlinedText); |
710 } | 716 } |
717 } | |
718 | |
719 void | |
720 Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model *model) | |
721 { | |
722 const Model *reference = model->getAlignmentReference(); | |
723 /* | |
724 if (!reference) { | |
725 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: No reference" << std::endl; | |
726 } else if (reference == model) { | |
727 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is the reference model" << std::endl; | |
728 } else { | |
729 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is not the reference" << std::endl; | |
730 } | |
731 */ | |
732 QString text; | |
733 int completion = 100; | |
734 | |
735 if (reference == model) { | |
736 text = tr("Reference"); | |
737 } else if (!reference) { | |
738 text = tr("Unaligned"); | |
739 } else { | |
740 completion = model->getAlignmentCompletion(); | |
741 if (completion == 0) { | |
742 text = tr("Unaligned"); | |
743 } else if (completion < 100) { | |
744 text = tr("Aligning: %1%").arg(completion); | |
745 } else { | |
746 text = tr("Aligned"); | |
747 } | |
748 } | |
749 | |
750 int w = paint.fontMetrics().width(text), h = paint.fontMetrics().height(); | |
751 if (r.top() > h + 5 || r.left() > w + m_scaleWidth + 5) return; | |
752 | |
753 paint.save(); | |
754 QFont font(paint.font()); | |
755 font.setBold(true); | |
756 paint.setFont(font); | |
757 if (completion < 100) paint.setPen(Qt::red); | |
758 | |
759 drawVisibleText(paint, m_scaleWidth + 5, | |
760 paint.fontMetrics().ascent() + 5, text, OutlinedText); | |
761 | |
762 paint.restore(); | |
763 } | |
764 | |
765 void | |
766 Pane::modelAlignmentCompletionChanged() | |
767 { | |
768 View::modelAlignmentCompletionChanged(); | |
769 update(QRect(0, 0, 300, 100)); | |
711 } | 770 } |
712 | 771 |
713 void | 772 void |
714 Pane::drawLayerNames(QRect r, QPainter &paint) | 773 Pane::drawLayerNames(QRect r, QPainter &paint) |
715 { | 774 { |