Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 874:7a80fa6a6dfc tonioni
Tidy
author | Chris Cannam |
---|---|
date | Tue, 11 Nov 2014 12:55:30 +0000 |
parents | 5d4e3e36945f |
children | 0e674f1bbf08 |
comparison
equal
deleted
inserted
replaced
873:9855fc0927af | 874:7a80fa6a6dfc |
---|---|
1133 tr("Drag Point")); | 1133 tr("Drag Point")); |
1134 } | 1134 } |
1135 | 1135 |
1136 m_editingCommand->deletePoint(m_editingPoint); | 1136 m_editingCommand->deletePoint(m_editingPoint); |
1137 | 1137 |
1138 std::cerr << "edit mode: " << m_editMode << std::endl; | 1138 std::cerr << "edit mode: " << m_editMode << " intelligent actions = " |
1139 << m_intelligentActions << std::endl; | |
1139 | 1140 |
1140 switch (m_editMode) { | 1141 switch (m_editMode) { |
1141 case LeftBoundary : { | 1142 case LeftBoundary : { |
1142 // left | 1143 // left |
1143 if (m_intelligentActions && dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; | 1144 if (m_intelligentActions && dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; |
1208 | 1209 |
1209 void | 1210 void |
1210 FlexiNoteLayer::splitStart(View *v, QMouseEvent *e) | 1211 FlexiNoteLayer::splitStart(View *v, QMouseEvent *e) |
1211 { | 1212 { |
1212 // GF: note splitting starts (!! remove printing soon) | 1213 // GF: note splitting starts (!! remove printing soon) |
1213 std::cerr << "splitStart" << std::endl; | 1214 std::cerr << "splitStart (n.b. editStart will be called later, if the user drags the mouse)" << std::endl; |
1214 if (!m_model) return; | 1215 if (!m_model) return; |
1215 | 1216 |
1216 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; | 1217 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; |
1217 // m_originalPoint = m_editingPoint; | 1218 // m_originalPoint = m_editingPoint; |
1218 // | 1219 // |
1225 } | 1226 } |
1226 | 1227 |
1227 m_editing = true; | 1228 m_editing = true; |
1228 m_dragStartX = e->x(); | 1229 m_dragStartX = e->x(); |
1229 m_dragStartY = e->y(); | 1230 m_dragStartY = e->y(); |
1230 | |
1231 } | 1231 } |
1232 | 1232 |
1233 void | 1233 void |
1234 FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) | 1234 FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) |
1235 { | 1235 { |
1337 SparseTimeValueModel * | 1337 SparseTimeValueModel * |
1338 FlexiNoteLayer::getAssociatedPitchModel(View *v) const | 1338 FlexiNoteLayer::getAssociatedPitchModel(View *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 |
1344 for (int i = 0; i < v->getLayerCount(); ++i) { | 1344 for (int i = 0; i < v->getLayerCount(); ++i) { |
1345 Layer *layer = v->getLayer(i); | 1345 Layer *layer = v->getLayer(i); |
1346 if (layer && | 1346 if (layer && |
1347 layer->getLayerPresentationName() != "candidate") { | 1347 layer->getLayerPresentationName() != "candidate") { |
1348 cerr << "FlexiNoteLayer::getAssociatedPitchModel: looks like our layer is " << layer << endl; | 1348 // cerr << "FlexiNoteLayer::getAssociatedPitchModel: looks like our layer is " << layer << endl; |
1349 SparseTimeValueModel *model = qobject_cast<SparseTimeValueModel *> | 1349 SparseTimeValueModel *model = qobject_cast<SparseTimeValueModel *> |
1350 (layer->getModel()); | 1350 (layer->getModel()); |
1351 cerr << "FlexiNoteLayer::getAssociatedPitchModel: and its model is " << model << endl; | 1351 // cerr << "FlexiNoteLayer::getAssociatedPitchModel: and its model is " << model << endl; |
1352 if (model && model->getScaleUnits() == "Hz") { | 1352 if (model && model->getScaleUnits() == "Hz") { |
1353 cerr << "FlexiNoteLayer::getAssociatedPitchModel: it's good, returning " << model << endl; | 1353 cerr << "FlexiNoteLayer::getAssociatedPitchModel: it's good, returning " << model << endl; |
1354 return model; | 1354 return model; |
1355 } | 1355 } |
1356 } | 1356 } |
1357 } | 1357 } |
1358 cerr << "FlexiNoteLayer::getAssociatedPitchModel: failed to find a model" << endl; | |
1358 return 0; | 1359 return 0; |
1359 } | 1360 } |
1360 | 1361 |
1361 void | 1362 void |
1362 FlexiNoteLayer::snapSelectedNotesToPitchTrack(View *v, Selection s) | 1363 FlexiNoteLayer::snapSelectedNotesToPitchTrack(View *v, Selection s) |
1490 if (!getNoteToEdit(v, e->x(), e->y(), note)) { | 1491 if (!getNoteToEdit(v, e->x(), e->y(), note)) { |
1491 // v->setCursor(Qt::UpArrowCursor); | 1492 // v->setCursor(Qt::UpArrowCursor); |
1492 return; | 1493 return; |
1493 } | 1494 } |
1494 | 1495 |
1495 bool closeToLeft = false, closeToRight = false, closeToTop = false, closeToBottom = false; | 1496 bool closeToLeft = false, closeToRight = false, |
1496 getRelativeMousePosition(v, note, e->x(), e->y(), closeToLeft, closeToRight, closeToTop, closeToBottom); | 1497 closeToTop = false, closeToBottom = false; |
1497 // if (!closeToLeft) return; | 1498 getRelativeMousePosition(v, note, e->x(), e->y(), |
1498 // if (closeToTop) v->setCursor(Qt::SizeVerCursor); | 1499 closeToLeft, closeToRight, |
1499 | 1500 closeToTop, closeToBottom); |
1500 if (closeToLeft) { v->setCursor(Qt::SizeHorCursor); m_editMode = LeftBoundary; return; } | 1501 |
1501 if (closeToRight) { v->setCursor(Qt::SizeHorCursor); m_editMode = RightBoundary; return; } | 1502 if (closeToLeft) { |
1502 if (closeToTop) { v->setCursor(Qt::CrossCursor); m_editMode = DragNote; return; } | 1503 v->setCursor(Qt::SizeHorCursor); |
1503 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); m_editMode = SplitNote; return; } | 1504 m_editMode = LeftBoundary; |
1504 | 1505 cerr << "edit mode -> LeftBoundary" << endl; |
1505 v->setCursor(Qt::ArrowCursor); | 1506 } else if (closeToRight) { |
1506 | 1507 v->setCursor(Qt::SizeHorCursor); |
1507 std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; | 1508 m_editMode = RightBoundary; |
1508 // v->setCursor(Qt::SizeHorCursor); | 1509 cerr << "edit mode -> RightBoundary" << endl; |
1509 | 1510 } else if (closeToTop) { |
1511 v->setCursor(Qt::CrossCursor); | |
1512 m_editMode = DragNote; | |
1513 cerr << "edit mode -> DragNote" << endl; | |
1514 } else if (closeToBottom) { | |
1515 v->setCursor(Qt::UpArrowCursor); | |
1516 m_editMode = SplitNote; | |
1517 cerr << "edit mode -> SplitNote" << endl; | |
1518 } else { | |
1519 v->setCursor(Qt::ArrowCursor); | |
1520 } | |
1510 } | 1521 } |
1511 | 1522 |
1512 void | 1523 void |
1513 FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const | 1524 FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const |
1514 { | 1525 { |