Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 805:1d526ba11a24 warnfix_no_size_t
Remove size_t's and fix warnings in layer/
author | Chris Cannam |
---|---|
date | Tue, 17 Jun 2014 15:18:06 +0100 |
parents | a6b87176b259 |
children | 4c8ca536b54f |
comparison
equal
deleted
inserted
replaced
782:ddae586bc47b | 805:1d526ba11a24 |
---|---|
59 // m_scaleMinimum(0), | 59 // m_scaleMinimum(0), |
60 // m_scaleMaximum(0) | 60 // m_scaleMaximum(0) |
61 | 61 |
62 m_model(0), | 62 m_model(0), |
63 m_editing(false), | 63 m_editing(false), |
64 m_intelligentActions(true), | |
64 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), | 65 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), |
65 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), | 66 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), |
66 m_editingCommand(0), | 67 m_editingCommand(0), |
67 m_verticalScale(AutoAlignScale), | 68 m_verticalScale(AutoAlignScale), |
68 m_editMode(DragNote), | 69 m_editMode(DragNote), |
69 m_scaleMinimum(34), | 70 m_scaleMinimum(34), |
70 m_scaleMaximum(77), | 71 m_scaleMaximum(77) |
71 m_intelligentActions(true) | |
72 { | 72 { |
73 } | 73 } |
74 | 74 |
75 void | 75 void |
76 FlexiNoteLayer::setModel(FlexiNoteModel *model) | 76 FlexiNoteLayer::setModel(FlexiNoteModel *model) |
419 | 419 |
420 FlexiNoteModel::PointList usePoints = prevPoints; | 420 FlexiNoteModel::PointList usePoints = prevPoints; |
421 | 421 |
422 if (prevPoints.empty()) { | 422 if (prevPoints.empty()) { |
423 usePoints = nextPoints; | 423 usePoints = nextPoints; |
424 } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && | 424 } else if (prevPoints.begin()->frame < v->getStartFrame() && |
425 !(nextPoints.begin()->frame > v->getEndFrame())) { | 425 !(nextPoints.begin()->frame > v->getEndFrame())) { |
426 usePoints = nextPoints; | 426 usePoints = nextPoints; |
427 } else if (long(nextPoints.begin()->frame) - frame < | 427 } else if (nextPoints.begin()->frame - frame < |
428 frame - long(prevPoints.begin()->frame)) { | 428 frame - prevPoints.begin()->frame) { |
429 usePoints = nextPoints; | 429 usePoints = nextPoints; |
430 } | 430 } |
431 | 431 |
432 if (!usePoints.empty()) { | 432 if (!usePoints.empty()) { |
433 int fuzz = 2; | 433 int fuzz = 2; |
586 return text; | 586 return text; |
587 } | 587 } |
588 | 588 |
589 bool | 589 bool |
590 FlexiNoteLayer::snapToFeatureFrame(View *v, int &frame, | 590 FlexiNoteLayer::snapToFeatureFrame(View *v, int &frame, |
591 size_t &resolution, | 591 int &resolution, |
592 SnapType snap) const | 592 SnapType snap) const |
593 { | 593 { |
594 if (!m_model) { | 594 if (!m_model) { |
595 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 595 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
596 } | 596 } |
816 float max = m_model->getValueMaximum(); | 816 float max = m_model->getValueMaximum(); |
817 if (max == min) max = min + 1.0; | 817 if (max == min) max = min + 1.0; |
818 | 818 |
819 QPoint localPos; | 819 QPoint localPos; |
820 FlexiNoteModel::Point illuminatePoint(0); | 820 FlexiNoteModel::Point illuminatePoint(0); |
821 bool shouldIlluminate = false; | 821 // bool shouldIlluminate = false; |
822 | 822 |
823 if (v->shouldIlluminateLocalFeatures(this, localPos)) { | 823 // if (v->shouldIlluminateLocalFeatures(this, localPos)) { |
824 shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), | 824 // shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(), |
825 illuminatePoint); | 825 // illuminatePoint); |
826 } | 826 // } |
827 | 827 |
828 paint.save(); | 828 paint.save(); |
829 paint.setRenderHint(QPainter::Antialiasing, false); | 829 paint.setRenderHint(QPainter::Antialiasing, false); |
830 | 830 |
831 for (FlexiNoteModel::PointList::const_iterator i = points.begin(); | 831 for (FlexiNoteModel::PointList::const_iterator i = points.begin(); |
1005 | 1005 |
1006 m_editing = true; | 1006 m_editing = true; |
1007 } | 1007 } |
1008 | 1008 |
1009 void | 1009 void |
1010 FlexiNoteLayer::eraseDrag(View *v, QMouseEvent *e) | 1010 FlexiNoteLayer::eraseDrag(View *, QMouseEvent *) |
1011 { | 1011 { |
1012 } | 1012 } |
1013 | 1013 |
1014 void | 1014 void |
1015 FlexiNoteLayer::eraseEnd(View *v, QMouseEvent *e) | 1015 FlexiNoteLayer::eraseEnd(View *v, QMouseEvent *e) |
1138 } | 1138 } |
1139 m_editingPoint.frame = dragFrame; | 1139 m_editingPoint.frame = dragFrame; |
1140 m_editingPoint.value = value; | 1140 m_editingPoint.value = value; |
1141 break; | 1141 break; |
1142 } | 1142 } |
1143 case SplitNote: // nothing | |
1144 break; | |
1143 } | 1145 } |
1144 updateNoteValue(v, m_editingPoint); | 1146 updateNoteValue(v, m_editingPoint); |
1145 m_editingCommand->addPoint(m_editingPoint); | 1147 m_editingCommand->addPoint(m_editingPoint); |
1146 std::cerr << "added new point(" << m_editingPoint.frame << "," << m_editingPoint.duration << ")" << std::endl; | 1148 std::cerr << "added new point(" << m_editingPoint.frame << "," << m_editingPoint.duration << ")" << std::endl; |
1147 | 1149 |
1148 } | 1150 } |
1149 | 1151 |
1150 void | 1152 void |
1151 FlexiNoteLayer::editEnd(View *v, QMouseEvent *e) | 1153 FlexiNoteLayer::editEnd(View *, QMouseEvent *e) |
1152 { | 1154 { |
1153 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; | 1155 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; |
1154 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; | 1156 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl; |
1155 | 1157 |
1156 if (!m_model || !m_editing) return; | 1158 if (!m_model || !m_editing) return; |
1433 } | 1435 } |
1434 | 1436 |
1435 if (pitchValues.empty()) return false; | 1437 if (pitchValues.empty()) return false; |
1436 | 1438 |
1437 sort(pitchValues.begin(), pitchValues.end()); | 1439 sort(pitchValues.begin(), pitchValues.end()); |
1438 size_t size = pitchValues.size(); | 1440 int size = pitchValues.size(); |
1439 double median; | 1441 double median; |
1440 | 1442 |
1441 if (size % 2 == 0) { | 1443 if (size % 2 == 0) { |
1442 median = (pitchValues[size/2 - 1] + pitchValues[size/2]) / 2; | 1444 median = (pitchValues[size/2 - 1] + pitchValues[size/2]) / 2; |
1443 } else { | 1445 } else { |
1548 delete dialog; | 1550 delete dialog; |
1549 return true; | 1551 return true; |
1550 } | 1552 } |
1551 | 1553 |
1552 void | 1554 void |
1553 FlexiNoteLayer::moveSelection(Selection s, size_t newStartFrame) | 1555 FlexiNoteLayer::moveSelection(Selection s, int newStartFrame) |
1554 { | 1556 { |
1555 if (!m_model) return; | 1557 if (!m_model) return; |
1556 | 1558 |
1557 FlexiNoteModel::EditCommand *command = | 1559 FlexiNoteModel::EditCommand *command = |
1558 new FlexiNoteModel::EditCommand(m_model, tr("Drag Selection")); | 1560 new FlexiNoteModel::EditCommand(m_model, tr("Drag Selection")); |
1652 } | 1654 } |
1653 } | 1655 } |
1654 } | 1656 } |
1655 | 1657 |
1656 bool | 1658 bool |
1657 FlexiNoteLayer::paste(View *v, const Clipboard &from, int frameOffset, bool /* interactive */) | 1659 FlexiNoteLayer::paste(View *v, const Clipboard &from, int /*frameOffset */, bool /* interactive */) |
1658 { | 1660 { |
1659 if (!m_model) return false; | 1661 if (!m_model) return false; |
1660 | 1662 |
1661 const Clipboard::PointList &points = from.getPoints(); | 1663 const Clipboard::PointList &points = from.getPoints(); |
1662 | 1664 |
1684 | 1686 |
1685 for (Clipboard::PointList::const_iterator i = points.begin(); | 1687 for (Clipboard::PointList::const_iterator i = points.begin(); |
1686 i != points.end(); ++i) { | 1688 i != points.end(); ++i) { |
1687 | 1689 |
1688 if (!i->haveFrame()) continue; | 1690 if (!i->haveFrame()) continue; |
1689 size_t frame = 0; | 1691 int frame = 0; |
1690 | 1692 |
1691 if (!realign) { | 1693 if (!realign) { |
1692 | 1694 |
1693 frame = i->getFrame(); | 1695 frame = i->getFrame(); |
1694 | 1696 |
1709 else newPoint.value = (m_model->getValueMinimum() + | 1711 else newPoint.value = (m_model->getValueMinimum() + |
1710 m_model->getValueMaximum()) / 2; | 1712 m_model->getValueMaximum()) / 2; |
1711 if (i->haveLevel()) newPoint.level = i->getLevel(); | 1713 if (i->haveLevel()) newPoint.level = i->getLevel(); |
1712 if (i->haveDuration()) newPoint.duration = i->getDuration(); | 1714 if (i->haveDuration()) newPoint.duration = i->getDuration(); |
1713 else { | 1715 else { |
1714 size_t nextFrame = frame; | 1716 int nextFrame = frame; |
1715 Clipboard::PointList::const_iterator j = i; | 1717 Clipboard::PointList::const_iterator j = i; |
1716 for (; j != points.end(); ++j) { | 1718 for (; j != points.end(); ++j) { |
1717 if (!j->haveFrame()) continue; | 1719 if (!j->haveFrame()) continue; |
1718 if (j != i) break; | 1720 if (j != i) break; |
1719 } | 1721 } |
1788 void | 1790 void |
1789 FlexiNoteLayer::setProperties(const QXmlAttributes &attributes) | 1791 FlexiNoteLayer::setProperties(const QXmlAttributes &attributes) |
1790 { | 1792 { |
1791 SingleColourLayer::setProperties(attributes); | 1793 SingleColourLayer::setProperties(attributes); |
1792 | 1794 |
1793 bool ok, alsoOk; | 1795 bool ok; |
1794 VerticalScale scale = (VerticalScale) | 1796 VerticalScale scale = (VerticalScale) |
1795 attributes.value("verticalScale").toInt(&ok); | 1797 attributes.value("verticalScale").toInt(&ok); |
1796 if (ok) setVerticalScale(scale); | 1798 if (ok) setVerticalScale(scale); |
1797 | 1799 |
1798 float min = attributes.value("scaleMinimum").toFloat(&ok); | 1800 // bool alsoOk; |
1799 float max = attributes.value("scaleMaximum").toFloat(&alsoOk); | 1801 // float min = attributes.value("scaleMinimum").toFloat(&ok); |
1802 // float max = attributes.value("scaleMaximum").toFloat(&alsoOk); | |
1800 // if (ok && alsoOk && min != max) setDisplayExtents(min, max); | 1803 // if (ok && alsoOk && min != max) setDisplayExtents(min, max); |
1801 } | 1804 } |
1802 | 1805 |
1803 void | 1806 void |
1804 FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) | 1807 FlexiNoteLayer::setVerticalRangeToNoteRange(View *v) |