comparison layer/TimeValueLayer.cpp @ 13:01849cd277e6

* Hook up tool selection buttons to switch the cursor mode * Implement simple and multi-selection, snapping to the resolution of the current layer. You can't actually do anything with a selection yet
author Chris Cannam
date Mon, 23 Jan 2006 17:02:57 +0000
parents 2d5005f2b3d9
children 1deb5f87a18c
comparison
equal deleted inserted replaced
12:484e7320f59f 13:01849cd277e6
266 valueText); 266 valueText);
267 paint.drawText(xbase + 5, ybase + 9 + metrics.ascent() + 2*metrics.height(), 267 paint.drawText(xbase + 5, ybase + 9 + metrics.ascent() + 2*metrics.height(),
268 points.begin()->label); 268 points.begin()->label);
269 } 269 }
270 270
271 int
272 TimeValueLayer::getNearestFeatureFrame(int frame,
273 size_t &resolution,
274 bool snapRight) const
275 {
276 if (!m_model) {
277 return Layer::getNearestFeatureFrame(frame, resolution, snapRight);
278 }
279
280 resolution = m_model->getResolution();
281 SparseTimeValueModel::PointList points(m_model->getPoints(frame, frame));
282
283 int returnFrame = frame;
284
285 for (SparseTimeValueModel::PointList::const_iterator i = points.begin();
286 i != points.end(); ++i) {
287
288 if (snapRight) {
289 if (i->frame > frame) {
290 returnFrame = i->frame;
291 break;
292 }
293 } else {
294 if (i->frame <= frame) {
295 returnFrame = i->frame;
296 }
297 }
298 }
299
300 return returnFrame;
301 }
302
271 void 303 void
272 TimeValueLayer::paint(QPainter &paint, QRect rect) const 304 TimeValueLayer::paint(QPainter &paint, QRect rect) const
273 { 305 {
274 if (!m_model || !m_model->isOK()) return; 306 if (!m_model || !m_model->isOK()) return;
275 307