|
From: Tapio V. <aa...@us...> - 2011-02-04 08:01:44
|
Module: editor
Branch: master
Commit: 881d0166d4cda3bd022638f9dc2180169f4511a0
Author: Tapio Vierros <tap...@gm...>
Date: Fri Feb 4 09:54:16 2011 +0200
Operation "NEW" now also takes seconds and note id instead of pixels.
---
notegraphwidget.cc | 11 +++++------
notelabelmanager.cc | 13 +++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 17a637c..08d6242 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -13,9 +13,9 @@
namespace {
- static Operation opFromNote(const NoteLabel& note, int id) {
+ static Operation opFromNote(const Note& note, int id, bool floating) {
Operation op("NEW");
- op << id << note.lyric() << note.x() << note.y() << note.width() << note.height() << note.isFloating();
+ op << id << note.syllable << note.begin << note.end << note.note << floating;
return op;
}
}
@@ -65,8 +65,8 @@ void NoteGraphWidget::setLyrics(QString lyrics)
QString word;
ts2 >> word;
if (!word.isEmpty()) {
- m_notes.push_back(new NoteLabel(Note(word), this, QPoint(0, n2px(24) - m_noteHalfHeight), QSize(), !firstNote));
- doOperation(opFromNote(*m_notes.back(), m_notes.size()-1), Operation::NO_EXEC);
+ Note note(word); note.note = 24;
+ doOperation(opFromNote(note, m_notes.size(), !firstNote));
if (sentenceStart) setLineBreak(m_notes.back(), true);
firstNote = false;
sentenceStart = false;
@@ -84,8 +84,7 @@ void NoteGraphWidget::setLyrics(const VocalTrack &track)
const Notes ¬es = track.notes;
for (Notes::const_iterator it = notes.begin(); it != notes.end(); ++it) {
if (it->type == Note::SLEEP) continue;
- m_notes.push_back(new NoteLabel(*it, this, QPoint(s2px(it->begin), n2px(it->note) - m_noteHalfHeight), QSize(s2px(it->length()), 0), false));
- doOperation(opFromNote(*m_notes.back(), m_notes.size()-1), Operation::NO_EXEC);
+ doOperation(opFromNote(*it, m_notes.size(), false));
}
updateNotes();
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 2bc8556..a603017 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -75,13 +75,14 @@ void NoteLabelManager::split(NoteLabel *note, float ratio)
int cutpos = int(std::ceil(note->lyric().length() * ratio));
QString firstst = note->lyric().left(cutpos);
QString secondst = note->lyric().right(note->lyric().length() - cutpos);
- int w1 = ratio * note->width();
+
+ const Note& n = note->note();
// Create operations for adding the new labels and deleting the old one
int id = getNoteLabelId(note);
Operation new1("NEW"), new2("NEW");
- new1 << id << firstst << note->pos().x() << note->pos().y() << w1 << 0 << note->isFloating();
- new2 << id+1 << secondst << note->pos().x() + w1 << note->pos().y() << note->width() - w1 << 0 << note->isFloating();
+ new1 << id << firstst << n.begin << n.begin + n.length() * ratio << n.note << note->isFloating();
+ new2 << id+1 << secondst << n.begin + n.length() * ratio << n.end << n.note << note->isFloating();
Operation del("DEL"); del << id+2;
Operation combiner("COMBINER"); combiner << 3; // This will combine the previous ones to one undo action
doOperation(new1); doOperation(new2); doOperation(del); doOperation(combiner);
@@ -189,9 +190,9 @@ void NoteLabelManager::doOperation(const Operation& op, Operation::OperationFlag
NoteLabel *newLabel = new NoteLabel(
Note(op.s(2)), // Note(lyric)
this, // parent
- QPoint(op.i(3), op.i(4)), // x,y
- QSize(op.i(5), op.i(6)), // w,h
- op.b(7) // floating
+ QPoint(s2px(op.i(3)), n2px(op.i(5))), // x,y
+ QSize(s2px(op.i(4) - op.i(3)), 2 * m_noteHalfHeight), // w,h
+ op.b(6) // floating
);
if (m_notes.isEmpty()) m_notes.push_back(newLabel);
else m_notes.insert(op.i(1), newLabel);
|