Mercurial > hg > svgui
comparison layer/FlexiNoteLayer.cpp @ 649:2ad082c5a090 tonioni
boundary actions and note delete consolidated
author | gyorgyf |
---|---|
date | Sun, 16 Jun 2013 20:40:05 +0100 |
parents | f61a54364d1d |
children | 76c5dfe333ee |
comparison
equal
deleted
inserted
replaced
648:f61a54364d1d | 649:2ad082c5a090 |
---|---|
942 | 942 |
943 if (!m_model) return; | 943 if (!m_model) return; |
944 | 944 |
945 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; | 945 if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return; |
946 m_originalPoint = m_editingPoint; | 946 m_originalPoint = m_editingPoint; |
947 | 947 |
948 m_dragPointX = v->getXForFrame(m_editingPoint.frame); | 948 if (m_editMode == rightBoundary) { |
949 m_dragPointX = v->getXForFrame(m_editingPoint.frame + m_editingPoint.duration); | |
950 } else { | |
951 m_dragPointX = v->getXForFrame(m_editingPoint.frame); | |
952 } | |
949 m_dragPointY = getYForValue(v, m_editingPoint.value); | 953 m_dragPointY = getYForValue(v, m_editingPoint.value); |
950 | 954 |
951 if (m_editingCommand) { | 955 if (m_editingCommand) { |
952 finish(m_editingCommand); | 956 finish(m_editingCommand); |
953 m_editingCommand = 0; | 957 m_editingCommand = 0; |
981 m_editingCommand = new FlexiNoteModel::EditCommand(m_model, | 985 m_editingCommand = new FlexiNoteModel::EditCommand(m_model, |
982 tr("Drag Point")); | 986 tr("Drag Point")); |
983 } | 987 } |
984 | 988 |
985 m_editingCommand->deletePoint(m_editingPoint); | 989 m_editingCommand->deletePoint(m_editingPoint); |
986 m_editingPoint.frame = frame; | 990 if (m_editMode == leftBoundary) |
991 m_editingPoint.duration = m_editingPoint.duration + (m_editingPoint.frame - frame); // GF: left boundary change | |
992 if (m_editMode == rightBoundary) { | |
993 m_editingPoint.duration = frame - m_editingPoint.frame; // GF: right boundary change | |
994 } else { | |
995 m_editingPoint.frame = frame; | |
996 } | |
987 m_editingPoint.value = value; | 997 m_editingPoint.value = value; |
988 m_editingCommand->addPoint(m_editingPoint); | 998 m_editingCommand->addPoint(m_editingPoint); |
999 std::cerr << "added new point(" << m_editingPoint.frame << "," << m_editingPoint.duration << ")" << std::endl; | |
1000 | |
989 } | 1001 } |
990 | 1002 |
991 void | 1003 void |
992 FlexiNoteLayer::editEnd(View *v, QMouseEvent *e) | 1004 FlexiNoteLayer::editEnd(View *v, QMouseEvent *e) |
993 { | 1005 { |
1045 void | 1057 void |
1046 FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) | 1058 FlexiNoteLayer::splitEnd(View *v, QMouseEvent *e) |
1047 { | 1059 { |
1048 // GF: note splitting ends. (!! remove printing soon) | 1060 // GF: note splitting ends. (!! remove printing soon) |
1049 std::cerr << "splitEnd" << std::endl; | 1061 std::cerr << "splitEnd" << std::endl; |
1050 if (!m_model || !m_editing) return; | 1062 if (!m_model || !m_editing || m_editMode != splitNote) return; |
1051 | 1063 |
1052 int xdist = e->x() - m_dragStartX; | 1064 int xdist = e->x() - m_dragStartX; |
1053 int ydist = e->y() - m_dragStartY; | 1065 int ydist = e->y() - m_dragStartY; |
1054 if (xdist != 0 || ydist != 0) { | 1066 if (xdist != 0 || ydist != 0) { |
1055 std::cerr << "mouse moved" << std::endl; | 1067 std::cerr << "mouse moved" << std::endl; |
1056 return; | 1068 return; |
1057 } | 1069 } |
1058 | 1070 |
1059 // MM simpler declaration | 1071 // MM: simpler declaration |
1060 FlexiNote note(0); | 1072 FlexiNote note(0); |
1061 if (!getPointToDrag(v, e->x(), e->y(), note)) return; | 1073 if (!getPointToDrag(v, e->x(), e->y(), note)) return; |
1062 | 1074 |
1063 long frame = v->getFrameForX(e->x()); | 1075 long frame = v->getFrameForX(e->x()); |
1064 | 1076 |
1065 int gap = 0; // MM: I prefer a gap of 0, but we can decide later | 1077 int gap = 0; // MM: I prefer a gap of 0, but we can decide later |
1066 | 1078 |
1067 // MM: changed this a bit, to make it slightly clearer | 1079 // MM: changed this a bit, to make it slightly clearer (// GF: nice changes!) |
1068 FlexiNote newNote1(note.frame, note.value, | 1080 FlexiNote newNote1(note.frame, note.value, |
1069 frame - note.frame - gap, | 1081 frame - note.frame - gap, |
1070 note.level, note.label); | 1082 note.level, note.label); |
1071 | 1083 |
1072 FlexiNote newNote2(frame, note.value, | 1084 FlexiNote newNote2(frame, note.value, |
1074 note.level, note.label); | 1086 note.level, note.label); |
1075 | 1087 |
1076 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand | 1088 FlexiNoteModel::EditCommand *command = new FlexiNoteModel::EditCommand |
1077 (m_model, tr("Edit Point")); | 1089 (m_model, tr("Edit Point")); |
1078 command->deletePoint(note); | 1090 command->deletePoint(note); |
1091 if ((e->modifiers() & Qt::ShiftModifier)) { | |
1092 finish(command); | |
1093 return; | |
1094 } | |
1079 command->addPoint(newNote1); | 1095 command->addPoint(newNote1); |
1080 command->addPoint(newNote2); | 1096 command->addPoint(newNote2); |
1081 finish(command); | 1097 finish(command); |
1082 | 1098 |
1083 } | 1099 } |
1094 } | 1110 } |
1095 | 1111 |
1096 bool closeToLeft = false, closeToRight = false, closeToTop = false, closeToBottom = false; | 1112 bool closeToLeft = false, closeToRight = false, closeToTop = false, closeToBottom = false; |
1097 getRelativeMousePosition(v, note, e->x(), e->y(), closeToLeft, closeToRight, closeToTop, closeToBottom); | 1113 getRelativeMousePosition(v, note, e->x(), e->y(), closeToLeft, closeToRight, closeToTop, closeToBottom); |
1098 // if (!closeToLeft) return; | 1114 // if (!closeToLeft) return; |
1099 if (closeToLeft || closeToRight) { v->setCursor(Qt::SizeHorCursor); return; } | |
1100 // if (closeToTop) v->setCursor(Qt::SizeVerCursor); | 1115 // if (closeToTop) v->setCursor(Qt::SizeVerCursor); |
1101 if (closeToTop) { v->setCursor(Qt::CrossCursor); return; } | 1116 |
1102 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); return; } | 1117 if (closeToLeft) { v->setCursor(Qt::SizeHorCursor); m_editMode = leftBoundary; return; } |
1118 if (closeToRight) { v->setCursor(Qt::SizeHorCursor); m_editMode = rightBoundary; return; } | |
1119 if (closeToTop) { v->setCursor(Qt::CrossCursor); m_editMode = dragNote; return; } | |
1120 if (closeToBottom) { v->setCursor(Qt::UpArrowCursor); m_editMode = splitNote; return; } | |
1121 | |
1103 v->setCursor(Qt::ArrowCursor); | 1122 v->setCursor(Qt::ArrowCursor); |
1104 | 1123 |
1105 | 1124 // std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; |
1106 std::cerr << "Mouse moved in edit mode over FlexiNoteLayer" << std::endl; | |
1107 // v->setCursor(Qt::SizeHorCursor); | 1125 // v->setCursor(Qt::SizeHorCursor); |
1108 | 1126 |
1109 } | 1127 } |
1110 | 1128 |
1111 void | 1129 void |
1112 FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const | 1130 FlexiNoteLayer::getRelativeMousePosition(View *v, FlexiNoteModel::Point ¬e, int x, int y, bool &closeToLeft, bool &closeToRight, bool &closeToTop, bool &closeToBottom) const |
1113 { | 1131 { |
1132 // GF: TODO: consoloidate the tolerance values | |
1114 if (!m_model) return; | 1133 if (!m_model) return; |
1115 | 1134 |
1116 int ctol = 2; | 1135 int ctol = 2; |
1117 int noteStartX = v->getXForFrame(note.frame); | 1136 int noteStartX = v->getXForFrame(note.frame); |
1118 int noteEndX = v->getXForFrame(note.frame + note.duration); | 1137 int noteEndX = v->getXForFrame(note.frame + note.duration); |