105
105
if (pTimeScale == NULL)
108
QPainter p(&m_pixmap);
108
QPainter painter(&m_pixmap);
109
painter.initFrom(this);
112
112
// Draw the time scale...
115
const QFontMetrics& fm = p.fontMetrics();
116
int x, y1, y2 = h - 1;
115
const QFontMetrics& fm = painter.fontMetrics();
116
int x, x1, y1, y2 = h - 1;
118
118
// Account for the editing offset:
119
int dx = cx + pTimeScale->pixelFromFrame(m_pEditor->offset());
119
const int dx = cx + pTimeScale->pixelFromFrame(m_pEditor->offset());
121
121
qtractorTimeScale::Cursor cursor(pTimeScale);
122
122
qtractorTimeScale::Node *pNode = cursor.seekPixel(dx);
124
124
unsigned short iPixelsPerBeat = pNode->pixelsPerBeat();
125
125
unsigned int iBeat = pNode->beatFromPixel(dx);
127
pNode = cursor.seekBeat(--iBeat);
128
x = pNode->pixelFromBeat(iBeat) - dx;
126
if (iBeat > 0) pNode = cursor.seekBeat(--iBeat);
127
x = x1 = pNode->pixelFromBeat(iBeat) - dx;
131
bool bBeatIsBar = pNode->beatIsBar(iBeat);
130
const bool bBeatIsBar = pNode->beatIsBar(iBeat);
131
if (bBeatIsBar || iPixelsPerBeat > 8) {
132
y1 = (bBeatIsBar && x >= x1 ? 0 : fm.ascent());
133
painter.setPen(pal.mid().color());
134
painter.drawLine(x, y1, x, y2);
135
painter.setPen(pal.light().color());
136
++x; painter.drawLine(x, y1, x, y2);
132
138
if (bBeatIsBar) {
134
p.setPen(pal.windowText().color());
135
p.drawText(x + 2, fm.ascent(),
136
QString::number(pNode->barFromBeat(iBeat) + 1));
142
const unsigned short iBar = pNode->barFromBeat(iBeat);
143
const QString& sBeat = QString::number(iBar + 1);
144
painter.setPen(pal.windowText().color());
145
painter.drawText(x1, y1, sBeat);
146
x1 += fm.width(sBeat) + 2;
137
149
if (iBeat == pNode->beat) {
138
150
iPixelsPerBeat = pNode->pixelsPerBeat();
139
p.setPen(pal.base().color().value() < 0x7f
140
? pal.light().color() : pal.dark().color());
141
p.drawText(x + 16, fm.ascent(),
151
const QString& sTempo = QString("%1 %2/%3")
143
152
.arg(pNode->tempo, 0, 'g', 3)
144
153
.arg(pNode->beatsPerBar)
145
.arg(1 << pNode->beatDivisor));
154
.arg(1 << pNode->beatDivisor);
155
painter.setPen(pal.base().color().value() < 0x7f
156
? pal.light().color() : pal.dark().color());
157
painter.drawText(x1, y1, sTempo);
158
x1 += fm.width(sTempo) + 2;
150
if (bBeatIsBar || iPixelsPerBeat > 8) {
151
p.setPen(pal.mid().color());
152
p.drawLine(x, y1, x, y2);
153
p.setPen(pal.light().color());
154
p.drawLine(x + 1, y1, x + 1, y2);
156
161
pNode = cursor.seekBeat(++iBeat);
157
162
x = pNode->pixelFromBeat(iBeat) - dx;