diff --git a/src/libs/core/score/tnoteobject.cpp b/src/libs/core/score/tnoteobject.cpp index e73b59b1050b342675d26b4842a6b4457fd8492e..4620fbff00a3f53d743df1de3d351cb1fc6a143b 100644 --- a/src/libs/core/score/tnoteobject.cpp +++ b/src/libs/core/score/tnoteobject.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Tomasz Bojczuk * + * Copyright (C) 2017-2018 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -47,7 +47,7 @@ static const QString accCharTable[6] = { * Width of every accidental for Scorek font of pixel size set to 7.0 * It was measured by QML and corresponds to QFont size @p QFont::setPointSizeF(5.5) (except of neutral) */ -static const qreal accWidthTable[6] = { 2.78125, 1.671875, 0.0, 1.765625, 2.03125, 2.34375 }; +// static const qreal accWidthTable[6] = { 2.78125, 1.671875, 0.0, 1.765625, 2.03125, 2.34375 }; /** * Static array with space definitions for each rhythm value @@ -267,6 +267,15 @@ if (updateStem) } +quint32 TnoteObject::technical() const { return m_wrapper ? m_wrapper->technical() : 255; } + + +void TnoteObject::setTechnical(quint32 tech) { + if (m_wrapper) + m_wrapper->setTechnical(tech); +} + + void TnoteObject::setX(qreal xx) { if (staff()->score()->singleNote()) QQuickItem::setX(xx); @@ -425,6 +434,47 @@ QString TnoteObject::getHeadText(const Trhythm& r) { } +void TnoteObject::setStringNumber(int strNr) { + if (!m_stringNumber && strNr > 0 && strNr < 7) { + m_staff->score()->component()->setData("import QtQuick 2.9; Text { z: -1; font { pixelSize: 4; family: \"Nootka\" } }", QUrl()); + m_stringNumber = qobject_cast<QQuickItem*>(m_staff->score()->component()->create()); + m_stringNumber->setParentItem(this); + } + if (strNr > 0 && strNr < 7) { + m_stringNumber->setProperty("text", QString::number(strNr)); + m_stringNumber->setX((width() - m_stringNumber->width()) / 2.0); + // TODO set Y position + m_stringNumber->setVisible(true); + } else { + if (m_stringNumber) + m_stringNumber->setVisible(false); + } +} + + +void TnoteObject::setBowing(EbowDirection bowDir) { + if (!m_bowing && bowDir != BowUndefined) { + m_staff->score()->component()->setData("import QtQuick 2.9; Text { z: -1; font { pixelSize: 5; family: \"Scorek\" } }", QUrl()); + m_bowing = qobject_cast<QQuickItem*>(m_staff->score()->component()->create()); + m_bowing->setParentItem(this); + } + if (bowDir != BowUndefined) { + m_bowing->setProperty("text", bowDir == BowDown ? QStringLiteral("\uE610") : QStringLiteral("\uE612")); + m_bowing->setX((width() - m_bowing->width()) / 2.0); +// m_bowing->setY(m_staff->upperLine()); + m_bowing->setVisible(true); + } else { + if (m_bowing) + m_bowing->setVisible(false); + } +} + + +void TnoteObject::setFingerNumber(int fiNr) +{ +} + + //################################################################################################# //################### PROTECTED ############################################ //################################################################################################# diff --git a/src/libs/core/score/tnoteobject.h b/src/libs/core/score/tnoteobject.h index a377fa0d13e461bb9bd59708c2b811227c6d1e20..a4eb3ba7ba93cbe0e245e63f5e6166a0a07c6db9 100644 --- a/src/libs/core/score/tnoteobject.h +++ b/src/libs/core/score/tnoteobject.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Tomasz Bojczuk * + * Copyright (C) 2017-2018 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -69,6 +69,9 @@ public: Tnote* note() { return m_note; } void setNote(const Tnote& n); + quint32 technical() const; + void setTechnical(quint32 tech); + qreal notePosY() const { return m_notePosY; } Q_INVOKABLE Trhythm rhythm() const; @@ -126,6 +129,18 @@ public: */ static QString getHeadText(const Trhythm& r); + void setFingerNumber(int fiNr); + void setStringNumber(int strNr); + + enum EbowDirection { + BowUndefined = 0, + BowDown = 2, /**< For bandoneon it is bellow opening */ + BowUp = 4 /**< For bandoneon it is bellow closing */ + }; + Q_ENUM(EbowDirection) + + void setBowing(EbowDirection bowDir); + signals: void noteChanged(); void notePosYchanged(); @@ -184,6 +199,9 @@ private: QString m_accidText; QQuickItem *m_tie = nullptr; QQuickItem *m_name = nullptr; + QQuickItem *m_stringNumber = nullptr; + QQuickItem *m_bowing = nullptr; + QQuickItem *m_fingerNumber = nullptr; QQuickItem *m_debug; diff --git a/src/libs/core/score/tnotepair.cpp b/src/libs/core/score/tnotepair.cpp index 5d5bcbfd2562ac349cbb9b2cecdb463dfc3cb96b..2d857833a94297be27a482bf8776f6bfd9b44d60 100644 --- a/src/libs/core/score/tnotepair.cpp +++ b/src/libs/core/score/tnotepair.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Tomasz Bojczuk * + * Copyright (C) 2017-2018 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -18,6 +18,7 @@ #include "tnotepair.h" #include "music/tnote.h" +#include "music/tnotedata.h" #include "tnoteobject.h" #include "tstaffobject.h" #include "tbeamobject.h" @@ -26,7 +27,7 @@ TnotePair::TnotePair(int index, Tnote* n, TnoteObject* ob) : m_note(n), m_noteItem(ob), - m_index(index) + m_index(static_cast<quint16>(index)) { } @@ -49,6 +50,18 @@ void TnotePair::setNote(const Tnote& n) { } +void TnotePair::setTechnical(quint32 tech) { + if (tech != m_technical.data()) { + TnoteData newData(tech); + if (newData.fingerPos().str() != m_technical.fingerPos().str()) + m_noteItem->setStringNumber(newData.fingerPos().str()); + if (newData.bowing() != m_technical.bowing()) + m_noteItem->setBowing(static_cast<TnoteObject::EbowDirection>(newData.bowing())); + m_technical.setData(tech); + } +} + + void TnotePair::approve() { if (m_changes) { if (m_changes & e_beamChanged || m_changes & e_stemDirChanged) @@ -90,4 +103,5 @@ void TnotePair::flush() { m_noteItem->checkTie(); } m_noteItem->setStaff(nullptr); + m_technical.reset(); } diff --git a/src/libs/core/score/tnotepair.h b/src/libs/core/score/tnotepair.h index f1744f42fb3610926b8316777c925f8df63ce3be..47239e67b9b4c441691684ff951f199bf12c065f 100644 --- a/src/libs/core/score/tnotepair.h +++ b/src/libs/core/score/tnotepair.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Tomasz Bojczuk * + * Copyright (C) 2017-2018 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -21,6 +21,7 @@ #include <QtCore/qobject.h> +#include "music/tnotedata.h" class Tnote; @@ -60,6 +61,14 @@ public: */ void setNote(Tnote* n) { m_note = n; } + /** + * Bowing, fingering, string number and etc... + */ + quint32 technical() const { return m_technical.data(); } + void setTechnical(quint32 tech); + + TnoteData& techicalData() { return m_technical; } + /** * Number of rhythmical group in the measure, -1 (undefined) by default */ @@ -120,6 +129,7 @@ private: quint16 m_index; int m_changes = 0; TbeamObject *m_beam = nullptr; + TnoteData m_technical; }; #endif // TNOTEPAIR_H diff --git a/src/libs/core/score/tscoreobject.cpp b/src/libs/core/score/tscoreobject.cpp index 5ce184f358bbdd71daab06b0e96852716abe25bc..62fd9e67a21173b1ab73fd7dd60c922002407d26 100644 --- a/src/libs/core/score/tscoreobject.cpp +++ b/src/libs/core/score/tscoreobject.cpp @@ -375,7 +375,7 @@ void TscoreObject::setNote(TnoteObject* no, const Tnote& n) { note(2)->setVisible(false); } } - if (m_recordMode) + if (!m_recordMode) setSelectedItem(no); } @@ -388,6 +388,11 @@ void TscoreObject::setNote(int noteNr, const Tnote& n) { } +void TscoreObject::setTechnical(int noteId, quint32 tech) { + if (noteId >= 0 && noteId < notesCount()) + noteSegment(noteId)->setTechnical(tech); +} + TnoteObject* TscoreObject::note(int noteId) { return noteId > -1 && noteId < notesCount() ? m_segments[noteId]->item() : nullptr; @@ -476,8 +481,10 @@ CHECKTIME ( setKeySignatureEnabled(true); setKeySignature(newKey); } - for (int n = 0; n < melody->length(); ++n) + for (int n = 0; n < melody->length(); ++n) { addNote(melody->note(n)->p()); + lastSegment()->setTechnical(melody->note(n)->noteData()); + } adjustScoreWidth(); emitLastNote(); ) diff --git a/src/libs/core/score/tscoreobject.h b/src/libs/core/score/tscoreobject.h index 6c70370a54e6c2858a5b7dd5b3d258848ac7da81..75788fd24e5efce9ac3f4bf1eed27abe1fad789f 100644 --- a/src/libs/core/score/tscoreobject.h +++ b/src/libs/core/score/tscoreobject.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2017 by Tomasz Bojczuk * + * Copyright (C) 2017-2018 by Tomasz Bojczuk * * seelook@gmail.com * * * * This program is free software; you can redistribute it and/or modify * @@ -133,6 +133,8 @@ public: Q_INVOKABLE void setNote(TnoteObject* no, const Tnote& n); Q_INVOKABLE void setNote(int noteNr, const Tnote& n); + void setTechnical(int noteId, quint32 tech); + /** * Returns a note item of @p TnoteObject */ diff --git a/src/main/tmainscoreobject.cpp b/src/main/tmainscoreobject.cpp index 1192425d6673e200dfea495e3ecbde6a2f67bf7d..6203931988716d92c6b8e4f5d8ea904ae4f12258 100644 --- a/src/main/tmainscoreobject.cpp +++ b/src/main/tmainscoreobject.cpp @@ -25,6 +25,7 @@ #include <tsound.h> #include <tcolor.h> #include <music/tkeysignature.h> +#include <music/tnotedata.h> #include <score/tnoteobject.h> #include <QtGui/qguiapplication.h> @@ -56,7 +57,7 @@ TmainScoreObject::TmainScoreObject(QObject* parent) : m_extraAccidsAct = new Taction(tr("Additional accidentals"), QString(), this); m_extraAccidsAct->setCheckable(true); -// m_showNamesAct->setChecked(GLOB->????); +// m_extraAccidsAct->setChecked(GLOB->????); m_deleteLastAct = new Taction(tr("Delete note"), QStringLiteral("delete"), this); m_clearScoreAct = new Taction(tr("Delete all notes"), QStringLiteral("clear-score"), this); @@ -128,6 +129,8 @@ void TmainScoreObject::clearScore() { } m_questionMark->setVisible(false); m_scoreObj->setBgColor(qApp->palette().base().color()); + if (m_scoreObj->singleNote()) + m_scoreObj->note(1)->setTechnical(255); } @@ -148,6 +151,11 @@ void TmainScoreObject::setSelectedItem(int id) { } +void TmainScoreObject::setTechnical(int noteId, quint32 tech) { + m_scoreObj->setTechnical(noteId, tech); +} + + void TmainScoreObject::askQuestion(Tmelody* mel) { m_scoreObj->setBgColor(scoreBackgroundColor(GLOB->EquestionColor, 20)); m_scoreObj->setMelody(mel); @@ -156,10 +164,18 @@ void TmainScoreObject::askQuestion(Tmelody* mel) { } +/** + * We are sure that this kind of questions occurs only in single note mode + */ void TmainScoreObject::askQuestion(const Tnote& note, char realStr) { m_scoreObj->setBgColor(scoreBackgroundColor(GLOB->EquestionColor, 20)); m_scoreObj->setNote(m_scoreObj->note(1), note); m_questionMark->setVisible(true); + if (realStr > 0 && realStr < 7) { + TnoteData nd; + nd.setFingerPos(TfingerPos(realStr, 0)); + m_scoreObj->note(1)->setTechnical(nd.data()); + } } diff --git a/src/main/tmainscoreobject.h b/src/main/tmainscoreobject.h index b1b46a65060d8d315936ebbdf03ea688bf7b74a9..13a51cb8aa59db5d107c13206304bc2d54ba02f5 100644 --- a/src/main/tmainscoreobject.h +++ b/src/main/tmainscoreobject.h @@ -92,6 +92,7 @@ public: char keySignatureValue(); Tnote getNote(int id); void setSelectedItem(int id); + void setTechnical(int noteId, quint32 tech); // exam/exercise related void askQuestion(const Tnote& note, char realStr = 0);