comparison layer/FlexiNoteLayer.cpp @ 916:94e4952a6774 osx-retina

Start trying to introduce LayerGeometryProvider as proxyable interface for View methods that the Layer wants to use
author Chris Cannam
date Tue, 17 Mar 2015 15:05:25 +0000
parents b66fb15de477
children 4fe7a09be0fe
comparison
equal deleted inserted replaced
915:f6d9f28f37cb 916:94e4952a6774
202 m_verticalScale = scale; 202 m_verticalScale = scale;
203 emit layerParametersChanged(); 203 emit layerParametersChanged();
204 } 204 }
205 205
206 bool 206 bool
207 FlexiNoteLayer::isLayerScrollable(const View *v) const 207 FlexiNoteLayer::isLayerScrollable(const LayerGeometryProvider *v) const
208 { 208 {
209 QPoint discard; 209 QPoint discard;
210 return !v->shouldIlluminateLocalFeatures(this, discard); 210 return !v->shouldIlluminateLocalFeatures(this, discard);
211 } 211 }
212 212
403 403
404 return mapper; 404 return mapper;
405 } 405 }
406 406
407 FlexiNoteModel::PointList 407 FlexiNoteModel::PointList
408 FlexiNoteLayer::getLocalPoints(View *v, int x) const 408 FlexiNoteLayer::getLocalPoints(LayerGeometryProvider *v, int x) const
409 { 409 {
410 if (!m_model) return FlexiNoteModel::PointList(); 410 if (!m_model) return FlexiNoteModel::PointList();
411 411
412 sv_frame_t frame = v->getFrameForX(x); 412 sv_frame_t frame = v->getFrameForX(x);
413 413
446 446
447 return usePoints; 447 return usePoints;
448 } 448 }
449 449
450 bool 450 bool
451 FlexiNoteLayer::getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &p) const 451 FlexiNoteLayer::getPointToDrag(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &p) const
452 { 452 {
453 if (!m_model) return false; 453 if (!m_model) return false;
454 454
455 sv_frame_t frame = v->getFrameForX(x); 455 sv_frame_t frame = v->getFrameForX(x);
456 456
474 474
475 return true; 475 return true;
476 } 476 }
477 477
478 bool 478 bool
479 FlexiNoteLayer::getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &p) const 479 FlexiNoteLayer::getNoteToEdit(LayerGeometryProvider *v, int x, int y, FlexiNoteModel::Point &p) const
480 { 480 {
481 // GF: find the note that is closest to the cursor 481 // GF: find the note that is closest to the cursor
482 if (!m_model) return false; 482 if (!m_model) return false;
483 483
484 sv_frame_t frame = v->getFrameForX(x); 484 sv_frame_t frame = v->getFrameForX(x);
503 503
504 return true; 504 return true;
505 } 505 }
506 506
507 QString 507 QString
508 FlexiNoteLayer::getFeatureDescription(View *v, QPoint &pos) const 508 FlexiNoteLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const
509 { 509 {
510 int x = pos.x(); 510 int x = pos.x();
511 511
512 if (!m_model || !m_model->getSampleRate()) return ""; 512 if (!m_model || !m_model->getSampleRate()) return "";
513 513
591 getYForValue(v, note.value)); 591 getYForValue(v, note.value));
592 return text; 592 return text;
593 } 593 }
594 594
595 bool 595 bool
596 FlexiNoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, 596 FlexiNoteLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame,
597 int &resolution, 597 int &resolution,
598 SnapType snap) const 598 SnapType snap) const
599 { 599 {
600 if (!m_model) { 600 if (!m_model) {
601 return Layer::snapToFeatureFrame(v, frame, resolution, snap); 601 return Layer::snapToFeatureFrame(v, frame, resolution, snap);
671 frame = snapped; 671 frame = snapped;
672 return found; 672 return found;
673 } 673 }
674 674
675 void 675 void
676 FlexiNoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const 676 FlexiNoteLayer::getScaleExtents(LayerGeometryProvider *v, double &min, double &max, bool &log) const
677 { 677 {
678 min = 0.0; 678 min = 0.0;
679 max = 0.0; 679 max = 0.0;
680 log = false; 680 log = false;
681 681
728 728
729 if (max == min) max = min + 1.0; 729 if (max == min) max = min + 1.0;
730 } 730 }
731 731
732 int 732 int
733 FlexiNoteLayer::getYForValue(View *v, double val) const 733 FlexiNoteLayer::getYForValue(LayerGeometryProvider *v, double val) const
734 { 734 {
735 double min = 0.0, max = 0.0; 735 double min = 0.0, max = 0.0;
736 bool logarithmic = false; 736 bool logarithmic = false;
737 int h = v->height(); 737 int h = v->getPaintHeight();
738 738
739 getScaleExtents(v, min, max, logarithmic); 739 getScaleExtents(v, min, max, logarithmic);
740 740
741 #ifdef DEBUG_NOTE_LAYER 741 #ifdef DEBUG_NOTE_LAYER
742 cerr << "FlexiNoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << endl; 742 cerr << "FlexiNoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << endl;
763 #endif 763 #endif
764 return y; 764 return y;
765 } 765 }
766 766
767 double 767 double
768 FlexiNoteLayer::getValueForY(View *v, int y) const 768 FlexiNoteLayer::getValueForY(LayerGeometryProvider *v, int y) const
769 { 769 {
770 double min = 0.0, max = 0.0; 770 double min = 0.0, max = 0.0;
771 bool logarithmic = false; 771 bool logarithmic = false;
772 int h = v->height(); 772 int h = v->getPaintHeight();
773 773
774 getScaleExtents(v, min, max, logarithmic); 774 getScaleExtents(v, min, max, logarithmic);
775 775
776 double val = min + (double(h - y) * double(max - min)) / h; 776 double val = min + (double(h - y) * double(max - min)) / h;
777 777
792 if (!m_model) return false; 792 if (!m_model) return false;
793 return (m_verticalScale == AutoAlignScale); 793 return (m_verticalScale == AutoAlignScale);
794 } 794 }
795 795
796 void 796 void
797 FlexiNoteLayer::paint(View *v, QPainter &paint, QRect rect) const 797 FlexiNoteLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
798 { 798 {
799 if (!m_model || !m_model->isOK()) return; 799 if (!m_model || !m_model->isOK()) return;
800 800
801 sv_samplerate_t sampleRate = m_model->getSampleRate(); 801 sv_samplerate_t sampleRate = m_model->getSampleRate();
802 if (!sampleRate) return; 802 if (!sampleRate) return;
858 if (shouldIlluminate && 858 if (shouldIlluminate &&
859 // "illuminatePoint == p" 859 // "illuminatePoint == p"
860 !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) && 860 !FlexiNoteModel::Point::Comparator()(illuminatePoint, p) &&
861 !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) { 861 !FlexiNoteModel::Point::Comparator()(p, illuminatePoint)) {
862 862
863 paint.drawLine(x, -1, x, v->height() + 1); 863 paint.drawLine(x, -1, x, v->getPaintHeight() + 1);
864 paint.drawLine(x+w, -1, x+w, v->height() + 1); 864 paint.drawLine(x+w, -1, x+w, v->getPaintHeight() + 1);
865 865
866 paint.setPen(v->getForeground()); 866 paint.setPen(v->getForeground());
867 // paint.setBrush(v->getForeground()); 867 // paint.setBrush(v->getForeground());
868 868
869 QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits()); 869 QString vlabel = QString("freq: %1%2").arg(p.value).arg(m_model->getScaleUnits());
902 902
903 paint.restore(); 903 paint.restore();
904 } 904 }
905 905
906 int 906 int
907 FlexiNoteLayer::getVerticalScaleWidth(View *v, bool, QPainter &paint) const 907 FlexiNoteLayer::getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &paint) const
908 { 908 {
909 if (!m_model || shouldAutoAlign()) { 909 if (!m_model || shouldAutoAlign()) {
910 return 0; 910 return 0;
911 } else { 911 } else {
912 if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { 912 if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) {
916 } 916 }
917 } 917 }
918 } 918 }
919 919
920 void 920 void
921 FlexiNoteLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const 921 FlexiNoteLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect) const
922 { 922 {
923 if (!m_model || m_model->getPoints().empty()) return; 923 if (!m_model || m_model->getPoints().empty()) return;
924 924
925 QString unit; 925 QString unit;
926 double min, max; 926 double min, max;
927 bool logarithmic; 927 bool logarithmic;
928 928
929 int w = getVerticalScaleWidth(v, false, paint); 929 int w = getVerticalScaleWidth(v, false, paint);
930 int h = v->height(); 930 int h = v->getPaintHeight();
931 931
932 getScaleExtents(v, min, max, logarithmic); 932 getScaleExtents(v, min, max, logarithmic);
933 933
934 if (logarithmic) { 934 if (logarithmic) {
935 LogNumericalScale().paintVertical(v, this, paint, 0, min, max); 935 LogNumericalScale().paintVertical(v, this, paint, 0, min, max);
954 mw)); 954 mw));
955 } 955 }
956 } 956 }
957 957
958 void 958 void
959 FlexiNoteLayer::drawStart(View *v, QMouseEvent *e) 959 FlexiNoteLayer::drawStart(LayerGeometryProvider *v, QMouseEvent *e)
960 { 960 {
961 // SVDEBUG << "FlexiNoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; 961 // SVDEBUG << "FlexiNoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl;
962 962
963 if (!m_model) return; 963 if (!m_model) return;
964 964
978 978
979 m_editing = true; 979 m_editing = true;
980 } 980 }
981 981
982 void 982 void
983 FlexiNoteLayer::drawDrag(View *v, QMouseEvent *e) 983 FlexiNoteLayer::drawDrag(LayerGeometryProvider *v, QMouseEvent *e)
984 { 984 {
985 // SVDEBUG << "FlexiNoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; 985 // SVDEBUG << "FlexiNoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl;
986 986
987 if (!m_model || !m_editing) return; 987 if (!m_model || !m_editing) return;
988 988
1007 m_editingPoint.duration = newDuration; 1007 m_editingPoint.duration = newDuration;
1008 m_editingCommand->addPoint(m_editingPoint); 1008 m_editingCommand->addPoint(m_editingPoint);
1009 } 1009 }
1010 1010
1011 void 1011 void
1012 FlexiNoteLayer::drawEnd(View *, QMouseEvent *) 1012 FlexiNoteLayer::drawEnd(LayerGeometryProvider *, QMouseEvent *)
1013 { 1013 {
1014 // SVDEBUG << "FlexiNoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl; 1014 // SVDEBUG << "FlexiNoteLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl;
1015 if (!m_model || !m_editing) return; 1015 if (!m_model || !m_editing) return;
1016 finish(m_editingCommand); 1016 finish(m_editingCommand);
1017 m_editingCommand = 0; 1017 m_editingCommand = 0;
1018 m_editing = false; 1018 m_editing = false;
1019 } 1019 }
1020 1020
1021 void 1021 void
1022 FlexiNoteLayer::eraseStart(View *v, QMouseEvent *e) 1022 FlexiNoteLayer::eraseStart(LayerGeometryProvider *v, QMouseEvent *e)
1023 { 1023 {
1024 if (!m_model) return; 1024 if (!m_model) return;
1025 1025
1026 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; 1026 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return;
1027 1027
1032 1032
1033 m_editing = true; 1033 m_editing = true;
1034 } 1034 }
1035 1035
1036 void 1036 void
1037 FlexiNoteLayer::eraseDrag(View *, QMouseEvent *) 1037 FlexiNoteLayer::eraseDrag(LayerGeometryProvider *, QMouseEvent *)
1038 { 1038 {
1039 } 1039 }
1040 1040
1041 void 1041 void
1042 FlexiNoteLayer::eraseEnd(View *v, QMouseEvent *e) 1042 FlexiNoteLayer::eraseEnd(LayerGeometryProvider *v, QMouseEvent *e)
1043 { 1043 {
1044 if (!m_model || !m_editing) return; 1044 if (!m_model || !m_editing) return;
1045 1045
1046 m_editing = false; 1046 m_editing = false;
1047 1047
1057 m_editingCommand = 0; 1057 m_editingCommand = 0;
1058 m_editing = false; 1058 m_editing = false;
1059 } 1059 }
1060 1060
1061 void 1061 void
1062 FlexiNoteLayer::editStart(View *v, QMouseEvent *e) 1062 FlexiNoteLayer::editStart(LayerGeometryProvider *v, QMouseEvent *e)
1063 { 1063 {
1064 // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; 1064 // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl;
1065 std::cerr << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; 1065 std::cerr << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl;
1066 1066
1067 if (!m_model) return; 1067 if (!m_model) return;
1108 } 1108 }
1109 std::cerr << "editStart: mode is " << m_editMode << ", note frame: " << onset << ", left boundary: " << m_greatestLeftNeighbourFrame << ", right boundary: " << m_smallestRightNeighbourFrame << std::endl; 1109 std::cerr << "editStart: mode is " << m_editMode << ", note frame: " << onset << ", left boundary: " << m_greatestLeftNeighbourFrame << ", right boundary: " << m_smallestRightNeighbourFrame << std::endl;
1110 } 1110 }
1111 1111
1112 void 1112 void
1113 FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) 1113 FlexiNoteLayer::editDrag(LayerGeometryProvider *v, QMouseEvent *e)
1114 { 1114 {
1115 // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; 1115 // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl;
1116 std::cerr << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << std::endl; 1116 std::cerr << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << std::endl;
1117 1117
1118 if (!m_model || !m_editing) return; 1118 if (!m_model || !m_editing) return;
1175 std::cerr << "added new point(" << m_editingPoint.frame << "," << m_editingPoint.duration << ")" << std::endl; 1175 std::cerr << "added new point(" << m_editingPoint.frame << "," << m_editingPoint.duration << ")" << std::endl;
1176 1176
1177 } 1177 }
1178 1178
1179 void 1179 void
1180 FlexiNoteLayer::editEnd(View *, QMouseEvent *e) 1180 FlexiNoteLayer::editEnd(LayerGeometryProvider *, QMouseEvent *e)
1181 { 1181 {
1182 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; 1182 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl;
1183 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; 1183 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl;
1184 1184
1185 if (!m_model || !m_editing) return; 1185 if (!m_model || !m_editing) return;
1205 m_editingCommand = 0; 1205 m_editingCommand = 0;
1206 m_editing = false; 1206 m_editing = false;
1207 } 1207 }
1208 1208
1209 void 1209 void
1210 FlexiNoteLayer::splitStart(View *v, QMouseEvent *e) 1210 FlexiNoteLayer::splitStart(LayerGeometryProvider *v, QMouseEvent *e)
1211 { 1211 {
1212 // GF: note splitting starts (!! remove printing soon) 1212 // GF: note splitting starts (!! remove printing soon)
1213 std::cerr << "splitStart" << std::endl; 1213 std::cerr << "splitStart" << std::endl;
1214 if (!m_model) return; 1214 if (!m_model) return;
1215 1215
1229 m_dragStartY = e->y(); 1229 m_dragStartY = e->y();
1230 1230
1231 } 1231 }
1232 1232
1233 void 1233 void
1234 FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) 1234 FlexiNoteLayer::splitEnd(LayerGeometryProvider *v, QMouseEvent *e)
1235 { 1235 {
1236 // GF: note splitting ends. (!! remove printing soon) 1236 // GF: note splitting ends. (!! remove printing soon)
1237 std::cerr << "splitEnd" << std::endl; 1237 std::cerr << "splitEnd" << std::endl;
1238 if (!m_model || !m_editing || m_editMode != SplitNote) return; 1238 if (!m_model || !m_editing || m_editMode != SplitNote) return;
1239 1239
1248 1248
1249 splitNotesAt(v, frame, e); 1249 splitNotesAt(v, frame, e);
1250 } 1250 }
1251 1251
1252 void 1252 void
1253 FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame) 1253 FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame)
1254 { 1254 {
1255 splitNotesAt(v, frame, 0); 1255 splitNotesAt(v, frame, 0);
1256 } 1256 }
1257 1257
1258 void 1258 void
1259 FlexiNoteLayer::splitNotesAt(View *v, sv_frame_t frame, QMouseEvent *e) 1259 FlexiNoteLayer::splitNotesAt(LayerGeometryProvider *v, sv_frame_t frame, QMouseEvent *e)
1260 { 1260 {
1261 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); 1261 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
1262 if (onPoints.empty()) return; 1262 if (onPoints.empty()) return;
1263 1263
1264 FlexiNote note(*onPoints.begin()); 1264 FlexiNote note(*onPoints.begin());
1294 1294
1295 finish(command); 1295 finish(command);
1296 } 1296 }
1297 1297
1298 void 1298 void
1299 FlexiNoteLayer::addNote(View *v, QMouseEvent *e) 1299 FlexiNoteLayer::addNote(LayerGeometryProvider *v, QMouseEvent *e)
1300 { 1300 {
1301 std::cerr << "addNote" << std::endl; 1301 std::cerr << "addNote" << std::endl;
1302 if (!m_model) return; 1302 if (!m_model) return;
1303 1303
1304 sv_frame_t duration = 10000; 1304 sv_frame_t duration = 10000;
1333 finish(command); 1333 finish(command);
1334 } 1334 }
1335 } 1335 }
1336 1336
1337 SparseTimeValueModel * 1337 SparseTimeValueModel *
1338 FlexiNoteLayer::getAssociatedPitchModel(View *v) const 1338 FlexiNoteLayer::getAssociatedPitchModel(LayerGeometryProvider *v) const
1339 { 1339 {
1340 // Better than we used to do, but still not very satisfactory 1340 // Better than we used to do, but still not very satisfactory
1341 1341
1342 cerr << "FlexiNoteLayer::getAssociatedPitchModel()" << endl; 1342 cerr << "FlexiNoteLayer::getAssociatedPitchModel()" << endl;
1343 1343
1357 } 1357 }
1358 return 0; 1358 return 0;
1359 } 1359 }
1360 1360
1361 void 1361 void
1362 FlexiNoteLayer::snapSelectedNotesToPitchTrack(View *v, Selection s) 1362 FlexiNoteLayer::snapSelectedNotesToPitchTrack(LayerGeometryProvider *v, Selection s)
1363 { 1363 {
1364 if (!m_model) return; 1364 if (!m_model) return;
1365 1365
1366 FlexiNoteModel::PointList points = 1366 FlexiNoteModel::PointList points =
1367 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 1367 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
1395 1395
1396 finish(command); 1396 finish(command);
1397 } 1397 }
1398 1398
1399 void 1399 void
1400 FlexiNoteLayer::mergeNotes(View *v, Selection s, bool inclusive) 1400 FlexiNoteLayer::mergeNotes(LayerGeometryProvider *v, Selection s, bool inclusive)
1401 { 1401 {
1402 FlexiNoteModel::PointList points = 1402 FlexiNoteModel::PointList points =
1403 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 1403 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
1404 1404
1405 FlexiNoteModel::PointList::iterator i = points.begin(); 1405 FlexiNoteModel::PointList::iterator i = points.begin();
1438 command->addPoint(newNote); 1438 command->addPoint(newNote);
1439 finish(command); 1439 finish(command);
1440 } 1440 }
1441 1441
1442 bool 1442 bool
1443 FlexiNoteLayer::updateNoteValue(View *v, FlexiNoteModel::Point &note) const 1443 FlexiNoteLayer::updateNoteValue(LayerGeometryProvider *v, FlexiNoteModel::Point &note) const
1444 { 1444 {
1445 SparseTimeValueModel *model = getAssociatedPitchModel(v); 1445 SparseTimeValueModel *model = getAssociatedPitchModel(v);
1446 if (!model) return false; 1446 if (!model) return false;
1447 1447
1448 std::cerr << model->getTypeName() << std::endl; 1448 std::cerr << model->getTypeName() << std::endl;
1480 1480
1481 return true; 1481 return true;
1482 } 1482 }
1483 1483
1484 void 1484 void
1485 FlexiNoteLayer::mouseMoveEvent(View *v, QMouseEvent *e) 1485 FlexiNoteLayer::mouseMoveEvent(LayerGeometryProvider *v, QMouseEvent *e)
1486 { 1486 {
1487 // GF: context sensitive cursors 1487 // GF: context sensitive cursors
1488 // v->setCursor(Qt::ArrowCursor); 1488 // v->setCursor(Qt::ArrowCursor);
1489 FlexiNoteModel::Point note(0); 1489 FlexiNoteModel::Point note(0);
1490 if (!getNoteToEdit(v, e->x(), e->y(), note)) { 1490 if (!getNoteToEdit(v, e->x(), e->y(), note)) {
1508 // v->setCursor(Qt::SizeHorCursor); 1508 // v->setCursor(Qt::SizeHorCursor);
1509 1509
1510 } 1510 }
1511 1511
1512 void 1512 void
1513 FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point &note, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const 1513 FlexiNoteLayer::getRelativeMousePosition(LayerGeometryProvider *v, FlexiNoteModel::Point &note, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const
1514 { 1514 {
1515 // GF: TODO: consoloidate the tolerance values 1515 // GF: TODO: consoloidate the tolerance values
1516 if (!m_model) return; 1516 if (!m_model) return;
1517 1517
1518 int ctol = 0; 1518 int ctol = 0;
1537 // cerr << "FlexiNoteLayer::getRelativeMousePosition: close to: left " << closeToLeft << " right " << closeToRight << " top " << closeToTop << " bottom " << closeToBottom << endl; 1537 // cerr << "FlexiNoteLayer::getRelativeMousePosition: close to: left " << closeToLeft << " right " << closeToRight << " top " << closeToTop << " bottom " << closeToBottom << endl;
1538 } 1538 }
1539 1539
1540 1540
1541 bool 1541 bool
1542 FlexiNoteLayer::editOpen(View *v, QMouseEvent *e) 1542 FlexiNoteLayer::editOpen(LayerGeometryProvider *v, QMouseEvent *e)
1543 { 1543 {
1544 std::cerr << "Opening note editor dialog" << std::endl; 1544 std::cerr << "Opening note editor dialog" << std::endl;
1545 if (!m_model) return false; 1545 if (!m_model) return false;
1546 1546
1547 FlexiNoteModel::Point note(0); 1547 FlexiNoteModel::Point note(0);
1691 1691
1692 finish(command); 1692 finish(command);
1693 } 1693 }
1694 1694
1695 void 1695 void
1696 FlexiNoteLayer::copy(View *v, Selection s, Clipboard &to) 1696 FlexiNoteLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to)
1697 { 1697 {
1698 if (!m_model) return; 1698 if (!m_model) return;
1699 1699
1700 FlexiNoteModel::PointList points = 1700 FlexiNoteModel::PointList points =
1701 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 1701 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
1709 } 1709 }
1710 } 1710 }
1711 } 1711 }
1712 1712
1713 bool 1713 bool
1714 FlexiNoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */) 1714 FlexiNoteLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /*frameOffset */, bool /* interactive */)
1715 { 1715 {
1716 if (!m_model) return false; 1716 if (!m_model) return false;
1717 1717
1718 const Clipboard::PointList &points = from.getPoints(); 1718 const Clipboard::PointList &points = from.getPoints();
1719 1719
1720 bool realign = false; 1720 bool realign = false;
1721 1721
1722 if (clipboardHasDifferentAlignment(v, from)) { 1722 if (clipboardHasDifferentAlignment(v, from)) {
1723 1723
1724 QMessageBox::StandardButton button = 1724 QMessageBox::StandardButton button =
1725 QMessageBox::question(v, tr("Re-align pasted items?"), 1725 QMessageBox::question(v->getWidget(), tr("Re-align pasted items?"),
1726 tr("The items 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?"), 1726 tr("The items 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?"),
1727 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, 1727 QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
1728 QMessageBox::Yes); 1728 QMessageBox::Yes);
1729 1729
1730 if (button == QMessageBox::Cancel) { 1730 if (button == QMessageBox::Cancel) {
1857 // double max = attributes.value("scaleMaximum").toDouble(&alsoOk); 1857 // double max = attributes.value("scaleMaximum").toDouble(&alsoOk);
1858 // if (ok && alsoOk && min != max) setDisplayExtents(min, max); 1858 // if (ok && alsoOk && min != max) setDisplayExtents(min, max);
1859 } 1859 }
1860 1860
1861 void 1861 void
1862 FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) 1862 FlexiNoteLayer::setVerticalRangeToNoteRange(LayerGeometryProvider *v)
1863 { 1863 {
1864 double minf = std::numeric_limits<double>::max(); 1864 double minf = std::numeric_limits<double>::max();
1865 double maxf = 0; 1865 double maxf = 0;
1866 bool hasNotes = 0; 1866 bool hasNotes = 0;
1867 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); 1867 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin();