Mercurial > hg > svgui
comparison layer/TimeInstantLayer.cpp @ 918:4fe7a09be0fe osx-retina
Many fixes for the previous stuff
author | Chris Cannam |
---|---|
date | Tue, 17 Mar 2015 16:56:03 +0000 |
parents | 94e4952a6774 |
children | 2adca8f05583 |
comparison
equal
deleted
inserted
replaced
917:77a1d42353ce | 918:4fe7a09be0fe |
---|---|
145 m_plotStyle = style; | 145 m_plotStyle = style; |
146 emit layerParametersChanged(); | 146 emit layerParametersChanged(); |
147 } | 147 } |
148 | 148 |
149 bool | 149 bool |
150 TimeInstantLayer::isLayerScrollable(const View *v) const | 150 TimeInstantLayer::isLayerScrollable(const LayerGeometryProvider *v) const |
151 { | 151 { |
152 QPoint discard; | 152 QPoint discard; |
153 return !v->shouldIlluminateLocalFeatures(this, discard); | 153 return !v->shouldIlluminateLocalFeatures(this, discard); |
154 } | 154 } |
155 | 155 |
156 SparseOneDimensionalModel::PointList | 156 SparseOneDimensionalModel::PointList |
157 TimeInstantLayer::getLocalPoints(View *v, int x) const | 157 TimeInstantLayer::getLocalPoints(LayerGeometryProvider *v, int x) const |
158 { | 158 { |
159 // Return a set of points that all have the same frame number, the | 159 // Return a set of points that all have the same frame number, the |
160 // nearest to the given x coordinate, and that are within a | 160 // nearest to the given x coordinate, and that are within a |
161 // certain fuzz distance of that x coordinate. | 161 // certain fuzz distance of that x coordinate. |
162 | 162 |
211 } | 211 } |
212 return ""; | 212 return ""; |
213 } | 213 } |
214 | 214 |
215 QString | 215 QString |
216 TimeInstantLayer::getFeatureDescription(View *v, QPoint &pos) const | 216 TimeInstantLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const |
217 { | 217 { |
218 int x = pos.x(); | 218 int x = pos.x(); |
219 | 219 |
220 if (!m_model || !m_model->getSampleRate()) return ""; | 220 if (!m_model || !m_model->getSampleRate()) return ""; |
221 | 221 |
247 pos = QPoint(v->getXForFrame(useFrame), pos.y()); | 247 pos = QPoint(v->getXForFrame(useFrame), pos.y()); |
248 return text; | 248 return text; |
249 } | 249 } |
250 | 250 |
251 bool | 251 bool |
252 TimeInstantLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, | 252 TimeInstantLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, |
253 int &resolution, | 253 int &resolution, |
254 SnapType snap) const | 254 SnapType snap) const |
255 { | 255 { |
256 if (!m_model) { | 256 if (!m_model) { |
257 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 257 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
401 iw = 2; | 401 iw = 2; |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
405 if (p.frame == illuminateFrame) { | 405 if (p.frame == illuminateFrame) { |
406 paint.setPen(getForegroundQColor(v)); | 406 paint.setPen(getForegroundQColor(v->getView())); |
407 } else { | 407 } else { |
408 paint.setPen(brushColour); | 408 paint.setPen(brushColour); |
409 } | 409 } |
410 | 410 |
411 if (m_plotStyle == PlotInstants) { | 411 if (m_plotStyle == PlotInstants) { |
412 if (iw > 1) { | 412 if (iw > 1) { |
413 paint.drawRect(x, 0, iw - 1, v->height() - 1); | 413 paint.drawRect(x, 0, iw - 1, v->getPaintHeight() - 1); |
414 } else { | 414 } else { |
415 paint.drawLine(x, 0, x, v->height() - 1); | 415 paint.drawLine(x, 0, x, v->getPaintHeight() - 1); |
416 } | 416 } |
417 } else { | 417 } else { |
418 | 418 |
419 if (odd) paint.setBrush(oddBrushColour); | 419 if (odd) paint.setBrush(oddBrushColour); |
420 else paint.setBrush(brushColour); | 420 else paint.setBrush(brushColour); |
429 } | 429 } |
430 | 430 |
431 if (nx >= x) { | 431 if (nx >= x) { |
432 | 432 |
433 if (illuminateFrame != p.frame && | 433 if (illuminateFrame != p.frame && |
434 (nx < x + 5 || x >= v->width() - 1)) { | 434 (nx < x + 5 || x >= v->getPaintWidth() - 1)) { |
435 paint.setPen(Qt::NoPen); | 435 paint.setPen(Qt::NoPen); |
436 } | 436 } |
437 | 437 |
438 paint.drawRect(x, -1, nx - x, v->height() + 1); | 438 paint.drawRect(x, -1, nx - x, v->getPaintHeight() + 1); |
439 } | 439 } |
440 | 440 |
441 odd = !odd; | 441 odd = !odd; |
442 } | 442 } |
443 | 443 |
464 prevX = x; | 464 prevX = x; |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 void | 468 void |
469 TimeInstantLayer::drawStart(View *v, QMouseEvent *e) | 469 TimeInstantLayer::drawStart(LayerGeometryProvider *v, QMouseEvent *e) |
470 { | 470 { |
471 #ifdef DEBUG_TIME_INSTANT_LAYER | 471 #ifdef DEBUG_TIME_INSTANT_LAYER |
472 cerr << "TimeInstantLayer::drawStart(" << e->x() << ")" << endl; | 472 cerr << "TimeInstantLayer::drawStart(" << e->x() << ")" << endl; |
473 #endif | 473 #endif |
474 | 474 |
487 | 487 |
488 m_editing = true; | 488 m_editing = true; |
489 } | 489 } |
490 | 490 |
491 void | 491 void |
492 TimeInstantLayer::drawDrag(View *v, QMouseEvent *e) | 492 TimeInstantLayer::drawDrag(LayerGeometryProvider *v, QMouseEvent *e) |
493 { | 493 { |
494 #ifdef DEBUG_TIME_INSTANT_LAYER | 494 #ifdef DEBUG_TIME_INSTANT_LAYER |
495 cerr << "TimeInstantLayer::drawDrag(" << e->x() << ")" << endl; | 495 cerr << "TimeInstantLayer::drawDrag(" << e->x() << ")" << endl; |
496 #endif | 496 #endif |
497 | 497 |
504 m_editingPoint.frame = frame; | 504 m_editingPoint.frame = frame; |
505 m_editingCommand->addPoint(m_editingPoint); | 505 m_editingCommand->addPoint(m_editingPoint); |
506 } | 506 } |
507 | 507 |
508 void | 508 void |
509 TimeInstantLayer::drawEnd(View *, QMouseEvent *) | 509 TimeInstantLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *) |
510 { | 510 { |
511 #ifdef DEBUG_TIME_INSTANT_LAYER | 511 #ifdef DEBUG_TIME_INSTANT_LAYER |
512 cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << endl; | 512 cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << endl; |
513 #endif | 513 #endif |
514 if (!m_model || !m_editing) return; | 514 if (!m_model || !m_editing) return; |
521 m_editingCommand = 0; | 521 m_editingCommand = 0; |
522 m_editing = false; | 522 m_editing = false; |
523 } | 523 } |
524 | 524 |
525 void | 525 void |
526 TimeInstantLayer::eraseStart(View *v, QMouseEvent *e) | 526 TimeInstantLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e) |
527 { | 527 { |
528 if (!m_model) return; | 528 if (!m_model) return; |
529 | 529 |
530 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); | 530 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); |
531 if (points.empty()) return; | 531 if (points.empty()) return; |
539 | 539 |
540 m_editing = true; | 540 m_editing = true; |
541 } | 541 } |
542 | 542 |
543 void | 543 void |
544 TimeInstantLayer::eraseDrag(View *, QMouseEvent *) | 544 TimeInstantLayer::eraseDrag(LayerGeometryProvider *, QMouseEvent *) |
545 { | 545 { |
546 } | 546 } |
547 | 547 |
548 void | 548 void |
549 TimeInstantLayer::eraseEnd(View *v, QMouseEvent *e) | 549 TimeInstantLayer::eraseEnd(LayerGeometryProvider *v, QMouseEvent *e) |
550 { | 550 { |
551 if (!m_model || !m_editing) return; | 551 if (!m_model || !m_editing) return; |
552 | 552 |
553 m_editing = false; | 553 m_editing = false; |
554 | 554 |
565 m_editingCommand = 0; | 565 m_editingCommand = 0; |
566 m_editing = false; | 566 m_editing = false; |
567 } | 567 } |
568 | 568 |
569 void | 569 void |
570 TimeInstantLayer::editStart(View *v, QMouseEvent *e) | 570 TimeInstantLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e) |
571 { | 571 { |
572 #ifdef DEBUG_TIME_INSTANT_LAYER | 572 #ifdef DEBUG_TIME_INSTANT_LAYER |
573 cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << endl; | 573 cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << endl; |
574 #endif | 574 #endif |
575 | 575 |
587 | 587 |
588 m_editing = true; | 588 m_editing = true; |
589 } | 589 } |
590 | 590 |
591 void | 591 void |
592 TimeInstantLayer::editDrag(View *v, QMouseEvent *e) | 592 TimeInstantLayer::editDrag(LayerGeometryProvider *v, QMouseEvent *e) |
593 { | 593 { |
594 #ifdef DEBUG_TIME_INSTANT_LAYER | 594 #ifdef DEBUG_TIME_INSTANT_LAYER |
595 cerr << "TimeInstantLayer::editDrag(" << e->x() << ")" << endl; | 595 cerr << "TimeInstantLayer::editDrag(" << e->x() << ")" << endl; |
596 #endif | 596 #endif |
597 | 597 |
610 m_editingPoint.frame = frame; | 610 m_editingPoint.frame = frame; |
611 m_editingCommand->addPoint(m_editingPoint); | 611 m_editingCommand->addPoint(m_editingPoint); |
612 } | 612 } |
613 | 613 |
614 void | 614 void |
615 TimeInstantLayer::editEnd(View *, QMouseEvent *) | 615 TimeInstantLayer::editEnd(LayerGeometryProvider *, QMouseEvent *) |
616 { | 616 { |
617 #ifdef DEBUG_TIME_INSTANT_LAYER | 617 #ifdef DEBUG_TIME_INSTANT_LAYER |
618 cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << endl; | 618 cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << endl; |
619 #endif | 619 #endif |
620 if (!m_model || !m_editing) return; | 620 if (!m_model || !m_editing) return; |
629 m_editingCommand = 0; | 629 m_editingCommand = 0; |
630 m_editing = false; | 630 m_editing = false; |
631 } | 631 } |
632 | 632 |
633 bool | 633 bool |
634 TimeInstantLayer::editOpen(View *v, QMouseEvent *e) | 634 TimeInstantLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e) |
635 { | 635 { |
636 if (!m_model) return false; | 636 if (!m_model) return false; |
637 | 637 |
638 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); | 638 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x()); |
639 if (points.empty()) return false; | 639 if (points.empty()) return false; |
745 | 745 |
746 finish(command); | 746 finish(command); |
747 } | 747 } |
748 | 748 |
749 void | 749 void |
750 TimeInstantLayer::copy(View *v, Selection s, Clipboard &to) | 750 TimeInstantLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to) |
751 { | 751 { |
752 if (!m_model) return; | 752 if (!m_model) return; |
753 | 753 |
754 SparseOneDimensionalModel::PointList points = | 754 SparseOneDimensionalModel::PointList points = |
755 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 755 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
763 } | 763 } |
764 } | 764 } |
765 } | 765 } |
766 | 766 |
767 bool | 767 bool |
768 TimeInstantLayer::paste(View *v, const Clipboard &from, sv_frame_t frameOffset, bool) | 768 TimeInstantLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t frameOffset, bool) |
769 { | 769 { |
770 if (!m_model) return false; | 770 if (!m_model) return false; |
771 | 771 |
772 const Clipboard::PointList &points = from.getPoints(); | 772 const Clipboard::PointList &points = from.getPoints(); |
773 | 773 |
774 bool realign = false; | 774 bool realign = false; |
775 | 775 |
776 if (clipboardHasDifferentAlignment(v, from)) { | 776 if (clipboardHasDifferentAlignment(v, from)) { |
777 | 777 |
778 QMessageBox::StandardButton button = | 778 QMessageBox::StandardButton button = |
779 QMessageBox::question(v, tr("Re-align pasted instants?"), | 779 QMessageBox::question(v->getView(), tr("Re-align pasted instants?"), |
780 tr("The instants you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), | 780 tr("The instants you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"), |
781 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, | 781 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, |
782 QMessageBox::Yes); | 782 QMessageBox::Yes); |
783 | 783 |
784 if (button == QMessageBox::Cancel) { | 784 if (button == QMessageBox::Cancel) { |