comparison layer/TimeRulerLayer.cpp @ 375:daaf1c435d98

* Fix mislabelling of time lines in ruler
author Chris Cannam
date Wed, 12 Mar 2008 14:40:18 +0000
parents 8ebc2ce2a210
children e1a9e478b7f2
comparison
equal deleted inserted replaced
372:67f82da3d29c 375:daaf1c435d98
247 double dms = ms; 247 double dms = ms;
248 long frame = lrint((dms * sampleRate) / 1000.0); 248 long frame = lrint((dms * sampleRate) / 1000.0);
249 frame /= v->getZoomLevel(); 249 frame /= v->getZoomLevel();
250 frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel 250 frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel
251 251
252 ms += incms;
253
254 int x = v->getXForFrame(frame); 252 int x = v->getXForFrame(frame);
255 253
256 #ifdef DEBUG_TIME_RULER_LAYER 254 #ifdef DEBUG_TIME_RULER_LAYER
257 std::cerr << "Considering frame = " << frame << ", x = " << x << std::endl; 255 std::cerr << "Considering frame = " << frame << ", x = " << x << std::endl;
258 #endif 256 #endif
264 break; 262 break;
265 } 263 }
266 264
267 if (x >= rect.x() - 50) { 265 if (x >= rect.x() - 50) {
268 266
269 #ifdef DEBUG_TIME_RULER_LAYER
270 std::cerr << "X in range, drawing line here" << std::endl;
271 #endif
272
273 RealTime rt = RealTime::fromMilliseconds(ms); 267 RealTime rt = RealTime::fromMilliseconds(ms);
268
269 #ifdef DEBUG_TIME_RULER_LAYER
270 std::cerr << "X in range, drawing line here for time " << rt.toText() << std::endl;
271 #endif
274 272
275 QString text(QString::fromStdString(rt.toText())); 273 QString text(QString::fromStdString(rt.toText()));
276 QFontMetrics metrics = paint.fontMetrics(); 274 QFontMetrics metrics = paint.fontMetrics();
277 int tw = metrics.width(text); 275 int tw = metrics.width(text);
278 276
349 } 347 }
350 } 348 }
351 paint.drawLine(x, 0, x, sz); 349 paint.drawLine(x, 0, x, sz);
352 paint.drawLine(x, v->height() - sz - 1, x, v->height() - 1); 350 paint.drawLine(x, v->height() - sz - 1, x, v->height() - 1);
353 } 351 }
352
353 ms += incms;
354 } 354 }
355 355
356 paint.restore(); 356 paint.restore();
357 } 357 }
358 358