Skip to content
Snippets Groups Projects
Commit 56a25300 authored by SeeLook's avatar SeeLook
Browse files

Added technical data to note object, implement string number and bowing...

Added technical data to note object, implement string number and bowing symbols, fingering maybe later
parent 4fd6c172
Branches
Tags
No related merge requests found
/***************************************************************************
* 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 ############################################
//#################################################################################################
......
/***************************************************************************
* 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;
......
/***************************************************************************
* 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();
}
/***************************************************************************
* 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
......@@ -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();
)
......
/***************************************************************************
* 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
*/
......
......@@ -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());
}
}
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment