comparison layer/FlexiNoteLayer.cpp @ 635:5c9dcec5f3e9 tonioni

splitting notes works but major cleanup needed
author gyorgyf
date Sat, 20 Apr 2013 08:38:37 +0100
parents 4fa3951bbb05
children ba76130ed7e5
comparison
equal deleted inserted replaced
634:4fa3951bbb05 635:5c9dcec5f3e9
623 if (shouldConvertMIDIToHz()) { 623 if (shouldConvertMIDIToHz()) {
624 min = Pitch::getFrequencyForPitch(lrintf(min)); 624 min = Pitch::getFrequencyForPitch(lrintf(min));
625 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 625 max = Pitch::getFrequencyForPitch(lrintf(max + 1));
626 } 626 }
627 627
628 std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; 628 // std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl;
629 629
630 } else if (log) { 630 } else if (log) {
631 631
632 LogRange::mapRange(min, max); 632 LogRange::mapRange(min, max);
633 633
634 std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; 634 // std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl;
635 635
636 } 636 }
637 637
638 } else { 638 } else {
639 639
906 906
907 void 907 void
908 FlexiNoteLayer::editStart(View *v, QMouseEvent *e) 908 FlexiNoteLayer::editStart(View *v, QMouseEvent *e)
909 { 909 {
910 // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl; 910 // SVDEBUG << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << endl;
911 std::cerr << "FlexiNoteLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl;
911 912
912 if (!m_model) return; 913 if (!m_model) return;
913 914
914 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; 915 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return;
915 m_originalPoint = m_editingPoint; 916 m_originalPoint = m_editingPoint;
929 930
930 void 931 void
931 FlexiNoteLayer::editDrag(View *v, QMouseEvent *e) 932 FlexiNoteLayer::editDrag(View *v, QMouseEvent *e)
932 { 933 {
933 // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; 934 // SVDEBUG << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl;
935 std::cerr << "FlexiNoteLayer::editDrag(" << e->x() << "," << e->y() << ")" << std::endl;
934 936
935 if (!m_model || !m_editing) return; 937 if (!m_model || !m_editing) return;
936 938
937 int xdist = e->x() - m_dragStartX; 939 int xdist = e->x() - m_dragStartX;
938 int ydist = e->y() - m_dragStartY; 940 int ydist = e->y() - m_dragStartY;
955 m_editingPoint.value = value; 957 m_editingPoint.value = value;
956 m_editingCommand->addPoint(m_editingPoint); 958 m_editingCommand->addPoint(m_editingPoint);
957 } 959 }
958 960
959 void 961 void
960 FlexiNoteLayer::editEnd(View *, QMouseEvent *) 962 FlexiNoteLayer::editEnd(View *v, QMouseEvent *e)
961 { 963 {
962 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl; 964 // SVDEBUG << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl;
965 std::cerr << "FlexiNoteLayer::editEnd(" << e->x() << "," << e->y() << ")" << std::endl;
966
963 if (!m_model || !m_editing) return; 967 if (!m_model || !m_editing) return;
964 968
965 if (m_editingCommand) { 969 if (m_editingCommand) {
966 970
967 QString newName = m_editingCommand->getName(); 971 QString newName = m_editingCommand->getName();
981 } 985 }
982 986
983 m_editingCommand = 0; 987 m_editingCommand = 0;
984 m_editing = false; 988 m_editing = false;
985 } 989 }
990
991 void
992 FlexiNoteLayer::splitStart(View *v, QMouseEvent *e)
993 {
994 std::cerr << "splitStart" << std::endl;
995 if (!m_model) return;
996
997 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return;
998 // m_originalPoint = m_editingPoint;
999 //
1000 // m_dragPointX = v->getXForFrame(m_editingPoint.frame);
1001 // m_dragPointY = getYForValue(v, m_editingPoint.value);
1002
1003 if (m_editingCommand) {
1004 finish(m_editingCommand);
1005 m_editingCommand = 0;
1006 }
1007
1008 m_editing = true;
1009 m_dragStartX = e->x();
1010 m_dragStartY = e->y();
1011
1012 }
1013
1014 void
1015 FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e)
1016 {
1017 std::cerr << "splitEnd" << std::endl;
1018 if (!m_model || !m_editing) return;
1019
1020 int xdist = e->x() - m_dragStartX;
1021 int ydist = e->y() - m_dragStartY;
1022 if (xdist != 0 || ydist != 0) {
1023 std::cerr << "mouse moved" << std::endl;
1024 return;
1025 }
1026
1027 FlexiNoteModel::Point note(0);
1028 if (!getPointToDrag(v, e->x(), e->y(), note)) return;
1029
1030 long frame = v->getFrameForX(e->x());
1031
1032 FlexiNoteModel::Point newNote1 = note;
1033 newNote1.frame = note.frame;
1034 newNote1.value = note.value;
1035 // newNote1.duration = note.duration+10000;
1036 newNote1.duration = frame - note.frame - 100;
1037 newNote1.label = note.label;
1038
1039 FlexiNoteModel::Point newNote2 = note;
1040 newNote2.frame = frame + 100;
1041 newNote2.value = note.value;
1042 newNote2.duration = note.duration - (frame - note.frame - 100);
1043 newNote2.label = note.label;
1044
1045
1046 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand
1047 (m_model, tr("Edit Point"));
1048 command->deletePoint(note);
1049 command->addPoint(newNote1);
1050 command->addPoint(newNote2);
1051 finish(command);
1052
1053 }
1054
986 1055
987 bool 1056 bool
988 FlexiNoteLayer::editOpen(View *v, QMouseEvent *e) 1057 FlexiNoteLayer::editOpen(View *v, QMouseEvent *e)
989 { 1058 {
990 std::cerr << "Opening note editor dialog" << std::endl; 1059 std::cerr << "Opening note editor dialog" << std::endl;