comparison layer/FlexiNoteLayer.cpp @ 1078:ee01a4062747 spectrogram-minor-refactor

Move drawVisibleText to PaintAssistant
author Chris Cannam
date Thu, 30 Jun 2016 12:40:22 +0100
parents 5144d7185fb5
children c39f2d439d59
comparison
equal deleted inserted replaced
1077:5144d7185fb5 1078:ee01a4062747
20 #include "base/RealTime.h" 20 #include "base/RealTime.h"
21 #include "base/Profiler.h" 21 #include "base/Profiler.h"
22 #include "base/Pitch.h" 22 #include "base/Pitch.h"
23 #include "base/LogRange.h" 23 #include "base/LogRange.h"
24 #include "base/RangeMapper.h" 24 #include "base/RangeMapper.h"
25
25 #include "ColourDatabase.h" 26 #include "ColourDatabase.h"
26 #include "LayerGeometryProvider.h" 27 #include "LayerGeometryProvider.h"
27
28 #include "PianoScale.h" 28 #include "PianoScale.h"
29 #include "LinearNumericalScale.h" 29 #include "LinearNumericalScale.h"
30 #include "LogNumericalScale.h" 30 #include "LogNumericalScale.h"
31 #include "PaintAssistant.h"
31 32
32 #include "data/model/FlexiNoteModel.h" 33 #include "data/model/FlexiNoteModel.h"
33 34
34 #include "view/View.h" 35 #include "view/View.h"
35 36
867 868
868 paint.setPen(v->getForeground()); 869 paint.setPen(v->getForeground());
869 // paint.setBrush(v->getForeground()); 870 // paint.setBrush(v->getForeground());
870 871
871 QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits()); 872 QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits());
872 // v->drawVisibleText(paint, 873 // PaintAssistant::drawVisibleText(v, paint,
873 // x - paint.fontMetrics().width(vlabel) - 2, 874 // x - paint.fontMetrics().width(vlabel) - 2,
874 // y + paint.fontMetrics().height()/2 875 // y + paint.fontMetrics().height()/2
875 // - paint.fontMetrics().descent(), 876 // - paint.fontMetrics().descent(),
876 // vlabel, LayerGeometryProvider::OutlinedText); 877 // vlabel, PaintAssistant::OutlinedText);
877 v->drawVisibleText(paint, 878 PaintAssistant::drawVisibleText(v, paint,
878 x, 879 x,
879 y - h/2 - 2 - paint.fontMetrics().height() 880 y - h/2 - 2 - paint.fontMetrics().height()
880 - paint.fontMetrics().descent(), 881 - paint.fontMetrics().descent(),
881 vlabel, LayerGeometryProvider::OutlinedText); 882 vlabel, PaintAssistant::OutlinedText);
882 883
883 QString hlabel = "dur: " + QString(RealTime::frame2RealTime 884 QString hlabel = "dur: " + QString(RealTime::frame2RealTime
884 (p.duration, m_model->getSampleRate()).toText(true).c_str()); 885 (p.duration, m_model->getSampleRate()).toText(true).c_str());
885 v->drawVisibleText(paint, 886 PaintAssistant::drawVisibleText(v, paint,
886 x, 887 x,
887 y - h/2 - paint.fontMetrics().descent() - 2, 888 y - h/2 - paint.fontMetrics().descent() - 2,
888 hlabel, LayerGeometryProvider::OutlinedText); 889 hlabel, PaintAssistant::OutlinedText);
889 890
890 QString llabel = QString("%1").arg(p.label); 891 QString llabel = QString("%1").arg(p.label);
891 v->drawVisibleText(paint, 892 PaintAssistant::drawVisibleText(v, paint,
892 x, 893 x,
893 y + h + 2 + paint.fontMetrics().descent(), 894 y + h + 2 + paint.fontMetrics().descent(),
894 llabel, LayerGeometryProvider::OutlinedText); 895 llabel, PaintAssistant::OutlinedText);
895 QString nlabel = QString("%1").arg(noteNumber); 896 QString nlabel = QString("%1").arg(noteNumber);
896 v->drawVisibleText(paint, 897 PaintAssistant::drawVisibleText(v, paint,
897 x + paint.fontMetrics().averageCharWidth() / 2, 898 x + paint.fontMetrics().averageCharWidth() / 2,
898 y + h/2 - paint.fontMetrics().descent(), 899 y + h/2 - paint.fontMetrics().descent(),
899 nlabel, LayerGeometryProvider::OutlinedText); 900 nlabel, PaintAssistant::OutlinedText);
900 } 901 }
901 902
902 paint.drawRect(x, y - h/2, w, h); 903 paint.drawRect(x, y - h/2, w, h);
903 } 904 }
904 905