comparison layer/FlexiNoteLayer.cpp @ 658:050404ae7799 tonioni

toggle button for boundary constraints and note recalculation
author gyorgyf
date Thu, 20 Jun 2013 10:58:40 +0100
parents ac26de7b727a
children 8663a831838f
comparison
equal deleted inserted replaced
657:ac26de7b727a 658:050404ae7799
59 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), 59 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")),
60 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")), 60 m_editingPoint(0, 0.0, 0, 1.f, tr("New Point")),
61 m_editingCommand(0), 61 m_editingCommand(0),
62 m_verticalScale(AutoAlignScale), 62 m_verticalScale(AutoAlignScale),
63 m_scaleMinimum(34), 63 m_scaleMinimum(34),
64 m_scaleMaximum(77) 64 m_scaleMaximum(77),
65 m_intelligentActions(true)
65 { 66 {
66 } 67 }
67 68
68 void 69 void
69 FlexiNoteLayer::setModel(FlexiNoteModel *model) 70 FlexiNoteLayer::setModel(FlexiNoteModel *model)
1017 1018
1018 std::cerr << "edit mode: " << m_editMode << std::endl; 1019 std::cerr << "edit mode: " << m_editMode << std::endl;
1019 1020
1020 switch (m_editMode) { 1021 switch (m_editMode) {
1021 case LeftBoundary : { 1022 case LeftBoundary : {
1022 // left 1023 // left
1023 if (dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; 1024 if (m_intelligentActions && dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1;
1024 // right 1025 // right
1025 if (dragFrame >= m_originalPoint.frame + m_originalPoint.duration) { 1026 if (m_intelligentActions && dragFrame >= m_originalPoint.frame + m_originalPoint.duration) {
1026 dragFrame = m_originalPoint.frame + m_originalPoint.duration - 1; 1027 dragFrame = m_originalPoint.frame + m_originalPoint.duration - 1;
1027 } 1028 }
1028 m_editingPoint.frame = dragFrame; 1029 m_editingPoint.frame = dragFrame;
1029 m_editingPoint.duration = m_originalPoint.frame - dragFrame + m_originalPoint.duration; 1030 m_editingPoint.duration = m_originalPoint.frame - dragFrame + m_originalPoint.duration;
1030 break; 1031 break;
1031 } 1032 }
1032 case RightBoundary : { 1033 case RightBoundary : {
1033 // left 1034 // left
1034 if (dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; 1035 if (m_intelligentActions && dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1;
1035 if (dragFrame >= m_smallestRightNeighbourFrame) dragFrame = m_smallestRightNeighbourFrame - 1; 1036 if (m_intelligentActions && dragFrame >= m_smallestRightNeighbourFrame) dragFrame = m_smallestRightNeighbourFrame - 1;
1036 m_editingPoint.duration = dragFrame - m_originalPoint.frame + 1; 1037 m_editingPoint.duration = dragFrame - m_originalPoint.frame + 1;
1037 break; 1038 break;
1038 } 1039 }
1039 case DragNote : { 1040 case DragNote : {
1040 // left 1041 // left
1041 if (dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1; 1042 if (m_intelligentActions && dragFrame <= m_greatestLeftNeighbourFrame) dragFrame = m_greatestLeftNeighbourFrame + 1;
1042 // right 1043 // right
1043 if (dragFrame + m_originalPoint.duration >= m_smallestRightNeighbourFrame) { 1044 if (m_intelligentActions && dragFrame + m_originalPoint.duration >= m_smallestRightNeighbourFrame) {
1044 dragFrame = m_smallestRightNeighbourFrame - m_originalPoint.duration; 1045 dragFrame = m_smallestRightNeighbourFrame - m_originalPoint.duration;
1045 } 1046 }
1046 m_editingPoint.frame = dragFrame; 1047 m_editingPoint.frame = dragFrame;
1047 m_editingPoint.value = value; 1048 m_editingPoint.value = value;
1048 break; 1049 break;
1135 note.level, note.label); 1136 note.level, note.label);
1136 1137
1137 FlexiNote newNote2(frame, note.value, 1138 FlexiNote newNote2(frame, note.value,
1138 note.duration - newNote1.duration, 1139 note.duration - newNote1.duration,
1139 note.level, note.label); 1140 note.level, note.label);
1140 1141
1141 updateNoteValue(v,newNote1); 1142 if (m_intelligentActions) {
1142 updateNoteValue(v,newNote2); 1143 updateNoteValue(v,newNote1);
1144 updateNoteValue(v,newNote2);
1145 }
1143 1146
1144 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand 1147 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand
1145 (m_model, tr("Edit Point")); 1148 (m_model, tr("Edit Point"));
1146 command->deletePoint(note); 1149 command->deletePoint(note);
1147 if ((e->modifiers() & Qt::ShiftModifier)) { 1150 if ((e->modifiers() & Qt::ShiftModifier)) {