|
From: Tapio V. <aa...@us...> - 2011-01-10 12:12:06
|
Module: editor
Branch: master
Commit: ad5f40af5fbe2c8a2471fde4c86fb442b715b1de
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 10 14:11:02 2011 +0200
Vertical note position now constrained to discrete steps.
---
notegraphwidget.cc | 13 ++++++++++---
notegraphwidget.hh | 3 +++
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 04b8d36..17cf9f7 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -3,6 +3,10 @@
#include <cmath>
#include "notelabel.hh"
#include "notegraphwidget.hh"
+#include "util.hh"
+
+
+const int NoteGraphWidget::noteYStep = 40;
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: QWidget(parent), m_panHotSpot(), m_selectedNote(), m_selectedAction(NONE)
@@ -25,7 +29,7 @@ void NoteGraphWidget::setLyrics(QString lyrics)
{
QTextStream ts(&lyrics, QIODevice::ReadOnly);
const int gap = 10;
- int x = gap, y = 50;
+ int x = gap, y = 2 * noteYStep;
clear();
while (!ts.atEnd()) {
@@ -151,8 +155,11 @@ void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
{
(void)*event;
if (m_selectedAction != NONE) {
- m_selectedNote->startResizing(0);
- m_selectedNote->startDragging(QPoint());
+ if (m_selectedNote) {
+ m_selectedNote->startResizing(0);
+ m_selectedNote->startDragging(QPoint());
+ m_selectedNote->move(m_selectedNote->pos().x(), int(round(m_selectedNote->pos().y() / float(noteYStep))) * noteYStep);
+ }
m_selectedAction = NONE;
}
m_panHotSpot = QPoint();
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 34ce8d4..6ddd0cd 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -9,6 +9,9 @@ typedef std::list<NoteLabel*> NoteLabels;
class NoteGraphWidget: public QWidget
{
public:
+
+ static const int noteYStep;
+
NoteGraphWidget(QWidget *parent = 0);
void clear();
|