|
From: Tapio V. <aa...@us...> - 2011-01-20 11:20:20
|
Module: editor
Branch: master
Commit: 6b32cd3d4502d07b38dc2f52a84efceb50193abb
Author: Tapio Vierros <tap...@gm...>
Date: Thu Jan 20 13:19:33 2011 +0200
NoteLabel y-movement is constrained to note levels.
---
notegraphwidget.cc | 7 +++++--
notelabel.cc | 5 ++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 816f06e..3bf8c54 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -18,6 +18,11 @@ namespace {
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: QLabel(parent), m_noteHalfHeight(), m_panHotSpot(), m_selectedNote(), m_selectedAction(NONE), m_seeking(), m_actionHappened(), m_pitch(), m_seekHandle(this)
{
+ // Determine NoteLabel height
+ NoteLabel templabel(Note(" "), NULL);
+ m_noteHalfHeight = templabel.height()/2;
+ templabel.close();
+
// FIXME: Temporary hack to make testing quicker
analyzeMusic("music.ogg");
@@ -174,8 +179,6 @@ void NoteGraphWidget::updateNotes()
gap = FloatingGap(child->x() + child->width());
}
}
- if (!m_notes.isEmpty())
- m_noteHalfHeight = m_notes.front()->height()/2;
}
void NoteGraphWidget::updateMusicPos(qint64 time, bool smoothing)
diff --git a/notelabel.cc b/notelabel.cc
index 48e652b..1fa5fcf 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -103,7 +103,10 @@ void NoteLabel::mouseMoveEvent(QMouseEvent *event)
// Moving
QPoint newpos = pos() + event->pos() - m_hotspot;
move(newpos);
- if (ngw) ngw->updateNotes();
+ if (ngw) {
+ move(x(), ngw->n2px(ngw->px2n(y())));
+ ngw->updateNotes();
+ }
// Check if we need a new hotspot, because the note was constrained
if (pos().x() != newpos.x()) m_hotspot.rx() = event->x();
|