comparison layer/FlexiNoteLayer.cpp @ 806:4c8ca536b54f warnfix_no_size_t

Some more unsigned/long removal
author Chris Cannam
date Tue, 17 Jun 2014 15:36:56 +0100
parents 1d526ba11a24
children 40c6c9344ff6
comparison
equal deleted inserted replaced
805:1d526ba11a24 806:4c8ca536b54f
401 FlexiNoteModel::PointList 401 FlexiNoteModel::PointList
402 FlexiNoteLayer::getLocalPoints(View *v, int x) const 402 FlexiNoteLayer::getLocalPoints(View *v, int x) const
403 { 403 {
404 if (!m_model) return FlexiNoteModel::PointList(); 404 if (!m_model) return FlexiNoteModel::PointList();
405 405
406 long frame = v->getFrameForX(x); 406 int frame = v->getFrameForX(x);
407 407
408 FlexiNoteModel::PointList onPoints = 408 FlexiNoteModel::PointList onPoints =
409 m_model->getPoints(frame); 409 m_model->getPoints(frame);
410 410
411 if (!onPoints.empty()) { 411 if (!onPoints.empty()) {
444 bool 444 bool
445 FlexiNoteLayer::getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &p) const 445 FlexiNoteLayer::getPointToDrag(View *v, int x, int y, FlexiNoteModel::Point &p) const
446 { 446 {
447 if (!m_model) return false; 447 if (!m_model) return false;
448 448
449 long frame = v->getFrameForX(x); 449 int frame = v->getFrameForX(x);
450 450
451 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); 451 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
452 if (onPoints.empty()) return false; 452 if (onPoints.empty()) return false;
453 453
454 // cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << endl; 454 // cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << endl;
473 FlexiNoteLayer::getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &p) const 473 FlexiNoteLayer::getNoteToEdit(View *v, int x, int y, FlexiNoteModel::Point &p) const
474 { 474 {
475 // GF: find the note that is closest to the cursor 475 // GF: find the note that is closest to the cursor
476 if (!m_model) return false; 476 if (!m_model) return false;
477 477
478 long frame = v->getFrameForX(x); 478 int frame = v->getFrameForX(x);
479 479
480 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); 480 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
481 if (onPoints.empty()) return false; 481 if (onPoints.empty()) return false;
482 482
483 // std::cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << std::endl; 483 // std::cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << std::endl;
796 if (!sampleRate) return; 796 if (!sampleRate) return;
797 797
798 // Profiler profiler("FlexiNoteLayer::paint", true); 798 // Profiler profiler("FlexiNoteLayer::paint", true);
799 799
800 int x0 = rect.left(), x1 = rect.right(); 800 int x0 = rect.left(), x1 = rect.right();
801 long frame0 = v->getFrameForX(x0); 801 int frame0 = v->getFrameForX(x0);
802 long frame1 = v->getFrameForX(x1); 802 int frame1 = v->getFrameForX(x1);
803 803
804 FlexiNoteModel::PointList points(m_model->getPoints(frame0, frame1)); 804 FlexiNoteModel::PointList points(m_model->getPoints(frame0, frame1));
805 if (points.empty()) return; 805 if (points.empty()) return;
806 806
807 paint.setPen(getBaseQColor()); 807 paint.setPen(getBaseQColor());
933 { 933 {
934 // SVDEBUG << "FlexiNoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; 934 // SVDEBUG << "FlexiNoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl;
935 935
936 if (!m_model) return; 936 if (!m_model) return;
937 937
938 long frame = v->getFrameForX(e->x()); 938 int frame = v->getFrameForX(e->x());
939 if (frame < 0) frame = 0; 939 if (frame < 0) frame = 0;
940 frame = frame / m_model->getResolution() * m_model->getResolution(); 940 frame = frame / m_model->getResolution() * m_model->getResolution();
941 941
942 float value = getValueForY(v, e->y()); 942 float value = getValueForY(v, e->y());
943 943
957 { 957 {
958 // SVDEBUG << "FlexiNoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; 958 // SVDEBUG << "FlexiNoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl;
959 959
960 if (!m_model || !m_editing) return; 960 if (!m_model || !m_editing) return;
961 961
962 long frame = v->getFrameForX(e->x()); 962 int frame = v->getFrameForX(e->x());
963 if (frame < 0) frame = 0; 963 if (frame < 0) frame = 0;
964 frame = frame / m_model->getResolution() * m_model->getResolution(); 964 frame = frame / m_model->getResolution() * m_model->getResolution();
965 965
966 float newValue = getValueForY(v, e->y()); 966 float newValue = getValueForY(v, e->y());
967 967
968 long newFrame = m_editingPoint.frame; 968 int newFrame = m_editingPoint.frame;
969 long newDuration = frame - newFrame; 969 int newDuration = frame - newFrame;
970 if (newDuration < 0) { 970 if (newDuration < 0) {
971 newFrame = frame; 971 newFrame = frame;
972 newDuration = -newDuration; 972 newDuration = -newDuration;
973 } else if (newDuration == 0) { 973 } else if (newDuration == 0) {
974 newDuration = 1; 974 newDuration = 1;
1056 1056
1057 m_editing = true; 1057 m_editing = true;
1058 m_dragStartX = e->x(); 1058 m_dragStartX = e->x();
1059 m_dragStartY = e->y(); 1059 m_dragStartY = e->y();
1060 1060
1061 long onset = m_originalPoint.frame; 1061 int onset = m_originalPoint.frame;
1062 long offset = m_originalPoint.frame + m_originalPoint.duration - 1; 1062 int offset = m_originalPoint.frame + m_originalPoint.duration - 1;
1063 1063
1064 m_greatestLeftNeighbourFrame = -1; 1064 m_greatestLeftNeighbourFrame = -1;
1065 m_smallestRightNeighbourFrame = std::numeric_limits<long>::max(); 1065 m_smallestRightNeighbourFrame = std::numeric_limits<int>::max();
1066 1066
1067 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); 1067 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin();
1068 i != m_model->getPoints().end(); ++i) { 1068 i != m_model->getPoints().end(); ++i) {
1069 FlexiNote currentNote = *i; 1069 FlexiNote currentNote = *i;
1070 1070
1093 int xdist = e->x() - m_dragStartX; 1093 int xdist = e->x() - m_dragStartX;
1094 int ydist = e->y() - m_dragStartY; 1094 int ydist = e->y() - m_dragStartY;
1095 int newx = m_dragPointX + xdist; 1095 int newx = m_dragPointX + xdist;
1096 int newy = m_dragPointY + ydist; 1096 int newy = m_dragPointY + ydist;
1097 1097
1098 long dragFrame = v->getFrameForX(newx); 1098 int dragFrame = v->getFrameForX(newx);
1099 if (dragFrame < 0) dragFrame = 0; 1099 if (dragFrame < 0) dragFrame = 0;
1100 dragFrame = dragFrame / m_model->getResolution() * m_model->getResolution(); 1100 dragFrame = dragFrame / m_model->getResolution() * m_model->getResolution();
1101 1101
1102 float value = getValueForY(v, newy); 1102 float value = getValueForY(v, newy);
1103 1103
1215 if (xdist != 0 || ydist != 0) { 1215 if (xdist != 0 || ydist != 0) {
1216 std::cerr << "mouse moved" << std::endl; 1216 std::cerr << "mouse moved" << std::endl;
1217 return; 1217 return;
1218 } 1218 }
1219 1219
1220 long frame = v->getFrameForX(e->x()); 1220 int frame = v->getFrameForX(e->x());
1221 1221
1222 splitNotesAt(v, frame, e); 1222 splitNotesAt(v, frame, e);
1223 } 1223 }
1224 1224
1225 void 1225 void
1272 FlexiNoteLayer::addNote(View *v, QMouseEvent *e) 1272 FlexiNoteLayer::addNote(View *v, QMouseEvent *e)
1273 { 1273 {
1274 std::cerr << "addNote" << std::endl; 1274 std::cerr << "addNote" << std::endl;
1275 if (!m_model) return; 1275 if (!m_model) return;
1276 1276
1277 long duration = 10000; 1277 int duration = 10000;
1278 1278
1279 long frame = v->getFrameForX(e->x()); 1279 int frame = v->getFrameForX(e->x());
1280 float value = getValueForY(v, e->y()); 1280 float value = getValueForY(v, e->y());
1281 1281
1282 if (m_intelligentActions) { 1282 if (m_intelligentActions) {
1283 long smallestRightNeighbourFrame = 0; 1283 int smallestRightNeighbourFrame = 0;
1284 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin(); 1284 for (FlexiNoteModel::PointList::const_iterator i = m_model->getPoints().begin();
1285 i != m_model->getPoints().end(); ++i) { 1285 i != m_model->getPoints().end(); ++i) {
1286 FlexiNote currentNote = *i; 1286 FlexiNote currentNote = *i;
1287 if (currentNote.frame > frame) { 1287 if (currentNote.frame > frame) {
1288 smallestRightNeighbourFrame = currentNote.frame; 1288 smallestRightNeighbourFrame = currentNote.frame;
1735 finish(command); 1735 finish(command);
1736 return true; 1736 return true;
1737 } 1737 }
1738 1738
1739 void 1739 void
1740 FlexiNoteLayer::addNoteOn(long frame, int pitch, int velocity) 1740 FlexiNoteLayer::addNoteOn(int frame, int pitch, int velocity)
1741 { 1741 {
1742 m_pendingNoteOns.insert(FlexiNote(frame, pitch, 0, float(velocity) / 127.0, "")); 1742 m_pendingNoteOns.insert(FlexiNote(frame, pitch, 0, float(velocity) / 127.0, ""));
1743 } 1743 }
1744 1744
1745 void 1745 void
1746 FlexiNoteLayer::addNoteOff(long frame, int pitch) 1746 FlexiNoteLayer::addNoteOff(int frame, int pitch)
1747 { 1747 {
1748 for (FlexiNoteSet::iterator i = m_pendingNoteOns.begin(); 1748 for (FlexiNoteSet::iterator i = m_pendingNoteOns.begin();
1749 i != m_pendingNoteOns.end(); ++i) { 1749 i != m_pendingNoteOns.end(); ++i) {
1750 if (lrintf((*i).value) == pitch) { 1750 if (lrintf((*i).value) == pitch) {
1751 FlexiNote note(*i); 1751 FlexiNote note(*i);