diff --git a/src/libs/core/score/tmeasureobject.h b/src/libs/core/score/tmeasureobject.h
index 7ed22818791ac6c93fc3fee22b623df1de99ce68..587123c16ca4c85a4ac21ef6ebf11908333bb91b 100644
--- a/src/libs/core/score/tmeasureobject.h
+++ b/src/libs/core/score/tmeasureobject.h
@@ -127,6 +127,8 @@ protected:
* Checks notes rhythms of group @p segmentId belongs to
* for 8ths and 16ths and crates beams (@p TbeamObject) if they occurs
* It can be called before @p TnoteObject will be created
+ * When beam was set or note was added to it it returns number of that group
+ * or -1 if no beams were added
*/
int beamGroup(int segmentId);
diff --git a/src/libs/core/score/tnoteobject.cpp b/src/libs/core/score/tnoteobject.cpp
index 041b0d0636e235ff6141f51b6342d919f6fd8a59..adc9425caf9aa8a9c21fa52069f8ce311c4a12a9 100644
--- a/src/libs/core/score/tnoteobject.cpp
+++ b/src/libs/core/score/tnoteobject.cpp
@@ -99,6 +99,7 @@ TnoteObject::TnoteObject(TstaffObject* staffObj, TnotePair* wrapper) :
m_alter = qobject_cast<QQuickItem*>(comp.create());
m_alter->setParentItem(m_head);
+ connect(m_alter, &QQuickItem::widthChanged, this, &TnoteObject::alterWidthChanged);
m_flag = qobject_cast<QQuickItem*>(comp.create());
m_flag->setParentItem(m_stem);
@@ -107,6 +108,7 @@ TnoteObject::TnoteObject(TstaffObject* staffObj, TnotePair* wrapper) :
setColor(qApp->palette().text().color());
setHeight(staffObj->staffItem()->height());
+ setAcceptHoverEvents(true);
}
@@ -226,12 +228,12 @@ void TnoteObject::setX(qreal xx) {
}
-qreal TnoteObject::rightX() {
+qreal TnoteObject::rightX() const {
return x() + width() + staff()->gapFactor() * rhythmFactor() - m_alter->width();
}
-qreal TnoteObject::rhythmFactor() {
+qreal TnoteObject::rhythmFactor() const {
if (m_note->rhythm() == Trhythm::NoRhythm)
return 0.0;
@@ -360,6 +362,22 @@ void TnoteObject::keySignatureChanged() {
}
+void TnoteObject::hoverEnterEvent(QHoverEvent*) {
+ m_measure->score()->changeActiveNote(this);
+}
+
+
+void TnoteObject::hoverLeaveEvent(QHoverEvent*) {
+ m_measure->score()->changeActiveNote(nullptr);
+}
+
+
+void TnoteObject::hoverMoveEvent(QHoverEvent* event) {
+ if (static_cast<int>(m_measure->score()->activeYpos()) != static_cast<int>(event->pos().y()))
+ m_measure->score()->setActiveNotePos(qFloor(event->pos().y()));
+}
+
+
//#################################################################################################
//################### PRIVATE ############################################
//#################################################################################################
@@ -389,7 +407,7 @@ void TnoteObject::updateAlter() {
void TnoteObject::updateWidth() {
- setWidth(m_alter->width() + m_head->width() + (m_note->rtm.stemDown() ? 0.0 : m_flag->width() - 0.5));
+ setWidth(m_alter->width() + m_head->width() + (m_note->isRest() ? 0.0 : m_note->rtm.stemDown() ? 0.0 : m_flag->width() - 0.5));
updateTieScale();
}
@@ -428,4 +446,6 @@ void TnoteObject::checkStem() {
m_stem->setVisible(true);
} else
m_stem->setVisible(false);
+ if (m_stemHeight != m_stem->height())
+ m_stemHeight = m_stem->height();
}
diff --git a/src/libs/core/score/tnoteobject.h b/src/libs/core/score/tnoteobject.h
index 11de61a7b5665f22ce0c6aeeb859f628bf413f0a..a01c496d2299d2e2a4b663843756741aee3da262 100644
--- a/src/libs/core/score/tnoteobject.h
+++ b/src/libs/core/score/tnoteobject.h
@@ -40,7 +40,9 @@ class NOOTKACORE_EXPORT TnoteObject : public QQuickItem
Q_OBJECT
- Q_PROPERTY(qreal notePosY READ notePosY WRITE setNotePosY NOTIFY notePosYchanged)
+ Q_PROPERTY(qreal notePosY READ notePosY NOTIFY notePosYchanged)
+ Q_PROPERTY(qreal alterWidth READ alterWidth NOTIFY alterWidthChanged)
+ Q_PROPERTY(int index READ index)
friend class TscoreObject;
friend class TstaffObject;
@@ -71,6 +73,8 @@ public:
qreal stemHeight() const { return m_stemHeight; }
void setStemHeight(qreal sh);
+ qreal alterWidth() { return m_alter->width(); }
+
QColor color() { return m_head->property("color").value<QColor>(); }
void setColor(const QColor& c);
@@ -84,12 +88,12 @@ public:
/**
* shortcut to X coordinate of right note corner plus gap related to rhythm and staff gap factor
*/
- qreal rightX();
+ qreal rightX() const;
/**
* Returns gap factor after this note item depends on current rhythm value
*/
- qreal rhythmFactor();
+ qreal rhythmFactor() const;
/**
* Returns position of the top of this note stem in staff coordinates
@@ -105,6 +109,7 @@ public:
signals:
void notePosYchanged();
+ void alterWidthChanged();
protected:
QString getAccidText();
@@ -128,6 +133,10 @@ protected:
*/
void checkTie();
+ void hoverEnterEvent(QHoverEvent*) override;
+ void hoverLeaveEvent(QHoverEvent*) override;
+ void hoverMoveEvent(QHoverEvent* event) override;
+
private:
TstaffObject *m_staff;
diff --git a/src/libs/core/score/tstaffobject.h b/src/libs/core/score/tstaffobject.h
index 013ef49a7bad55d7b6ffe67bbabb1f0a9e23df1a..dea0fc514ae49380b605a010d53e3121c25d4c57 100644
--- a/src/libs/core/score/tstaffobject.h
+++ b/src/libs/core/score/tstaffobject.h
@@ -68,7 +68,7 @@ public:
/**
* Y coordinate of upper staff line
*/
- qreal upperLine() { return m_upperLine; }
+ qreal upperLine() const { return m_upperLine; }
void setUpperLine(qreal upLine);
QQuickItem* staffItem() { return m_staffItem; }
@@ -77,7 +77,7 @@ public:
/**
* X coordinate of first note (or width of clef + key sign. + meter)
*/
- qreal notesIndent() { return m_notesIndent; }
+ qreal notesIndent() const { return m_notesIndent; }
void setNotesIndent(qreal ni);
int firstMeasureNr();
@@ -111,9 +111,9 @@ public:
/**
* Width of all notes on the staff
*/
- qreal allNotesWidth() { return m_allNotesWidth; }
+ qreal allNotesWidth() const { return m_allNotesWidth; }
- qreal gapsSum() { return m_gapsSum; }
+ qreal gapsSum() const { return m_gapsSum; }
/**
* Scaling factor of the staff
@@ -136,9 +136,9 @@ protected:
void fit();
void updateNotesPos(int startMeasure = 0);
- int firstMeasureId() { return m_firstMeasureId; }
+ int firstMeasureId() const { return m_firstMeasureId; }
void setFirstMeasureId(int firstId) { m_firstMeasureId = firstId; emit firstMeasureNrChanged(); }
- int lastMeasureId() { return m_lastMeasureId; }
+ int lastMeasureId() const { return m_lastMeasureId; }
void setLastMeasureId(int lastId) { m_lastMeasureId = lastId; }
/**