Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 827:ea098f7565eb
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Fri, 18 Jul 2014 15:38:21 +0100 |
parents | 22fe9bcb7206 |
children | 5d4e3e36945f |
comparison
equal
deleted
inserted
replaced
823:2d4af227fd32 | 827:ea098f7565eb |
---|---|
795 int sampleRate = m_model->getSampleRate(); | 795 int sampleRate = m_model->getSampleRate(); |
796 if (!sampleRate) return; | 796 if (!sampleRate) return; |
797 | 797 |
798 // Profiler profiler("FlexiNoteLayer::paint", true); | 798 // Profiler profiler("FlexiNoteLayer::paint", true); |
799 | 799 |
800 int x0 = rect.left(), x1 = rect.right(); | 800 int x1 = rect.right(); |
801 int frame0 = v->getFrameForX(x0); | |
802 int frame1 = v->getFrameForX(x1); | 801 int frame1 = v->getFrameForX(x1); |
803 | 802 |
804 FlexiNoteModel::PointList points(m_model->getPoints(frame0, frame1)); | 803 FlexiNoteModel::PointList points(m_model->getPoints(0, frame1)); |
805 if (points.empty()) return; | 804 if (points.empty()) return; |
806 | 805 |
807 paint.setPen(getBaseQColor()); | 806 paint.setPen(getBaseQColor()); |
808 | 807 |
809 QColor brushColour(getBaseQColor()); | 808 QColor brushColour(getBaseQColor()); |
826 } | 825 } |
827 | 826 |
828 paint.save(); | 827 paint.save(); |
829 paint.setRenderHint(QPainter::Antialiasing, false); | 828 paint.setRenderHint(QPainter::Antialiasing, false); |
830 | 829 |
830 int noteNumber = 0; | |
831 | |
831 for (FlexiNoteModel::PointList::const_iterator i = points.begin(); | 832 for (FlexiNoteModel::PointList::const_iterator i = points.begin(); |
832 i != points.end(); ++i) { | 833 i != points.end(); ++i) { |
833 | 834 |
835 ++noteNumber; | |
834 const FlexiNoteModel::Point &p(*i); | 836 const FlexiNoteModel::Point &p(*i); |
835 | 837 |
836 int x = v->getXForFrame(p.frame); | 838 int x = v->getXForFrame(p.frame); |
837 int y = getYForValue(v, p.value); | 839 int y = getYForValue(v, p.value); |
838 int w = v->getXForFrame(p.frame + p.duration) - x; | 840 int w = v->getXForFrame(p.frame + p.duration) - x; |
880 QString llabel = QString("%1").arg(p.label); | 882 QString llabel = QString("%1").arg(p.label); |
881 v->drawVisibleText(paint, | 883 v->drawVisibleText(paint, |
882 x, | 884 x, |
883 y + h + 2 + paint.fontMetrics().descent(), | 885 y + h + 2 + paint.fontMetrics().descent(), |
884 llabel, View::OutlinedText); | 886 llabel, View::OutlinedText); |
887 QString nlabel = QString("%1").arg(noteNumber); | |
888 v->drawVisibleText(paint, | |
889 x + paint.fontMetrics().averageCharWidth() / 2, | |
890 y + h/2 - paint.fontMetrics().descent(), | |
891 nlabel, View::OutlinedText); | |
885 } | 892 } |
886 | 893 |
887 paint.drawRect(x, y - h/2, w, h); | 894 paint.drawRect(x, y - h/2, w, h); |
888 } | 895 } |
889 | 896 |