|
From: Tapio V. <aa...@us...> - 2011-01-13 13:17:52
|
Module: editor
Branch: master
Commit: 1fc438555df7d039b4d33431fac1ce1008c267ad
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 13 15:16:53 2011 +0200
Note loading now determines the needed viewport.
Makes US notes visible again.
---
editorapp.cc | 4 ++--
notegraphwidget.cc | 17 ++++++++++++++---
notegraphwidget.hh | 4 +++-
notelabel.cc | 1 -
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index e3fc389..59504fa 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -55,7 +55,7 @@ EditorApp::EditorApp(QWidget *parent): QMainWindow(parent)
void EditorApp::operationDone(const Operation &op)
{
- std::cout << "Push op: " << op.dump() << std::endl;
+ //std::cout << "Push op: " << op.dump() << std::endl;
opStack.push(op);
}
@@ -117,7 +117,7 @@ void EditorApp::on_actionOpen_triggered()
QFileInfo finfo(fileName);
try {
song.reset(new Song(QString(finfo.path()+"/").toStdString(), finfo.fileName().toStdString()));
- noteGraph->setLyrics(song->getVocalTrack().notes);
+ noteGraph->setLyrics(song->getVocalTrack());
updateSongMeta(true);
noteGraph->doOperation(Operation("BLOCK")); // Lock the undo stack
ui.tabWidget->setCurrentIndex(1); // Swicth to song properties tab
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 7a6e99b..202b561 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -10,7 +10,6 @@
namespace {
static Operation opFromNote(const NoteLabel& note, int id) {
Operation op("NEW");
- op << id << note.lyric() << note.x() << note.y() << note.width() << note.height() << note.isFloating();
return op;
}
}
@@ -40,7 +39,7 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
progress.setValue(width);
// FIXME: Width should come from song length * pixPerSec
- setFixedSize(std::max(width, (unsigned)1024), noteYStep * 12 * m_octaves);
+ setFixedSize(std::max(width, (unsigned)1024), h());
setFocusPolicy(Qt::StrongFocus);
setWhatsThis(tr("Note graph that displays the song notes and allows you to manipulate them."));
@@ -92,9 +91,18 @@ void NoteGraphWidget::setLyrics(QString lyrics)
finalizeNewLyrics();
}
-void NoteGraphWidget::setLyrics(const Notes ¬es)
+void NoteGraphWidget::setLyrics(const VocalTrack &track)
{
clear();
+
+ // Determine how many octaves are needed and what is the base line
+ int diff = track.noteMax - track.noteMin;
+ m_octaves = std::ceil(diff / 12.0f) + 1;
+ m_lowestNote = clamp(track.noteMin - 6, 0, 1000);
+ std::cout << "--: " << m_octaves << " " << m_lowestNote << std::endl;
+ setFixedSize(s2px(track.endTime), ndiff2px(m_octaves*12));
+
+ const Notes ¬es = track.notes;
for (Notes::const_iterator it = notes.begin(); it != notes.end(); ++it) {
if (it->type == Note::NORMAL || it->type == Note::GOLDEN || it->type == Note::FREESTYLE) {
m_notes.push_back(new NoteLabel(*it, this, QPoint(s2px(it->begin), n2px(it->note)),
@@ -411,6 +419,9 @@ int NoteGraphWidget::s2px(double sec) const {
double NoteGraphWidget::px2s(int px) const {
return px / m_pixPerSec;
}
+int NoteGraphWidget::ndiff2px(int dn) const {
+ return dn * noteYStep;
+}
int NoteGraphWidget::n2px(int note) const {
int highestNote = m_lowestNote + 12 * m_octaves;
return (highestNote - note) * noteYStep;
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 065229d..4d40379 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -21,7 +21,7 @@ public:
void clear();
void setLyrics(QString lyrics);
- void setLyrics(const Notes ¬es);
+ void setLyrics(const VocalTrack &track);
void updateNotes();
void selectNote(NoteLabel* note);
@@ -33,8 +33,10 @@ public:
int s2px(double sec) const;
double px2s(int px) const;
+ int ndiff2px(int dn) const;
int n2px(int note) const;
int px2n(int px) const;
+ int h() const { return 12 * m_octaves * noteYStep; }
signals:
diff --git a/notelabel.cc b/notelabel.cc
index 9705d65..c2d08ce 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -17,7 +17,6 @@ NoteLabel::NoteLabel(const Note ¬e, QWidget *parent, const QPoint &position,
createPixmap(size);
if (!position.isNull())
move(position);
- std::cout << x() << " " << y() << " " << width() << std::endl;
setMouseTracking(true);
setMinimumSize(min_width, 10);
setAttribute(Qt::WA_DeleteOnClose);
|