2012-05-26 14:26:10 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
2013-09-06 09:36:31 +02:00
|
|
|
// Copyright (C) 2002-2013 Werner Schweer
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2
|
|
|
|
// as published by the Free Software Foundation and appearing in
|
|
|
|
// the file LICENCE.GPL
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
/**
|
|
|
|
\file
|
2013-03-25 13:15:50 +01:00
|
|
|
Implementation of classes Chord
|
2012-05-26 14:26:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "chord.h"
|
|
|
|
#include "note.h"
|
|
|
|
#include "xml.h"
|
|
|
|
#include "style.h"
|
|
|
|
#include "segment.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "measure.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "tuplet.h"
|
|
|
|
#include "hook.h"
|
2013-08-22 12:18:14 +02:00
|
|
|
#include "tie.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "arpeggio.h"
|
|
|
|
#include "score.h"
|
|
|
|
#include "tremolo.h"
|
2015-02-04 18:54:03 +01:00
|
|
|
#include "glissando.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "staff.h"
|
2013-06-10 21:13:04 +02:00
|
|
|
#include "part.h"
|
2012-05-26 14:26:10 +02:00
|
|
|
#include "utils.h"
|
|
|
|
#include "articulation.h"
|
|
|
|
#include "undo.h"
|
|
|
|
#include "chordline.h"
|
|
|
|
#include "lyrics.h"
|
|
|
|
#include "navigate.h"
|
|
|
|
#include "stafftype.h"
|
|
|
|
#include "stem.h"
|
|
|
|
#include "mscore.h"
|
|
|
|
#include "accidental.h"
|
|
|
|
#include "noteevent.h"
|
|
|
|
#include "pitchspelling.h"
|
2013-03-25 13:15:50 +01:00
|
|
|
#include "stemslash.h"
|
|
|
|
#include "ledgerline.h"
|
2013-06-10 21:13:04 +02:00
|
|
|
#include "drumset.h"
|
|
|
|
#include "key.h"
|
2013-11-11 16:53:03 +01:00
|
|
|
#include "sym.h"
|
2014-04-22 17:02:03 +02:00
|
|
|
#include "stringdata.h"
|
2014-04-23 18:07:38 +02:00
|
|
|
#include "beam.h"
|
2013-03-22 15:26:55 +01:00
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2016-09-03 17:45:59 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// LedgerLineData
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
struct LedgerLineData {
|
|
|
|
int line;
|
|
|
|
qreal minX, maxX;
|
|
|
|
bool visible;
|
|
|
|
bool accidental;
|
|
|
|
};
|
|
|
|
|
2013-03-22 15:26:55 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// upNote / downNote
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Note* Chord::upNote() const
|
|
|
|
{
|
2016-06-06 10:33:09 +02:00
|
|
|
Q_ASSERT(!_notes.empty());
|
|
|
|
|
2013-03-22 15:26:55 +01:00
|
|
|
Note* result = _notes.back();
|
2014-04-22 19:40:25 +02:00
|
|
|
if (!staff())
|
|
|
|
return result;
|
|
|
|
if (staff()->isDrumStaff()) {
|
2016-02-06 22:03:43 +01:00
|
|
|
for (Note* n : _notes) {
|
2013-03-22 15:26:55 +01:00
|
|
|
if (n->line() < result->line()) {
|
|
|
|
result = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 19:40:25 +02:00
|
|
|
else if (staff()->isTabStaff()) {
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = staff()->staffType();
|
|
|
|
int line = tab->lines() - 1; // start at bottom line
|
2014-04-22 19:40:25 +02:00
|
|
|
int noteLine;
|
|
|
|
// scan each note: if TAB strings are not in sequential order,
|
|
|
|
// visual order of notes might not correspond to pitch order
|
2016-02-06 22:03:43 +01:00
|
|
|
for (Note* n : _notes) {
|
2014-04-22 19:40:25 +02:00
|
|
|
noteLine = tab->physStringToVisual(n->string());
|
|
|
|
if (noteLine < line) {
|
|
|
|
line = noteLine;
|
|
|
|
result = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-03-22 15:26:55 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Note* Chord::downNote() const
|
|
|
|
{
|
2016-06-06 10:33:09 +02:00
|
|
|
Q_ASSERT(!_notes.empty());
|
|
|
|
|
2013-03-22 15:26:55 +01:00
|
|
|
Note* result = _notes.front();
|
2014-04-22 19:40:25 +02:00
|
|
|
if (!staff())
|
|
|
|
return result;
|
2014-05-15 13:42:03 +02:00
|
|
|
if (staff()->isDrumStaff()) {
|
2016-02-06 22:03:43 +01:00
|
|
|
for (Note* n : _notes) {
|
2013-03-22 15:26:55 +01:00
|
|
|
if (n->line() > result->line()) {
|
|
|
|
result = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-22 19:40:25 +02:00
|
|
|
else if (staff()->isTabStaff()) {
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = staff()->staffType();
|
|
|
|
int line = 0; // start at top line
|
2014-04-22 19:40:25 +02:00
|
|
|
int noteLine;
|
|
|
|
// scan each note: if TAB strings are not in sequential order,
|
|
|
|
// visual order of notes might not correspond to pitch order
|
2016-02-06 22:03:43 +01:00
|
|
|
for (Note* n : _notes) {
|
2014-04-22 19:40:25 +02:00
|
|
|
noteLine = tab->physStringToVisual(n->string());
|
|
|
|
if (noteLine > line) {
|
|
|
|
line = noteLine;
|
|
|
|
result = n;
|
2014-05-15 13:42:03 +02:00
|
|
|
}
|
2014-04-22 19:40:25 +02:00
|
|
|
}
|
|
|
|
}
|
2013-03-22 15:26:55 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
2012-09-06 14:00:14 +02:00
|
|
|
// upLine / downLine
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
int Chord::upLine() const
|
|
|
|
{
|
2013-03-22 15:26:55 +01:00
|
|
|
return (staff() && staff()->isTabStaff()) ? upString()*2 : upNote()->line();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2012-09-06 14:00:14 +02:00
|
|
|
int Chord::downLine() const
|
|
|
|
{
|
2013-03-22 15:26:55 +01:00
|
|
|
return (staff() && staff()->isTabStaff()) ? downString()*2 : downNote()->line();
|
2012-09-06 14:00:14 +02:00
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
2012-09-06 14:00:14 +02:00
|
|
|
// upString / downString
|
|
|
|
//
|
|
|
|
// return the topmost / bottommost string used by chord
|
|
|
|
// Top and bottom refer to the DRAWN position, not the position in the instrument
|
|
|
|
// (i.e., upside-down TAB are taken into account)
|
|
|
|
//
|
|
|
|
// If no staff, always return 0
|
|
|
|
// If staf is not a TAB, always returns TOP and BOTTOM staff lines
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2012-09-06 14:00:14 +02:00
|
|
|
int Chord::upString() const
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2012-09-06 14:00:14 +02:00
|
|
|
// if no staff or staff not a TAB, return 0 (=topmost line)
|
|
|
|
if(!staff() || !staff()->isTabStaff())
|
|
|
|
return 0;
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = staff()->staffType();
|
|
|
|
int line = tab->lines() - 1; // start at bottom line
|
2012-09-06 14:00:14 +02:00
|
|
|
int noteLine;
|
|
|
|
// scan each note: if TAB strings are not in sequential order,
|
|
|
|
// visual order of notes might not correspond to pitch order
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
noteLine = tab->physStringToVisual(_notes.at(i)->string());
|
|
|
|
if (noteLine < line)
|
2012-09-06 14:00:14 +02:00
|
|
|
line = noteLine;
|
|
|
|
}
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Chord::downString() const
|
|
|
|
{
|
2014-04-28 18:38:50 +02:00
|
|
|
if (!staff()) // if no staff, return 0
|
2012-09-06 14:00:14 +02:00
|
|
|
return 0;
|
2014-04-28 18:38:50 +02:00
|
|
|
if (!staff()->isTabStaff()) // if staff not a TAB, return bottom line
|
2012-09-06 14:00:14 +02:00
|
|
|
return staff()->lines()-1;
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = staff()->staffType();
|
|
|
|
int line = 0; // start at top line
|
|
|
|
int noteLine;
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
noteLine = tab->physStringToVisual(_notes.at(i)->string());
|
2014-04-28 18:38:50 +02:00
|
|
|
if (noteLine > line)
|
2012-09-06 14:00:14 +02:00
|
|
|
line = noteLine;
|
|
|
|
}
|
|
|
|
return line;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Chord
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Chord::Chord(Score* s)
|
|
|
|
: ChordRest(s)
|
|
|
|
{
|
2013-01-03 16:56:56 +01:00
|
|
|
_ledgerLines = 0;
|
2012-11-19 10:08:15 +01:00
|
|
|
_stem = 0;
|
|
|
|
_hook = 0;
|
2016-07-10 12:00:57 +02:00
|
|
|
_stemDirection = Direction_AUTO;
|
2012-11-19 10:08:15 +01:00
|
|
|
_arpeggio = 0;
|
|
|
|
_tremolo = 0;
|
2014-12-13 17:40:39 +01:00
|
|
|
_endsGlissando = false;
|
2014-05-27 10:35:28 +02:00
|
|
|
_noteType = NoteType::NORMAL;
|
2012-11-19 10:08:15 +01:00
|
|
|
_stemSlash = 0;
|
|
|
|
_noStem = false;
|
2014-03-28 16:29:55 +01:00
|
|
|
_playEventType = PlayEventType::Auto;
|
2014-05-21 15:41:23 +02:00
|
|
|
_crossMeasure = CrossMeasure::UNKNOWN;
|
2013-06-16 23:33:37 +02:00
|
|
|
_graceIndex = 0;
|
2014-05-22 10:10:58 +02:00
|
|
|
setFlags(ElementFlag::MOVABLE | ElementFlag::ON_STAFF);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2014-06-27 13:41:49 +02:00
|
|
|
Chord::Chord(const Chord& c, bool link)
|
|
|
|
: ChordRest(c, link)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2014-06-27 13:41:49 +02:00
|
|
|
if (link)
|
2016-03-24 08:29:17 +01:00
|
|
|
score()->undo(new Link(const_cast<Chord*>(&c), this));
|
2013-01-03 16:56:56 +01:00
|
|
|
_ledgerLines = 0;
|
2015-03-10 16:21:12 +01:00
|
|
|
|
|
|
|
for (Note* onote : c._notes) {
|
2014-07-10 18:59:44 +02:00
|
|
|
Note* nnote = new Note(*onote, link);
|
2014-06-27 13:41:49 +02:00
|
|
|
add(nnote);
|
|
|
|
}
|
2013-09-13 15:44:47 +02:00
|
|
|
for (Chord* gn : c.graceNotes()) {
|
2014-06-27 13:41:49 +02:00
|
|
|
Chord* nc = new Chord(*gn, link);
|
|
|
|
add(nc);
|
2013-09-13 15:44:47 +02:00
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
_stem = 0;
|
|
|
|
_hook = 0;
|
2014-12-13 17:40:39 +01:00
|
|
|
_endsGlissando = false;
|
2012-05-26 14:26:10 +02:00
|
|
|
_arpeggio = 0;
|
|
|
|
_stemSlash = 0;
|
2014-05-05 19:59:00 +02:00
|
|
|
_tremolo = 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-06-16 23:33:37 +02:00
|
|
|
_graceIndex = c._graceIndex;
|
2012-11-19 10:08:15 +01:00
|
|
|
_noStem = c._noStem;
|
2014-03-28 16:29:55 +01:00
|
|
|
_playEventType = c._playEventType;
|
2014-06-27 13:41:49 +02:00
|
|
|
_stemDirection = c._stemDirection;
|
|
|
|
_noteType = c._noteType;
|
|
|
|
_crossMeasure = CrossMeasure::UNKNOWN;
|
2012-11-19 10:08:15 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
if (c._stem)
|
|
|
|
add(new Stem(*(c._stem)));
|
|
|
|
if (c._hook)
|
|
|
|
add(new Hook(*(c._hook)));
|
2015-03-06 10:28:56 +01:00
|
|
|
if (c._stemSlash)
|
2012-05-26 14:26:10 +02:00
|
|
|
add(new StemSlash(*(c._stemSlash)));
|
2014-06-27 13:41:49 +02:00
|
|
|
if (c._arpeggio) {
|
|
|
|
Arpeggio* a = new Arpeggio(*(c._arpeggio));
|
|
|
|
add(a);
|
|
|
|
if (link)
|
2016-03-24 08:29:17 +01:00
|
|
|
score()->undo(new Link(const_cast<Arpeggio*>(c._arpeggio), a));
|
2014-06-27 13:41:49 +02:00
|
|
|
}
|
2014-07-21 11:43:50 +02:00
|
|
|
if (c._tremolo && !c._tremolo->twoNotes()) {
|
2014-06-27 13:41:49 +02:00
|
|
|
Tremolo* t = new Tremolo(*(c._tremolo));
|
2014-07-21 11:43:50 +02:00
|
|
|
add(t);
|
2014-06-27 13:41:49 +02:00
|
|
|
if (link)
|
2016-03-24 08:29:17 +01:00
|
|
|
score()->undo(new Link(const_cast<Tremolo*>(c._tremolo), t));
|
2014-06-27 13:41:49 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-06-27 13:41:49 +02:00
|
|
|
for (Element* e : c.el()) {
|
|
|
|
if (e->type() == Element::Type::CHORDLINE) {
|
|
|
|
ChordLine* cl = static_cast<ChordLine*>(e);
|
|
|
|
ChordLine* ncl = new ChordLine(*cl);
|
|
|
|
add(ncl);
|
|
|
|
if (link)
|
2016-03-24 08:29:17 +01:00
|
|
|
score()->undo(new Link(const_cast<ChordLine*>(ncl), cl));
|
2014-05-10 17:36:32 +02:00
|
|
|
}
|
2014-05-10 16:36:37 +02:00
|
|
|
}
|
2014-08-07 10:55:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// undoUnlink
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::undoUnlink()
|
|
|
|
{
|
|
|
|
ChordRest::undoUnlink();
|
|
|
|
for (Note* n : _notes)
|
|
|
|
n->undoUnlink();
|
|
|
|
for (Chord* gn : graceNotes())
|
|
|
|
gn->undoUnlink();
|
|
|
|
|
2014-12-13 17:40:39 +01:00
|
|
|
/* if (_glissando)
|
|
|
|
_glissando->undoUnlink(); */
|
2014-08-07 10:55:36 +02:00
|
|
|
if (_arpeggio)
|
|
|
|
_arpeggio->undoUnlink();
|
|
|
|
if (_tremolo && !_tremolo->twoNotes())
|
|
|
|
_tremolo->undoUnlink();
|
|
|
|
|
|
|
|
for (Element* e : el()) {
|
|
|
|
if (e->type() == Element::Type::CHORDLINE)
|
|
|
|
e->undoUnlink();
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// ~Chord
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Chord::~Chord()
|
|
|
|
{
|
|
|
|
delete _arpeggio;
|
2013-09-06 20:56:56 +02:00
|
|
|
if (_tremolo && _tremolo->chord1() == this) {
|
|
|
|
if (_tremolo->chord2())
|
|
|
|
_tremolo->chord2()->setTremolo(0);
|
2012-05-26 14:26:10 +02:00
|
|
|
delete _tremolo;
|
2013-09-06 20:56:56 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
delete _stemSlash;
|
|
|
|
delete _stem;
|
|
|
|
delete _hook;
|
2013-02-07 00:18:02 +01:00
|
|
|
for (LedgerLine* ll = _ledgerLines; ll;) {
|
|
|
|
LedgerLine* llNext = ll->next();
|
2013-01-03 16:56:56 +01:00
|
|
|
delete ll;
|
2013-02-07 00:18:02 +01:00
|
|
|
ll = llNext;
|
|
|
|
}
|
2015-03-10 16:21:12 +01:00
|
|
|
qDeleteAll(_graceNotes);
|
2012-12-06 12:46:05 +01:00
|
|
|
qDeleteAll(_notes);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2016-02-15 12:23:28 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// noteHeadWidth
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::noteHeadWidth() const
|
|
|
|
{
|
|
|
|
qreal nhw = score()->noteHeadWidth();
|
|
|
|
if (_noteType != NoteType::NORMAL)
|
|
|
|
nhw *= score()->styleD(StyleIdx::graceNoteMag);
|
|
|
|
return nhw * mag();
|
|
|
|
}
|
|
|
|
|
2013-05-23 12:58:06 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// stemPosX
|
2013-08-01 13:16:07 +02:00
|
|
|
// return Chord coordinates
|
2013-05-23 12:58:06 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::stemPosX() const
|
|
|
|
{
|
2013-08-01 13:16:07 +02:00
|
|
|
if (staff() && staff()->isTabStaff())
|
2014-04-28 18:38:50 +02:00
|
|
|
return staff()->staffType()->chordStemPosX(this) * spatium();
|
2016-02-15 12:23:28 +01:00
|
|
|
return _up ? noteHeadWidth() : 0.0;
|
2013-05-23 12:58:06 +02:00
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// stemPos
|
|
|
|
// return page coordinates
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Chord::stemPos() const
|
|
|
|
{
|
2013-05-23 12:32:40 +02:00
|
|
|
qreal _spatium = spatium();
|
2013-08-01 13:16:07 +02:00
|
|
|
QPointF p(pagePos());
|
|
|
|
|
2013-01-02 09:29:17 +01:00
|
|
|
if (staff() && staff()->isTabStaff())
|
2014-04-28 18:38:50 +02:00
|
|
|
return staff()->staffType()->chordStemPos(this) * _spatium + p;
|
2013-05-23 12:32:40 +02:00
|
|
|
|
|
|
|
if (_up) {
|
2016-02-15 12:23:28 +01:00
|
|
|
qreal nhw = noteHeadWidth();
|
2013-05-23 16:58:22 +02:00
|
|
|
p.rx() += nhw;
|
2013-05-23 12:58:06 +02:00
|
|
|
p.ry() += downNote()->pos().y();
|
2013-05-23 12:32:40 +02:00
|
|
|
}
|
|
|
|
else
|
2013-05-23 12:58:06 +02:00
|
|
|
p.ry() += upNote()->pos().y();
|
2013-05-23 12:32:40 +02:00
|
|
|
return p;
|
2013-01-02 14:33:23 +01:00
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// stemPosBeam
|
|
|
|
// return stem position of note on beam side
|
2016-02-15 12:23:28 +01:00
|
|
|
// return page coordinates
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Chord::stemPosBeam() const
|
|
|
|
{
|
2013-05-23 12:32:40 +02:00
|
|
|
qreal _spatium = spatium();
|
|
|
|
QPointF p(pagePos());
|
2016-02-15 12:23:28 +01:00
|
|
|
|
2016-02-16 21:21:28 +01:00
|
|
|
|
2014-12-18 11:54:55 +01:00
|
|
|
if (staff() && staff()->isTabStaff())
|
|
|
|
return staff()->staffType()->chordStemPosBeam(this) * _spatium + p;
|
2016-02-15 12:23:28 +01:00
|
|
|
|
2013-05-23 12:32:40 +02:00
|
|
|
if (_up) {
|
2016-02-15 12:23:28 +01:00
|
|
|
qreal nhw = noteHeadWidth();
|
2013-05-23 16:58:22 +02:00
|
|
|
p.rx() += nhw;
|
2013-05-23 12:58:06 +02:00
|
|
|
p.ry() += upNote()->pos().y();
|
2013-05-23 12:32:40 +02:00
|
|
|
}
|
|
|
|
else
|
2013-05-23 12:58:06 +02:00
|
|
|
p.ry() += downNote()->pos().y();
|
2016-02-16 21:21:28 +01:00
|
|
|
|
2013-05-23 12:32:40 +02:00
|
|
|
return p;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setSelected
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2014-11-22 13:05:23 +01:00
|
|
|
void Chord::setSelected(bool)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2014-11-22 13:05:23 +01:00
|
|
|
/* Element::setSelected(f);
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
|
|
|
for (int i = 0; i < n; ++i)
|
|
|
|
_notes.at(i)->setSelected(f);
|
2014-11-22 13:05:23 +01:00
|
|
|
*/
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// add
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::add(Element* e)
|
|
|
|
{
|
|
|
|
e->setParent(this);
|
|
|
|
e->setTrack(track());
|
|
|
|
switch(e->type()) {
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::NOTE:
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
Note* note = static_cast<Note*>(e);
|
|
|
|
bool found = false;
|
2014-03-22 16:46:17 +01:00
|
|
|
// _notes should be sorted by line position,
|
|
|
|
// but it's often not yet possible since line is unknown
|
|
|
|
// use pitch instead, and line as a second sort critera.
|
2016-02-06 22:03:43 +01:00
|
|
|
for (unsigned idx = 0; idx < _notes.size(); ++idx) {
|
2014-03-22 16:46:17 +01:00
|
|
|
if (note->pitch() <= _notes[idx]->pitch()) {
|
|
|
|
if (note->pitch() == _notes[idx]->pitch() && note->line() > _notes[idx]->line())
|
2016-02-06 22:03:43 +01:00
|
|
|
_notes.insert(_notes.begin()+idx+1, note);
|
2014-03-22 16:46:17 +01:00
|
|
|
else
|
2016-02-06 22:03:43 +01:00
|
|
|
_notes.insert(_notes.begin()+idx, note);
|
2012-05-26 14:26:10 +02:00
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found)
|
2016-02-06 22:03:43 +01:00
|
|
|
_notes.push_back(note);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (note->tieFor()) {
|
|
|
|
if (note->tieFor()->endNote())
|
|
|
|
note->tieFor()->endNote()->setTieBack(note->tieFor());
|
|
|
|
}
|
2015-01-26 22:58:46 +01:00
|
|
|
if (voice() && measure() && note->visible())
|
|
|
|
measure()->mstaff(staffIdx())->hasVoices = true;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::ARPEGGIO:
|
2012-05-26 14:26:10 +02:00
|
|
|
_arpeggio = static_cast<Arpeggio*>(e);
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::TREMOLO:
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
Tremolo* tr = static_cast<Tremolo*>(e);
|
|
|
|
if (tr->twoNotes()) {
|
|
|
|
if (!(_tremolo && _tremolo->twoNotes())) {
|
|
|
|
TDuration d = durationType();
|
|
|
|
int dots = d.dots();
|
|
|
|
d = d.shift(-1);
|
|
|
|
d.setDots(dots);
|
|
|
|
if (tr->chord1())
|
|
|
|
tr->chord1()->setDurationType(d);
|
|
|
|
if (tr->chord2())
|
|
|
|
tr->chord2()->setDurationType(d);
|
|
|
|
}
|
|
|
|
tr->chord2()->setTremolo(tr);
|
|
|
|
}
|
|
|
|
_tremolo = tr;
|
|
|
|
}
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::GLISSANDO:
|
2014-12-13 17:40:39 +01:00
|
|
|
_endsGlissando = true;
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::STEM:
|
2015-01-21 11:55:36 +01:00
|
|
|
Q_ASSERT(!_stem);
|
2016-04-27 16:33:30 +02:00
|
|
|
_stem = toStem(e);
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::HOOK:
|
2016-04-27 16:33:30 +02:00
|
|
|
_hook = toHook(e);
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::CHORDLINE:
|
2013-07-05 13:52:14 +02:00
|
|
|
_el.push_back(e);
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::STEM_SLASH:
|
2015-01-21 11:55:36 +01:00
|
|
|
Q_ASSERT(!_stemSlash);
|
2016-04-27 16:33:30 +02:00
|
|
|
_stemSlash = toStemSlash(e);
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::CHORD:
|
2013-06-16 23:33:37 +02:00
|
|
|
{
|
|
|
|
Chord* gc = static_cast<Chord*>(e);
|
2015-03-10 16:21:12 +01:00
|
|
|
Q_ASSERT(gc->noteType() != NoteType::NORMAL);
|
2013-06-16 23:33:37 +02:00
|
|
|
int idx = gc->graceIndex();
|
2014-05-22 10:10:58 +02:00
|
|
|
gc->setFlags(ElementFlag::MOVABLE);
|
2013-06-16 23:33:37 +02:00
|
|
|
_graceNotes.insert(_graceNotes.begin() + idx, gc);
|
|
|
|
}
|
2013-06-12 14:23:57 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::LEDGER_LINE:
|
2014-06-05 20:58:05 +02:00
|
|
|
qFatal("Chord::add ledgerline");
|
2014-04-22 17:02:03 +02:00
|
|
|
break;
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
default:
|
|
|
|
ChordRest::add(e);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// remove
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::remove(Element* e)
|
|
|
|
{
|
2016-02-06 22:03:43 +01:00
|
|
|
if (!e)
|
2016-02-01 09:29:09 +01:00
|
|
|
return;
|
2016-02-06 22:03:43 +01:00
|
|
|
|
|
|
|
switch (e->type()) {
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::NOTE:
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2016-02-17 14:54:23 +01:00
|
|
|
Note* note = toNote(e);
|
2016-02-06 22:03:43 +01:00
|
|
|
auto i = std::find(_notes.begin(), _notes.end(), note);
|
|
|
|
if (i != _notes.end()) {
|
|
|
|
_notes.erase(i);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (note->tieFor()) {
|
2015-02-17 20:22:24 +01:00
|
|
|
if (note->tieFor()->endNote())
|
2012-05-26 14:26:10 +02:00
|
|
|
note->tieFor()->endNote()->setTieBack(0);
|
|
|
|
}
|
2016-03-02 13:20:19 +01:00
|
|
|
for (Spanner* s : note->spannerBack())
|
2015-06-29 16:20:47 +02:00
|
|
|
note->removeSpannerBack(s);
|
2016-03-02 13:20:19 +01:00
|
|
|
for (Spanner* s : note->spannerFor())
|
2015-06-29 16:20:47 +02:00
|
|
|
note->removeSpannerFor(s);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
else
|
2014-03-25 13:33:47 +01:00
|
|
|
qDebug("Chord::remove() note %p not found!", e);
|
2015-01-26 22:58:46 +01:00
|
|
|
if (voice() && measure() && note->visible())
|
|
|
|
measure()->checkMultiVoices(staffIdx());
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::ARPEGGIO:
|
2012-05-26 14:26:10 +02:00
|
|
|
_arpeggio = 0;
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::TREMOLO:
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
Tremolo* tremolo = static_cast<Tremolo*>(e);
|
|
|
|
if (tremolo->twoNotes()) {
|
|
|
|
TDuration d = durationType();
|
|
|
|
int dots = d.dots();
|
|
|
|
d = d.shift(1);
|
|
|
|
d.setDots(dots);
|
2013-09-06 09:36:31 +02:00
|
|
|
Fraction f = duration();
|
|
|
|
if (f.numerator() > 0)
|
|
|
|
d = TDuration(f);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (tremolo->chord1())
|
|
|
|
tremolo->chord1()->setDurationType(d);
|
2014-07-08 20:22:07 +02:00
|
|
|
if (tremolo->chord2()) {
|
2012-05-26 14:26:10 +02:00
|
|
|
tremolo->chord2()->setDurationType(d);
|
2014-07-08 20:22:07 +02:00
|
|
|
tremolo->chord2()->setTremolo(0);
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
_tremolo = 0;
|
|
|
|
}
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::GLISSANDO:
|
2015-02-04 18:54:03 +01:00
|
|
|
_endsGlissando = false;
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::STEM:
|
2012-05-26 14:26:10 +02:00
|
|
|
_stem = 0;
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::HOOK:
|
2012-05-26 14:26:10 +02:00
|
|
|
_hook = 0;
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::STEM_SLASH:
|
2015-01-21 11:55:36 +01:00
|
|
|
Q_ASSERT(_stemSlash);
|
|
|
|
if (_stemSlash->selected() && score())
|
|
|
|
score()->deselect(_stemSlash);
|
2013-08-31 19:28:48 +02:00
|
|
|
_stemSlash = 0;
|
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::CHORDLINE:
|
2013-03-25 16:27:20 +01:00
|
|
|
_el.remove(e);
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::CHORD:
|
2013-06-16 23:33:37 +02:00
|
|
|
{
|
|
|
|
auto i = std::find(_graceNotes.begin(), _graceNotes.end(), static_cast<Chord*>(e));
|
|
|
|
Chord* grace = *i;
|
|
|
|
grace->setGraceIndex(i - _graceNotes.begin());
|
|
|
|
_graceNotes.erase(i);
|
|
|
|
}
|
2013-06-12 14:23:57 +02:00
|
|
|
break;
|
2012-05-26 14:26:10 +02:00
|
|
|
default:
|
|
|
|
ChordRest::remove(e);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-14 01:43:08 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// maxHeadWidth
|
|
|
|
//---------------------------------------------------------
|
2014-07-05 12:05:27 +02:00
|
|
|
|
2013-09-02 19:07:39 +02:00
|
|
|
qreal Chord::maxHeadWidth() const
|
2013-05-14 01:43:08 +02:00
|
|
|
{
|
|
|
|
// determine max head width in chord
|
|
|
|
qreal hw = 0;
|
2016-02-06 22:03:43 +01:00
|
|
|
for (unsigned i = 0; i < _notes.size(); i++) {
|
2013-05-14 01:43:08 +02:00
|
|
|
qreal t = _notes.at(i)->headWidth();
|
|
|
|
if (t > hw)
|
|
|
|
hw = t;
|
|
|
|
}
|
|
|
|
return hw;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// addLedgerLines
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-05-07 05:14:00 +02:00
|
|
|
void Chord::addLedgerLines()
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2016-05-07 05:14:00 +02:00
|
|
|
// initialize for palette
|
2016-08-07 11:04:14 +02:00
|
|
|
int track = 0; // the track lines belong to
|
2013-08-15 01:25:08 +02:00
|
|
|
// the line pos corresponding to the bottom line of the staff
|
2016-08-07 11:04:14 +02:00
|
|
|
int lineBelow = 8; // assuming 5-lined "staff"
|
2016-05-13 04:22:42 +02:00
|
|
|
qreal lineDistance = 1;
|
2016-08-07 11:04:14 +02:00
|
|
|
qreal _mag = 1;
|
|
|
|
bool staffVisible = true;
|
2016-05-07 05:14:00 +02:00
|
|
|
|
|
|
|
if (segment()) { //not palette
|
2016-08-07 11:04:14 +02:00
|
|
|
int idx = staffIdx() + staffMove();
|
|
|
|
track = staff2track(idx);
|
|
|
|
Staff* st = score()->staff(idx);
|
2016-05-07 05:14:00 +02:00
|
|
|
lineBelow = (st->lines() - 1) * 2;
|
|
|
|
lineDistance = st->lineDistance();
|
|
|
|
_mag = staff()->mag();
|
|
|
|
staffVisible = !staff()->invisible();
|
|
|
|
}
|
|
|
|
|
2016-05-13 04:22:42 +02:00
|
|
|
// need ledger lines?
|
|
|
|
if (downLine() <= lineBelow + 1 && upLine() >= -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
LedgerLineData lld;
|
2016-05-07 05:14:00 +02:00
|
|
|
// the extra length of a ledger line with respect to notehead (half of it on each side)
|
|
|
|
qreal extraLen = score()->styleP(StyleIdx::ledgerLineLength) * _mag * 0.5;
|
|
|
|
qreal hw = _notes[0]->headWidth();
|
2013-08-15 01:25:08 +02:00
|
|
|
qreal minX, maxX; // note extrema in raster units
|
|
|
|
int minLine, maxLine;
|
2013-08-03 01:45:46 +02:00
|
|
|
bool visible = false;
|
|
|
|
qreal x;
|
|
|
|
|
|
|
|
// scan chord notes, collecting visibility and x and y extrema
|
2013-08-15 01:25:08 +02:00
|
|
|
// NOTE: notes are sorted from bottom to top (line no. decreasing)
|
|
|
|
// notes are scanned twice from outside (bottom or top) toward the staff
|
|
|
|
// each pass stops at the first note without ledger lines
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
2013-08-15 01:25:08 +02:00
|
|
|
for (int j = 0; j < 2; j++) { // notes are scanned twice...
|
|
|
|
int from, delta;
|
|
|
|
vector<LedgerLineData> vecLines;
|
|
|
|
minX = maxX = 0;
|
|
|
|
minLine = 0;
|
|
|
|
maxLine = lineBelow;
|
|
|
|
if (j == 0) { // ...once from lowest up...
|
|
|
|
from = 0;
|
|
|
|
delta = +1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
from = n-1; // ...once from highest down
|
|
|
|
delta = -1;
|
|
|
|
}
|
|
|
|
for (int i = from; i < n && i >=0 ; i += delta) {
|
2016-09-03 17:45:59 +02:00
|
|
|
Note* note = _notes.at(i);
|
2015-09-01 06:19:20 +02:00
|
|
|
int l = note->physicalLine();
|
2016-05-13 04:22:42 +02:00
|
|
|
|
|
|
|
// if 1st pass and note not below staff or 2nd pass and note not above staff
|
|
|
|
if ((!j && l <= lineBelow + 1) || (j && l >= -1))
|
2013-08-15 01:25:08 +02:00
|
|
|
break; // stop this pass
|
|
|
|
// round line number to even number toward 0
|
2016-05-13 04:22:42 +02:00
|
|
|
if (l < 0)
|
|
|
|
l = (l + 1) & ~ 1;
|
|
|
|
else
|
|
|
|
l = l & ~ 1;
|
2013-08-15 01:25:08 +02:00
|
|
|
|
|
|
|
if (note->visible()) // if one note is visible,
|
|
|
|
visible = true; // all lines between it and the staff are visible
|
|
|
|
|
|
|
|
//
|
|
|
|
// Experimental:
|
|
|
|
// shorten ledger line to avoid collisions with accidentals
|
|
|
|
//
|
2013-09-05 16:37:49 +02:00
|
|
|
// bool accid = (note->accidental() && note->line() >= (l-1) && note->line() <= (l+1) );
|
2013-08-15 01:25:08 +02:00
|
|
|
//
|
|
|
|
// TODO : do something with this accid flag in the following code!
|
|
|
|
//
|
|
|
|
|
|
|
|
// check if note horiz. pos. is outside current range
|
|
|
|
// if more length on the right, increase range
|
2016-09-03 17:45:59 +02:00
|
|
|
// note->layout();
|
2013-08-15 01:25:08 +02:00
|
|
|
x = note->pos().x();
|
2016-09-03 17:45:59 +02:00
|
|
|
if (x - extraLen < minX) {
|
2013-08-15 01:25:08 +02:00
|
|
|
minX = x - extraLen;
|
|
|
|
// increase width of all lines between this one and the staff
|
2016-09-03 17:45:59 +02:00
|
|
|
for (auto& d : vecLines) {
|
2013-08-15 01:25:08 +02:00
|
|
|
if (!d.accidental && ((l < 0 && d.line >= l) || (l > 0 && d.line <= l)) )
|
|
|
|
d.minX = minX ;
|
2016-09-03 17:45:59 +02:00
|
|
|
}
|
2013-08-15 01:25:08 +02:00
|
|
|
}
|
|
|
|
// same for left side
|
2016-09-03 17:45:59 +02:00
|
|
|
if (x + hw + extraLen > maxX) {
|
2013-08-15 01:25:08 +02:00
|
|
|
maxX = x + hw + extraLen;
|
|
|
|
for (auto& d : vecLines)
|
|
|
|
if ( (l < 0 && d.line >= l) || (l > 0 && d.line <= l) )
|
|
|
|
d.maxX = maxX;
|
|
|
|
}
|
2013-08-03 01:45:46 +02:00
|
|
|
|
2013-08-15 01:25:08 +02:00
|
|
|
// check if note vert. pos. is outside current range
|
2015-09-01 06:19:20 +02:00
|
|
|
// and, if so, add data for new line(s)
|
2013-08-15 01:25:08 +02:00
|
|
|
if (l < minLine) {
|
|
|
|
for (int i = l; i < minLine; i += 2) {
|
|
|
|
lld.line = i;
|
2015-09-01 06:19:20 +02:00
|
|
|
if (lineDistance != 1.0)
|
|
|
|
lld.line *= lineDistance;
|
2013-08-15 01:25:08 +02:00
|
|
|
lld.minX = minX;
|
|
|
|
lld.maxX = maxX;
|
|
|
|
lld.visible = visible;
|
|
|
|
lld.accidental = false;
|
|
|
|
vecLines.push_back(lld);
|
|
|
|
}
|
|
|
|
minLine = l;
|
|
|
|
}
|
|
|
|
if (l > maxLine) {
|
|
|
|
for (int i = maxLine+2; i <= l; i += 2) {
|
|
|
|
lld.line = i;
|
2015-09-01 06:19:20 +02:00
|
|
|
if (lineDistance != 1.0)
|
|
|
|
lld.line *= lineDistance;
|
2013-08-15 01:25:08 +02:00
|
|
|
lld.minX = minX;
|
|
|
|
lld.maxX = maxX;
|
|
|
|
lld.visible = visible;
|
|
|
|
lld.accidental = false;
|
|
|
|
vecLines.push_back(lld);
|
|
|
|
}
|
|
|
|
maxLine = l;
|
|
|
|
}
|
|
|
|
}
|
2016-08-07 11:04:14 +02:00
|
|
|
if (minLine < 0 || maxLine > lineBelow) {
|
|
|
|
qreal _spatium = spatium();
|
|
|
|
qreal stepDistance = 0.5; // staff() ? staff()->lineDistance() * 0.5 : 0.5;
|
|
|
|
for (auto lld : vecLines) {
|
|
|
|
LedgerLine* h = new LedgerLine(score());
|
|
|
|
h->setParent(this);
|
|
|
|
h->setTrack(track);
|
|
|
|
h->setVisible(lld.visible && staffVisible);
|
2016-09-03 17:45:59 +02:00
|
|
|
h->setLen(lld.maxX - lld.minX);
|
2016-08-07 11:04:14 +02:00
|
|
|
h->setPos(lld.minX, lld.line * _spatium * stepDistance);
|
|
|
|
h->setNext(_ledgerLines);
|
|
|
|
_ledgerLines = h;
|
|
|
|
}
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2016-08-07 11:04:14 +02:00
|
|
|
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
|
|
|
|
ll->layout();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// computeUp
|
|
|
|
// rules:
|
|
|
|
// single note:
|
|
|
|
// All notes beneath the middle line: upward stems
|
|
|
|
// All notes on or above the middle line: downward stems
|
|
|
|
// two notes:
|
|
|
|
// If the interval above the middle line is greater than the interval
|
|
|
|
// below the middle line: downward stems
|
|
|
|
// If the interval below the middle line is greater than the interval
|
|
|
|
// above the middle line: upward stems
|
|
|
|
// If the two notes are the same distance from the middle line:
|
|
|
|
// stem can go in either direction. but most engravers prefer
|
|
|
|
// downward stems
|
|
|
|
// > two notes:
|
|
|
|
// If the interval of the highest note above the middle line is greater
|
|
|
|
// than the interval of the lowest note below the middle line:
|
|
|
|
// downward stems
|
|
|
|
// If the interval of the lowest note below the middle line is greater
|
|
|
|
// than the interval of the highest note above the middle line:
|
|
|
|
// upward stem
|
|
|
|
// If the highest and the lowest notes are the same distance from
|
|
|
|
// the middle line:, use these rules to determine stem direction:
|
|
|
|
// - If the majority of the notes are above the middle:
|
|
|
|
// downward stems
|
|
|
|
// - If the majority of the notes are below the middle:
|
|
|
|
// upward stems
|
2013-03-09 09:58:43 +01:00
|
|
|
// TABlatures:
|
|
|
|
// stems beside staves:
|
|
|
|
// All stems are up / down according to TAB::stemsDown() setting
|
|
|
|
// stems through staves:
|
|
|
|
// Same rules as per pitched staves
|
2012-05-26 14:26:10 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::computeUp()
|
|
|
|
{
|
2016-06-06 10:33:09 +02:00
|
|
|
Q_ASSERT(!_notes.empty());
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = 0;
|
2013-03-09 09:58:43 +01:00
|
|
|
// TAB STAVES
|
2012-08-16 11:09:36 +02:00
|
|
|
if (staff() && staff()->isTabStaff()) {
|
2014-04-28 18:38:50 +02:00
|
|
|
tab = staff()->staffType();
|
2013-03-09 09:58:43 +01:00
|
|
|
// if no stems or stem beside staves
|
|
|
|
if (tab->slashStyle() || !tab->stemThrough()) {
|
|
|
|
// if measure has voices, set stem direction according to voice
|
2013-08-09 11:42:24 +02:00
|
|
|
if (measure()->mstaff(staffIdx())->hasVoices)
|
Fix #69846, #69821, #63561 - multi-voice TAB's: stem and slur positions
__Background__:
In the original TAB implementation, the "Stems above / below" setting was followed when there was only one voice, while with multiple voices, voice 1 stems were always above and voice 2 stems always below.
In issue https://musescore.org/en/node/63561 the OP reported that:
- with multiple voices, stems in TAB did not follow the "Stems above / below" setting;
- extra space was allocated for voice 2 stems.
Both issues were more apparent than real, because the example provided casually had no stems in voice 2 (all whole notes). With the commit https://github.com/musescore/MuseScore/commit/33797cd6c55490cd67a3267e5e7e09f409e61dbf :
- voice 1 stems are forced to be below or down according to the setting even for multi-voice cases and voice 2 stems on the opposite side;
- additional distance is allocated above the TAB staff (but not below) if stems are above or there are multiple voices or below (but not above) if stems are below and there is only voice 1.
__Issues__:
1a) The original stem directions were __by design__, assuming that with multiple voices notes of voice 1 tend to be above and notes of voice 2 tend to be below; then it is more sensible to put voice 1 stems above and voice 2 stems below, limiting the "Stems above / below" setting to the single voice case only.
1b) Stem direction controls slurs and tie placement and users are complaining that, with multiple voices, stems, slurs and ties are placed unexpectedly. See issue https://musescore.org/en/node/69846 and forum post https://musescore.org/en/node/69821 .
2) About additional staff distance allocation, with multiple voices it has to be allocated __both__ above and below, as stems may appear both above and below.
__Fix__:
1) This patch fixes 1) by restoring the original stem direction computation (single voice: follow "Stems above / below" setting | multiple voices: voice 1 unconditionally above and voice 2 below) when tab is configured to have stems beside the staff and also when it is configured to have __no stems at all_ (so that slurs and ties occur in expected positions).
2) It corrects additional staff distance allocation for the multiple voice case. No resources are spent to check the odd case when one voice casually has no stems over the entire system (in which case, additional distance on that side could in theory be spared).
2015-07-26 20:55:02 +02:00
|
|
|
_up = !(track() % 2);
|
2013-03-09 09:58:43 +01:00
|
|
|
else // if only voice 1,
|
Fix #69846, #69821, #63561 - multi-voice TAB's: stem and slur positions
__Background__:
In the original TAB implementation, the "Stems above / below" setting was followed when there was only one voice, while with multiple voices, voice 1 stems were always above and voice 2 stems always below.
In issue https://musescore.org/en/node/63561 the OP reported that:
- with multiple voices, stems in TAB did not follow the "Stems above / below" setting;
- extra space was allocated for voice 2 stems.
Both issues were more apparent than real, because the example provided casually had no stems in voice 2 (all whole notes). With the commit https://github.com/musescore/MuseScore/commit/33797cd6c55490cd67a3267e5e7e09f409e61dbf :
- voice 1 stems are forced to be below or down according to the setting even for multi-voice cases and voice 2 stems on the opposite side;
- additional distance is allocated above the TAB staff (but not below) if stems are above or there are multiple voices or below (but not above) if stems are below and there is only voice 1.
__Issues__:
1a) The original stem directions were __by design__, assuming that with multiple voices notes of voice 1 tend to be above and notes of voice 2 tend to be below; then it is more sensible to put voice 1 stems above and voice 2 stems below, limiting the "Stems above / below" setting to the single voice case only.
1b) Stem direction controls slurs and tie placement and users are complaining that, with multiple voices, stems, slurs and ties are placed unexpectedly. See issue https://musescore.org/en/node/69846 and forum post https://musescore.org/en/node/69821 .
2) About additional staff distance allocation, with multiple voices it has to be allocated __both__ above and below, as stems may appear both above and below.
__Fix__:
1) This patch fixes 1) by restoring the original stem direction computation (single voice: follow "Stems above / below" setting | multiple voices: voice 1 unconditionally above and voice 2 below) when tab is configured to have stems beside the staff and also when it is configured to have __no stems at all_ (so that slurs and ties occur in expected positions).
2) It corrects additional staff distance allocation for the multiple voice case. No resources are spent to check the odd case when one voice casually has no stems over the entire system (in which case, additional distance on that side could in theory be spared).
2015-07-26 20:55:02 +02:00
|
|
|
// uncondtionally set to down if not stems or according to TAB stem direction otherwise
|
|
|
|
// (even with no stems, stem direction controls position of slurs and ties)
|
|
|
|
_up = tab->slashStyle() ? false : !tab->stemsDown();
|
|
|
|
return;
|
2013-03-09 09:58:43 +01:00
|
|
|
}
|
|
|
|
// if TAB has stems through staves, chain into standard processing
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-03-09 09:58:43 +01:00
|
|
|
|
|
|
|
// PITCHED STAVES (or TAB with stems through staves)
|
2016-07-10 12:00:57 +02:00
|
|
|
if (_stemDirection != Direction_AUTO) {
|
|
|
|
_up = _stemDirection == Direction_UP;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
else if (!parent())
|
2014-09-09 05:12:38 +02:00
|
|
|
// hack for palette and drumset editor
|
2016-01-04 14:48:58 +01:00
|
|
|
_up = upNote()->line() > 4;
|
2014-05-27 10:35:28 +02:00
|
|
|
else if (_noteType != NoteType::NORMAL) {
|
2012-06-25 13:59:45 +02:00
|
|
|
//
|
|
|
|
// stem direction for grace notes
|
|
|
|
//
|
2013-08-09 11:42:24 +02:00
|
|
|
if (measure()->mstaff(staffIdx())->hasVoices)
|
|
|
|
_up = !(track() % 2);
|
2012-05-26 14:26:10 +02:00
|
|
|
else
|
|
|
|
_up = true;
|
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
else if (staffMove())
|
2013-01-29 15:21:01 +01:00
|
|
|
_up = staffMove() > 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
else if (measure()->mstaff(staffIdx())->hasVoices) {
|
2013-08-09 11:42:24 +02:00
|
|
|
_up = !(track() % 2);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
else {
|
2015-09-01 06:19:20 +02:00
|
|
|
int dnMaxLine = staff()->middleLine();
|
2013-03-09 09:58:43 +01:00
|
|
|
int ud = (tab ? upString()*2 : upNote()->line() ) - dnMaxLine;
|
|
|
|
// standard case: if only 1 note or cross beaming
|
|
|
|
if (_notes.size() == 1 || staffMove()) {
|
|
|
|
if (staffMove() > 0)
|
|
|
|
_up = true;
|
|
|
|
else if (staffMove() < 0)
|
|
|
|
_up = false;
|
|
|
|
else
|
|
|
|
_up = ud > 0;
|
|
|
|
}
|
|
|
|
// if more than 1 note, compare extrema (topmost and bottommost notes)
|
|
|
|
else {
|
|
|
|
int dd = (tab ? downString()*2 : downNote()->line() ) - dnMaxLine;
|
|
|
|
// if extrema symmetrical, average directions of intermediate notes
|
|
|
|
if (-ud == dd) {
|
|
|
|
int up = 0;
|
|
|
|
int n = _notes.size();
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
const Note* n = _notes.at(i);
|
|
|
|
int l = tab ? n->string()*2 : n->line();
|
|
|
|
if (l <= dnMaxLine)
|
|
|
|
--up;
|
|
|
|
else
|
|
|
|
++up;
|
|
|
|
}
|
|
|
|
_up = up > 0;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-03-09 09:58:43 +01:00
|
|
|
// if extrema not symmetrical, set _up to prevailing
|
|
|
|
else
|
|
|
|
_up = dd > -ud;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// selectedNote
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Note* Chord::selectedNote() const
|
|
|
|
{
|
|
|
|
Note* note = 0;
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
2013-01-28 20:57:07 +01:00
|
|
|
for (int i = 0; i < n; ++i) {
|
2012-12-06 12:46:05 +01:00
|
|
|
Note* n = _notes.at(i);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (n->selected()) {
|
|
|
|
if (note)
|
|
|
|
return 0;
|
|
|
|
note = n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return note;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Chord::write
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::write(Xml& xml) const
|
|
|
|
{
|
2013-06-19 16:25:29 +02:00
|
|
|
for (Chord* c : _graceNotes) {
|
|
|
|
c->writeBeam(xml);
|
2013-06-12 14:23:57 +02:00
|
|
|
c->write(xml);
|
2013-06-19 16:25:29 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
xml.stag("Chord");
|
|
|
|
ChordRest::writeProperties(xml);
|
2013-06-19 16:25:29 +02:00
|
|
|
switch (_noteType) {
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::NORMAL:
|
2013-06-19 16:25:29 +02:00
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::ACCIACCATURA:
|
2013-06-19 16:25:29 +02:00
|
|
|
xml.tagE("acciaccatura");
|
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::APPOGGIATURA:
|
2013-06-19 16:25:29 +02:00
|
|
|
xml.tagE("appoggiatura");
|
|
|
|
break;
|
2014-05-30 13:35:44 +02:00
|
|
|
case NoteType::GRACE4:
|
2013-06-19 16:25:29 +02:00
|
|
|
xml.tagE("grace4");
|
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::GRACE16:
|
2013-06-19 16:25:29 +02:00
|
|
|
xml.tagE("grace16");
|
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::GRACE32:
|
2013-06-19 16:25:29 +02:00
|
|
|
xml.tagE("grace32");
|
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::GRACE8_AFTER:
|
2014-04-23 18:07:38 +02:00
|
|
|
xml.tagE("grace8after");
|
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::GRACE16_AFTER:
|
2014-04-23 18:07:38 +02:00
|
|
|
xml.tagE("grace16after");
|
|
|
|
break;
|
2014-05-27 10:35:28 +02:00
|
|
|
case NoteType::GRACE32_AFTER:
|
2014-04-23 18:07:38 +02:00
|
|
|
xml.tagE("grace32after");
|
|
|
|
break;
|
2016-09-22 16:07:47 +02:00
|
|
|
default:
|
|
|
|
break;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-06-19 16:25:29 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_noStem)
|
|
|
|
xml.tag("noStem", _noStem);
|
2015-03-06 10:44:47 +01:00
|
|
|
else if (_stem && (_stem->isUserModified() || (_stem->userLen() != 0.0)))
|
2012-05-26 14:26:10 +02:00
|
|
|
_stem->write(xml);
|
2015-03-06 10:44:47 +01:00
|
|
|
if (_hook && _hook->isUserModified())
|
2012-05-26 14:26:10 +02:00
|
|
|
_hook->write(xml);
|
2015-03-06 10:44:47 +01:00
|
|
|
if (_stemSlash && _stemSlash->isUserModified())
|
|
|
|
_stemSlash->write(xml);
|
2016-07-10 12:00:57 +02:00
|
|
|
writeProperty(xml, P_ID::STEM_DIRECTION);
|
2013-06-19 16:25:29 +02:00
|
|
|
for (Note* n : _notes)
|
|
|
|
n->write(xml);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_arpeggio)
|
|
|
|
_arpeggio->write(xml);
|
2014-05-15 13:42:03 +02:00
|
|
|
if (_tremolo && tremoloChordType() != TremoloChordType::TremoloSecondNote)
|
2012-05-26 14:26:10 +02:00
|
|
|
_tremolo->write(xml);
|
2014-07-09 18:05:58 +02:00
|
|
|
for (Element* e : _el)
|
|
|
|
e->write(xml);
|
2012-05-26 14:26:10 +02:00
|
|
|
xml.etag();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// Chord::read
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-01-11 18:10:18 +01:00
|
|
|
void Chord::read(XmlReader& e)
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
2013-01-11 18:10:18 +01:00
|
|
|
while (e.readNextStartElement()) {
|
2016-09-22 12:02:27 +02:00
|
|
|
if (readProperties(e))
|
2013-05-29 10:31:26 +02:00
|
|
|
;
|
|
|
|
else
|
2013-01-11 18:10:18 +01:00
|
|
|
e.unknown();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 12:02:27 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// readProperties
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool Chord::readProperties(XmlReader& e)
|
|
|
|
{
|
|
|
|
const QStringRef& tag(e.name());
|
|
|
|
|
|
|
|
if (tag == "Note") {
|
|
|
|
Note* note = new Note(score());
|
|
|
|
// the note needs to know the properties of the track it belongs to
|
|
|
|
note->setTrack(track());
|
|
|
|
note->setChord(this);
|
|
|
|
note->read(e);
|
|
|
|
add(note);
|
|
|
|
}
|
|
|
|
else if (ChordRest::readProperties(e))
|
|
|
|
;
|
|
|
|
else if (tag == "Stem") {
|
|
|
|
Stem* s = new Stem(score());
|
|
|
|
s->read(e);
|
|
|
|
add(s);
|
|
|
|
}
|
|
|
|
else if (tag == "Hook") {
|
|
|
|
_hook = new Hook(score());
|
|
|
|
_hook->read(e);
|
|
|
|
add(_hook);
|
|
|
|
}
|
|
|
|
else if (tag == "appoggiatura") {
|
|
|
|
_noteType = NoteType::APPOGGIATURA;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "acciaccatura") {
|
|
|
|
_noteType = NoteType::ACCIACCATURA;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "grace4") {
|
|
|
|
_noteType = NoteType::GRACE4;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "grace16") {
|
|
|
|
_noteType = NoteType::GRACE16;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "grace32") {
|
|
|
|
_noteType = NoteType::GRACE32;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "grace8after") {
|
|
|
|
_noteType = NoteType::GRACE8_AFTER;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "grace16after") {
|
|
|
|
_noteType = NoteType::GRACE16_AFTER;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "grace32after") {
|
|
|
|
_noteType = NoteType::GRACE32_AFTER;
|
|
|
|
e.readNext();
|
|
|
|
}
|
|
|
|
else if (tag == "StemSlash") {
|
|
|
|
StemSlash* ss = new StemSlash(score());
|
|
|
|
ss->read(e);
|
|
|
|
add(ss);
|
|
|
|
}
|
|
|
|
else if (tag == "StemDirection")
|
|
|
|
readProperty(e, P_ID::STEM_DIRECTION);
|
|
|
|
else if (tag == "noStem")
|
|
|
|
_noStem = e.readInt();
|
|
|
|
else if (tag == "Arpeggio") {
|
|
|
|
_arpeggio = new Arpeggio(score());
|
|
|
|
_arpeggio->setTrack(track());
|
|
|
|
_arpeggio->read(e);
|
|
|
|
_arpeggio->setParent(this);
|
|
|
|
}
|
|
|
|
// old glissando format, chord-to-chord, attached to its final chord
|
|
|
|
else if (tag == "Glissando") {
|
|
|
|
// the measure we are reading is not inserted in the score yet
|
|
|
|
// as well as, possibly, the glissando intended initial chord;
|
|
|
|
// then we cannot fully link the glissando right now;
|
|
|
|
// temporarily attach the glissando to its final note as a back spanner;
|
|
|
|
// after the whole score is read, Score::connectTies() will look for
|
|
|
|
// the suitable initial note
|
|
|
|
Note* finalNote = upNote();
|
|
|
|
Glissando* gliss = new Glissando(score());
|
|
|
|
gliss->read(e);
|
|
|
|
gliss->setAnchor(Spanner::Anchor::NOTE);
|
|
|
|
gliss->setStartElement(nullptr);
|
|
|
|
gliss->setEndElement(nullptr);
|
|
|
|
// in TAB, use straight line with no text
|
|
|
|
if (score()->staff(e.track() >> 2)->isTabStaff()) {
|
|
|
|
gliss->setGlissandoType(Glissando::Type::STRAIGHT);
|
|
|
|
gliss->setShowText(false);
|
|
|
|
}
|
|
|
|
finalNote->addSpannerBack(gliss);
|
|
|
|
}
|
|
|
|
else if (tag == "Tremolo") {
|
|
|
|
_tremolo = new Tremolo(score());
|
|
|
|
_tremolo->setTrack(track());
|
|
|
|
_tremolo->read(e);
|
|
|
|
_tremolo->setParent(this);
|
|
|
|
}
|
|
|
|
else if (tag == "tickOffset") // obsolete
|
|
|
|
;
|
|
|
|
else if (tag == "ChordLine") {
|
|
|
|
ChordLine* cl = new ChordLine(score());
|
|
|
|
cl->read(e);
|
|
|
|
add(cl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// upPos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::upPos() const
|
|
|
|
{
|
|
|
|
return upNote()->pos().y();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// downPos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::downPos() const
|
|
|
|
{
|
|
|
|
return downNote()->pos().y();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// centerX
|
|
|
|
// return x position for attributes
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::centerX() const
|
|
|
|
{
|
2013-03-09 09:58:43 +01:00
|
|
|
// TAB 'notes' are always centered on the stem
|
|
|
|
if (staff()->isTabStaff())
|
2014-04-28 18:38:50 +02:00
|
|
|
return staff()->staffType()->chordStemPosX(this) * spatium();
|
2013-03-09 09:58:43 +01:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
const Note* note = up() ? upNote() : downNote();
|
|
|
|
qreal x = note->pos().x();
|
|
|
|
x += note->headWidth() * .5;
|
|
|
|
if (note->mirror()) {
|
|
|
|
x += note->headWidth() * (up() ? -1.0 : 1.0);
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// scanElements
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::scanElements(void* data, void (*func)(void*, Element*), bool all)
|
|
|
|
{
|
2015-01-21 11:55:36 +01:00
|
|
|
if (_hook)
|
2013-06-22 10:55:22 +02:00
|
|
|
func(data, _hook );
|
2015-01-21 11:55:36 +01:00
|
|
|
if (_stem)
|
2012-05-26 14:26:10 +02:00
|
|
|
func(data, _stem);
|
|
|
|
if (_stemSlash)
|
|
|
|
func(data, _stemSlash);
|
|
|
|
if (_arpeggio)
|
|
|
|
func(data, _arpeggio);
|
2014-05-15 13:42:03 +02:00
|
|
|
if (_tremolo && (tremoloChordType() != TremoloChordType::TremoloSecondNote))
|
2012-05-26 14:26:10 +02:00
|
|
|
func(data, _tremolo);
|
2016-05-07 05:14:00 +02:00
|
|
|
Staff* st = staff();
|
|
|
|
if ((st && st->showLedgerLines()) || !st) // also for palette
|
2013-06-22 10:55:22 +02:00
|
|
|
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
|
|
|
|
func(data, ll);
|
2013-01-03 16:56:56 +01:00
|
|
|
int n = _notes.size();
|
2012-12-06 12:46:05 +01:00
|
|
|
for (int i = 0; i < n; ++i)
|
|
|
|
_notes.at(i)->scanElements(data, func, all);
|
|
|
|
n = _el.size();
|
2013-06-10 21:13:04 +02:00
|
|
|
for (Chord* chord : _graceNotes)
|
|
|
|
chord->scanElements(data, func, all);
|
2013-03-25 16:27:20 +01:00
|
|
|
for (Element* e : _el)
|
|
|
|
e->scanElements(data, func, all);
|
2012-05-26 14:26:10 +02:00
|
|
|
ChordRest::scanElements(data, func, all);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2013-03-25 16:27:20 +01:00
|
|
|
// processSiblings
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
void Chord::processSiblings(std::function<void(Element*)> func) const
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
if (_hook)
|
2013-03-25 16:27:20 +01:00
|
|
|
func(_hook);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_stem)
|
2013-03-25 16:27:20 +01:00
|
|
|
func(_stem);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_stemSlash)
|
2013-03-25 16:27:20 +01:00
|
|
|
func(_stemSlash);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_arpeggio)
|
2013-03-25 16:27:20 +01:00
|
|
|
func(_arpeggio);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_tremolo)
|
2013-03-25 16:27:20 +01:00
|
|
|
func(_tremolo);
|
2013-01-03 16:56:56 +01:00
|
|
|
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
|
2013-03-25 16:27:20 +01:00
|
|
|
func(ll);
|
2016-02-06 22:03:43 +01:00
|
|
|
for (Note* note : _notes)
|
|
|
|
func(note);
|
2013-03-25 16:27:20 +01:00
|
|
|
for (Element* e : _el)
|
|
|
|
func(e);
|
2016-01-04 14:48:58 +01:00
|
|
|
for (Chord* chord : _graceNotes) // process grace notes last, needed for correct shape calculation
|
|
|
|
func(chord);
|
2013-03-25 16:27:20 +01:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-03-25 16:27:20 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// setTrack
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::setTrack(int val)
|
|
|
|
{
|
2012-05-26 14:26:10 +02:00
|
|
|
ChordRest::setTrack(val);
|
2013-03-25 16:27:20 +01:00
|
|
|
processSiblings([val] (Element* e) { e->setTrack(val); } );
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2013-03-25 16:27:20 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// setScore
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::setScore(Score* s)
|
|
|
|
{
|
|
|
|
ChordRest::setScore(s);
|
|
|
|
processSiblings([s] (Element* e) { e->setScore(s); } );
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2015-06-22 17:41:06 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// defaultStemLength
|
|
|
|
/// Get the default stem length for this chord
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-03-19 11:41:38 +01:00
|
|
|
qreal Chord::defaultStemLength()
|
|
|
|
{
|
2015-06-22 17:41:06 +02:00
|
|
|
qreal _spatium = spatium();
|
|
|
|
Note* downnote;
|
|
|
|
int dl, ul;
|
|
|
|
qreal stemLen;
|
|
|
|
int hookIdx = durationType().hooks();
|
|
|
|
downnote = downNote();
|
|
|
|
ul = upLine();
|
|
|
|
dl = downLine();
|
2015-09-01 06:19:20 +02:00
|
|
|
Staff* st = staff();
|
|
|
|
qreal physicalLineDistance = st ? st->lineDistance() : 1.0;
|
|
|
|
qreal logicalLineDistance = st ? st->logicalLineDistance() : 1.0;
|
2015-06-22 17:41:06 +02:00
|
|
|
|
|
|
|
StaffType* tab = 0;
|
2015-09-01 06:19:20 +02:00
|
|
|
if (st && st->isTabStaff()) {
|
|
|
|
tab = st->staffType();
|
2015-06-22 17:41:06 +02:00
|
|
|
// require stems only if TAB is not stemless and this chord has a stem
|
|
|
|
if (!tab->slashStyle() && _stem) {
|
|
|
|
// if stems are beside staff, apply special formatting
|
|
|
|
if (!tab->stemThrough()) {
|
|
|
|
// process stem:
|
|
|
|
return tab->chordStemLength(this) * _spatium;
|
2016-01-04 14:48:58 +01:00
|
|
|
}
|
2015-06-22 17:41:06 +02:00
|
|
|
}
|
|
|
|
}
|
2015-09-01 06:19:20 +02:00
|
|
|
else if (logicalLineDistance != 1.0) {
|
|
|
|
// convert to actual distance from top of staff in sp
|
|
|
|
ul *= logicalLineDistance;
|
|
|
|
dl *= logicalLineDistance;
|
|
|
|
}
|
2015-06-22 17:41:06 +02:00
|
|
|
|
|
|
|
if (tab && !tab->onLines()) { // if TAB and frets above strings, move 1 position up
|
|
|
|
--ul;
|
|
|
|
--dl;
|
|
|
|
}
|
|
|
|
bool shortenStem = score()->styleB(StyleIdx::shortenStem);
|
|
|
|
if (hookIdx >= 2 || _tremolo)
|
|
|
|
shortenStem = false;
|
|
|
|
|
2016-03-19 11:41:38 +01:00
|
|
|
Spatium progression = score()->styleS(StyleIdx::shortStemProgression);
|
|
|
|
qreal shortest = score()->styleS(StyleIdx::shortestStem).val();
|
2015-06-22 17:41:06 +02:00
|
|
|
|
|
|
|
qreal normalStemLen = small() ? 2.5 : 3.5;
|
|
|
|
switch(hookIdx) {
|
|
|
|
case 3: normalStemLen += small() ? .5 : 0.75; break; //32nd notes
|
|
|
|
case 4: normalStemLen += small() ? 1.0 : 1.5; break; //64th notes
|
|
|
|
case 5: normalStemLen += small() ? 1.5 : 2.25; break; //128th notes
|
|
|
|
}
|
|
|
|
if (_hook && tab == 0) {
|
|
|
|
if (up() && durationType().dots()) {
|
|
|
|
//
|
|
|
|
// avoid collision of dot with hook
|
|
|
|
//
|
|
|
|
if (!(ul & 1))
|
|
|
|
normalStemLen += .5;
|
|
|
|
shortenStem = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_noteType != NoteType::NORMAL) {
|
|
|
|
// grace notes stems are not subject to normal
|
|
|
|
// stem rules
|
|
|
|
stemLen = qAbs(ul - dl) * .5;
|
|
|
|
stemLen += normalStemLen * score()->styleD(StyleIdx::graceNoteMag);
|
|
|
|
if (up())
|
|
|
|
stemLen *= -1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// normal note (not grace)
|
2015-09-01 06:19:20 +02:00
|
|
|
qreal staffHeight = st ? st->lines() - 1 : 4;
|
|
|
|
if (physicalLineDistance != 1.0 && !tab)
|
|
|
|
staffHeight *= physicalLineDistance;
|
2015-06-22 17:41:06 +02:00
|
|
|
qreal staffHlfHgt = staffHeight * 0.5;
|
|
|
|
if (up()) { // stem up
|
|
|
|
qreal dy = dl * .5; // note-side vert. pos.
|
|
|
|
qreal sel = ul * .5 - normalStemLen; // stem end vert. pos
|
|
|
|
|
|
|
|
// if stem ends above top line (with some exceptions), shorten it
|
2016-05-19 13:15:34 +02:00
|
|
|
if (shortenStem && (sel < 0.0) && (hookIdx == 0 || tab || !downnote->mirror()))
|
2015-06-22 17:41:06 +02:00
|
|
|
sel -= sel * progression.val();
|
|
|
|
if (sel > staffHlfHgt) // if stem ends below ('>') staff mid position,
|
|
|
|
sel = staffHlfHgt; // stretch it to mid position
|
|
|
|
stemLen = sel - dy; // actual stem length
|
|
|
|
if (-stemLen < shortest) // is stem too short,
|
|
|
|
stemLen = -shortest; // lengthen it to shortest possible length
|
|
|
|
}
|
|
|
|
else { // stem down
|
|
|
|
qreal uy = ul * .5; // note-side vert. pos.
|
|
|
|
qreal sel = dl * .5 + normalStemLen; // stem end vert. pos.
|
|
|
|
|
|
|
|
// if stem ends below bottom line (with some exceptions), shorten it
|
2016-05-19 13:15:34 +02:00
|
|
|
if (shortenStem && (sel > staffHeight) && (hookIdx == 0 || tab || downnote->mirror()))
|
2015-06-22 17:41:06 +02:00
|
|
|
sel -= (sel - staffHeight) * progression.val();
|
|
|
|
if (sel < staffHlfHgt) // if stem ends above ('<') staff mid position,
|
|
|
|
sel = staffHlfHgt; // stretch it to mid position
|
|
|
|
stemLen = sel - uy; // actual stem length
|
|
|
|
if (stemLen < shortest) // if stem too short,
|
|
|
|
stemLen = shortest; // lengthen it to shortest possible position
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// adjust stem len for tremolo
|
|
|
|
if (_tremolo && !_tremolo->twoNotes()) {
|
|
|
|
// hook up odd lines
|
2016-05-19 13:15:34 +02:00
|
|
|
static const int tab[2][2][2][4] = {
|
2015-06-22 17:41:06 +02:00
|
|
|
{ { { 0, 0, 0, 1 }, // stem - down - even - lines
|
|
|
|
{ 0, 0, 0, 2 } // stem - down - odd - lines
|
|
|
|
},
|
|
|
|
{ { 0, 0, 0, -1 }, // stem - up - even - lines
|
|
|
|
{ 0, 0, 0, -2 } // stem - up - odd - lines
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ { { 0, 0, 1, 2 }, // hook - down - even - lines
|
|
|
|
{ 0, 0, 1, 2 } // hook - down - odd - lines
|
|
|
|
},
|
|
|
|
{ { 0, 0, -1, -2 }, // hook - up - even - lines
|
|
|
|
{ 0, 0, -1, -2 } // hook - up - odd - lines
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
int odd = (up() ? upLine() : downLine()) & 1;
|
|
|
|
int n = tab[_hook ? 1 : 0][up() ? 1 : 0][odd][_tremolo->lines()-1];
|
|
|
|
stemLen += n * .5;
|
|
|
|
}
|
2015-08-06 23:29:55 +02:00
|
|
|
// TAB: scale stemLen according to staff line spacing
|
2015-09-01 06:19:20 +02:00
|
|
|
if (tab)
|
|
|
|
stemLen *= physicalLineDistance;
|
2015-06-22 17:41:06 +02:00
|
|
|
|
|
|
|
return stemLen * _spatium;
|
2016-01-04 14:48:58 +01:00
|
|
|
}
|
2015-06-22 17:41:06 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layoutStem1
|
2013-07-13 11:17:47 +02:00
|
|
|
/// Layout _stem and _stemSlash
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
2013-07-13 11:17:47 +02:00
|
|
|
// Called before layout spacing of notes.
|
|
|
|
// Create stem if necessary.
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::layoutStem1()
|
|
|
|
{
|
2015-01-21 11:55:36 +01:00
|
|
|
if (durationType().hasStem() && !(_noStem || measure()->slashStyle(staffIdx())
|
|
|
|
|| (staff() && staff()->isTabStaff() && staff()->staffType()->slashStyle()))) {
|
2013-07-13 11:17:47 +02:00
|
|
|
if (!_stem) {
|
|
|
|
Stem* stem = new Stem(score());
|
|
|
|
stem->setParent(this);
|
|
|
|
stem->setGenerated(true);
|
|
|
|
score()->undoAddElement(stem);
|
|
|
|
}
|
2015-01-24 11:31:38 +01:00
|
|
|
if ((_noteType == NoteType::ACCIACCATURA) && !(beam() && beam()->elements().front() != this)) {
|
|
|
|
if (!_stemSlash)
|
|
|
|
add(new StemSlash(score()));
|
2013-07-13 11:17:47 +02:00
|
|
|
}
|
2015-01-24 11:31:38 +01:00
|
|
|
else if (_stemSlash)
|
|
|
|
remove(_stemSlash);
|
2016-04-27 16:33:30 +02:00
|
|
|
|
|
|
|
qreal stemWidth5 = _stem->lineWidth() * .5;
|
|
|
|
_stem->rxpos() = stemPosX() + (up() ? -stemWidth5 : +stemWidth5);
|
|
|
|
_stem->setLen(defaultStemLength());
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2015-01-21 11:55:36 +01:00
|
|
|
else {
|
|
|
|
if (_stem)
|
|
|
|
score()->undoRemoveElement(_stem);
|
|
|
|
if (_stemSlash)
|
2015-03-06 10:28:56 +01:00
|
|
|
score()->undoRemoveElement(_stemSlash);
|
2015-01-21 11:55:36 +01:00
|
|
|
}
|
2013-07-11 12:25:25 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-06-20 10:19:04 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
// layoutStem
|
2012-06-25 13:59:45 +02:00
|
|
|
/// Layout chord tremolo stem and hook.
|
2013-03-09 09:58:43 +01:00
|
|
|
//
|
|
|
|
// hook: sets position
|
|
|
|
// stem: sets length, but not position (assumed to be set in Chord::layout())
|
2013-06-20 10:19:04 +02:00
|
|
|
//-----------------------------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
void Chord::layoutStem()
|
|
|
|
{
|
2013-06-10 21:13:04 +02:00
|
|
|
for (Chord* c : _graceNotes)
|
|
|
|
c->layoutStem();
|
2016-05-19 13:15:34 +02:00
|
|
|
if (_beam)
|
2013-06-16 23:33:37 +02:00
|
|
|
return;
|
2016-05-19 13:15:34 +02:00
|
|
|
|
|
|
|
// create hooks for unbeamed chords
|
|
|
|
|
|
|
|
int hookIdx = durationType().hooks();
|
|
|
|
|
|
|
|
if (hookIdx && !(noStem() || measure()->slashStyle(staffIdx()))) {
|
|
|
|
if (!hook()) {
|
|
|
|
Hook* hook = new Hook(score());
|
|
|
|
hook->setParent(this);
|
|
|
|
hook->setGenerated(true);
|
|
|
|
score()->undoAddElement(hook);
|
|
|
|
}
|
|
|
|
hook()->setHookType(up() ? hookIdx : -hookIdx);
|
|
|
|
}
|
|
|
|
else if (hook())
|
|
|
|
score()->undoRemoveElement(hook());
|
|
|
|
|
2012-09-06 14:00:14 +02:00
|
|
|
//
|
|
|
|
// TAB
|
|
|
|
//
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = 0;
|
2012-08-16 11:09:36 +02:00
|
|
|
if (staff() && staff()->isTabStaff()) {
|
2014-04-28 18:38:50 +02:00
|
|
|
tab = staff()->staffType();
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
// if stemless TAB
|
|
|
|
if (tab->slashStyle()) {
|
|
|
|
// if 'grid' duration symbol of MEDIALFINAL type, it is time to compute its width
|
|
|
|
if (_tabDur != nullptr && _tabDur->beamGrid() == TabBeamGrid::MEDIALFINAL)
|
|
|
|
_tabDur->layout2();
|
|
|
|
// in all other stemless cases, do nothing
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// not a stemless TAB; if stems are beside staff, apply special formatting
|
|
|
|
if (!tab->stemThrough()) {
|
|
|
|
if (_stem) { // (duplicate code with defaultStemLength())
|
2013-03-09 09:58:43 +01:00
|
|
|
// process stem:
|
2016-04-27 16:33:30 +02:00
|
|
|
_stem->setLen(tab->chordStemLength(this) * spatium());
|
2013-03-09 09:58:43 +01:00
|
|
|
// process hook
|
|
|
|
int hookIdx = durationType().hooks();
|
2013-03-11 23:34:50 +01:00
|
|
|
if (!up())
|
2013-03-09 09:58:43 +01:00
|
|
|
hookIdx = -hookIdx;
|
2015-05-10 09:58:54 +02:00
|
|
|
if (hookIdx && _hook) {
|
2013-03-09 09:58:43 +01:00
|
|
|
_hook->setHookType(hookIdx);
|
2014-02-26 21:31:01 +01:00
|
|
|
qreal x = _stem->pos().x() + _stem->lineWidth() * .5;;
|
2013-11-07 19:58:42 +01:00
|
|
|
qreal y = _stem->pos().y();
|
|
|
|
if (up()) {
|
2014-02-26 21:31:01 +01:00
|
|
|
y -= _stem->bbox().height();
|
2013-11-07 19:58:42 +01:00
|
|
|
x -= _stem->width();
|
|
|
|
}
|
|
|
|
else {
|
2014-02-26 21:31:01 +01:00
|
|
|
y += _stem->bbox().height();
|
|
|
|
x -= _stem->width();
|
2013-11-07 19:58:42 +01:00
|
|
|
}
|
|
|
|
_hook->setPos(x, y);
|
2013-03-09 09:58:43 +01:00
|
|
|
_hook->adjustReadPos();
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
return;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
// if stems are through staff, use standard formatting
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2012-09-06 14:00:14 +02:00
|
|
|
//
|
2013-03-09 09:58:43 +01:00
|
|
|
// NON-TAB (or TAB with stems through staff)
|
2012-09-06 14:00:14 +02:00
|
|
|
//
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_stem) {
|
2016-01-04 14:48:58 +01:00
|
|
|
_stem->setLen(defaultStemLength());
|
2013-06-16 23:33:37 +02:00
|
|
|
// if (isGrace())
|
|
|
|
// abort();
|
2012-05-26 14:26:10 +02:00
|
|
|
if (_hook) {
|
2016-01-04 14:48:58 +01:00
|
|
|
_hook->layout();
|
2013-11-07 19:58:42 +01:00
|
|
|
QPointF p(_stem->hookPos());
|
|
|
|
if (up()) {
|
|
|
|
p.ry() -= _hook->bbox().top();
|
|
|
|
p.rx() -= _stem->width();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
p.ry() -= _hook->bbox().bottom();
|
|
|
|
p.rx() -= _stem->width();
|
|
|
|
}
|
|
|
|
_hook->setPos(p);
|
2012-05-26 14:26:10 +02:00
|
|
|
_hook->adjustReadPos();
|
|
|
|
}
|
2012-11-23 14:48:55 +01:00
|
|
|
if (_stemSlash)
|
|
|
|
_stemSlash->layout();
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------
|
|
|
|
// process tremolo
|
|
|
|
//-----------------------------------------
|
|
|
|
|
|
|
|
if (_tremolo)
|
|
|
|
_tremolo->layout();
|
|
|
|
}
|
|
|
|
|
2014-04-23 18:07:38 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// underBeam: true, if grace note is placed under a beam.
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool Chord::underBeam() const
|
|
|
|
{
|
2014-05-27 10:35:28 +02:00
|
|
|
if(_noteType == NoteType::NORMAL)
|
2014-04-23 18:07:38 +02:00
|
|
|
return false;
|
|
|
|
const Chord* cr = static_cast<Chord*>(parent());
|
|
|
|
Beam* beam = cr->beam();
|
|
|
|
if(!beam || !cr->beam()->up())
|
|
|
|
return false;
|
|
|
|
int s = beam->elements().count();
|
|
|
|
if(isGraceBefore()){
|
|
|
|
if(beam->elements()[0] != cr)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(isGraceAfter()){
|
|
|
|
if(beam->elements()[s - 1] != cr)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layout2
|
|
|
|
// Called after horizontal positions of all elements
|
|
|
|
// are fixed.
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::layout2()
|
|
|
|
{
|
2013-06-10 21:13:04 +02:00
|
|
|
for (Chord* c : _graceNotes)
|
|
|
|
c->layout2();
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal _spatium = spatium();
|
2016-03-02 13:20:19 +01:00
|
|
|
qreal _mag = staff()->mag();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Experimental:
|
|
|
|
// look for colliding ledger lines
|
|
|
|
//
|
|
|
|
|
|
|
|
const qreal minDist = _spatium * .17;
|
|
|
|
|
2014-06-25 11:46:10 +02:00
|
|
|
Segment* s = segment()->prev(Segment::Type::ChordRest);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (s) {
|
2013-01-02 20:13:58 +01:00
|
|
|
int strack = staff2track(staffIdx());
|
2012-05-26 14:26:10 +02:00
|
|
|
int etrack = strack + VOICES;
|
2012-12-06 12:46:05 +01:00
|
|
|
|
2013-01-03 16:56:56 +01:00
|
|
|
for (LedgerLine* h = _ledgerLines; h; h = h->next()) {
|
2016-09-03 17:45:59 +02:00
|
|
|
qreal len = h->len();
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal y = h->y();
|
|
|
|
qreal x = h->x();
|
|
|
|
bool found = false;
|
|
|
|
qreal cx = h->measureXPos();
|
|
|
|
|
|
|
|
for (int track = strack; track < etrack; ++track) {
|
2013-01-03 16:56:56 +01:00
|
|
|
Chord* e = static_cast<Chord*>(s->element(track));
|
2014-06-24 18:36:02 +02:00
|
|
|
if (!e || e->type() != Element::Type::CHORD)
|
2012-05-26 14:26:10 +02:00
|
|
|
continue;
|
2013-01-03 16:56:56 +01:00
|
|
|
for (LedgerLine* ll = e->ledgerLines(); ll; ll = ll->next()) {
|
2012-05-26 14:26:10 +02:00
|
|
|
if (ll->y() != y)
|
|
|
|
continue;
|
|
|
|
|
2016-09-03 17:45:59 +02:00
|
|
|
qreal d = cx - ll->measureXPos() - ll->len();
|
2012-05-26 14:26:10 +02:00
|
|
|
if (d < minDist) {
|
|
|
|
//
|
|
|
|
// the ledger lines overlap
|
|
|
|
//
|
|
|
|
qreal shorten = (minDist - d) * .5;
|
|
|
|
x += shorten;
|
2016-09-03 17:45:59 +02:00
|
|
|
len -= shorten;
|
|
|
|
ll->setLen(ll->len() - shorten);
|
2012-05-26 14:26:10 +02:00
|
|
|
h->setLen(len);
|
|
|
|
h->setPos(x, y);
|
|
|
|
}
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-25 23:00:59 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// position after-chord grace notes
|
|
|
|
// room for them has been reserved in Chord::layout()
|
|
|
|
//
|
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> gna = graceNotesAfter();
|
|
|
|
if (!gna.empty()) {
|
2016-03-02 13:20:19 +01:00
|
|
|
qreal minNoteDist = score()->styleP(StyleIdx::minNoteDistance) * _mag * score()->styleD(StyleIdx::graceNoteMag);
|
2015-01-25 23:00:59 +01:00
|
|
|
// position grace notes from the rightmost to the leftmost
|
|
|
|
// get segment (of whatever type) at the end of this chord; if none, get measure last segment
|
|
|
|
Segment* s = measure()->tick2segment(segment()->tick() + actualTicks(), Segment::Type::All);
|
|
|
|
if (s == nullptr)
|
|
|
|
s = measure()->last();
|
|
|
|
if (s == segment()) // if our segment is the last, no adjacent segment found
|
|
|
|
s = nullptr;
|
|
|
|
// start from the right (if next segment found, x of it relative to this chord;
|
|
|
|
// chord right space otherwise)
|
2016-02-04 11:27:47 +01:00
|
|
|
qreal xOff = s ? s->pos().x() - (segment()->pos().x() + pos().x()) : _spaceRw;
|
2015-01-25 23:00:59 +01:00
|
|
|
// final distance: if near to another chord, leave minNoteDist at right of last grace
|
|
|
|
// else leave note-to-barline distance;
|
|
|
|
xOff -= (s != nullptr && s->segmentType() != Segment::Type::ChordRest)
|
2016-03-02 13:20:19 +01:00
|
|
|
? score()->styleP(StyleIdx::noteBarDistance) * _mag
|
2015-01-25 23:00:59 +01:00
|
|
|
: minNoteDist;
|
|
|
|
// scan grace note list from the end
|
2015-02-19 10:28:25 +01:00
|
|
|
int n = gna.size();
|
|
|
|
for (int i = n-1; i >= 0; i--) {
|
|
|
|
Chord* g = gna.value(i);
|
2016-02-04 11:27:47 +01:00
|
|
|
xOff -= g->_spaceRw; // move to left by grace note left space (incl. grace own width)
|
2015-01-25 23:00:59 +01:00
|
|
|
g->rxpos() = xOff;
|
2016-02-04 11:27:47 +01:00
|
|
|
xOff -= minNoteDist + g->_spaceLw; // move to left by grace note right space and inter-grace distance
|
2015-01-25 23:00:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2014-04-22 17:02:03 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// cmdUpdateNotes
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::cmdUpdateNotes(AccidentalState* as)
|
|
|
|
{
|
|
|
|
// TAB_STAFF is different, as each note has to be fretted
|
|
|
|
// in the context of the all of the chords of the whole segment
|
|
|
|
|
|
|
|
StaffGroup staffGroup = staff()->staffType()->group();
|
2014-05-27 13:30:23 +02:00
|
|
|
if (staffGroup == StaffGroup::TAB) {
|
2015-03-13 11:16:43 +01:00
|
|
|
const Instrument* instrument = part()->instrument();
|
2014-04-22 17:02:03 +02:00
|
|
|
for (Chord* ch : graceNotes())
|
|
|
|
instrument->stringData()->fretChords(ch);
|
|
|
|
instrument->stringData()->fretChords(this);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// PITCHED_ and PERCUSSION_STAFF can go note by note
|
|
|
|
|
2015-02-19 10:28:25 +01:00
|
|
|
for (Chord* ch : graceNotesBefore()) {
|
|
|
|
if (staffGroup != StaffGroup::PERCUSSION) {
|
2016-02-06 22:03:43 +01:00
|
|
|
std::vector<Note*> notes(ch->notes()); // we need a copy!
|
2015-02-19 10:28:25 +01:00
|
|
|
for (Note* note : notes)
|
|
|
|
note->updateAccidental(as);
|
2014-10-03 23:20:00 +02:00
|
|
|
}
|
2015-02-19 10:28:25 +01:00
|
|
|
ch->sortNotes();
|
2014-04-22 17:02:03 +02:00
|
|
|
}
|
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
std::vector<Note*> lnotes(notes()); // we need a copy!
|
2016-04-21 14:17:18 +02:00
|
|
|
|
|
|
|
if (staffGroup == StaffGroup::STANDARD) {
|
|
|
|
for (Note* note : lnotes) {
|
2016-06-16 21:31:37 +02:00
|
|
|
if (note->tieBack() && note->tpc() == note->tieBack()->startNote()->tpc()) {
|
|
|
|
// same pitch
|
|
|
|
if (note->accidental() && note->accidental()->role() == AccidentalRole::AUTO) {
|
|
|
|
// not courtesy
|
2014-04-22 17:02:03 +02:00
|
|
|
// TODO: remove accidental only if note is not
|
|
|
|
// on new system
|
|
|
|
score()->undoRemoveElement(note->accidental());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
note->updateAccidental(as);
|
|
|
|
}
|
2016-04-21 14:17:18 +02:00
|
|
|
}
|
|
|
|
else if (staffGroup == StaffGroup::PERCUSSION) {
|
|
|
|
const Instrument* instrument = part()->instrument();
|
|
|
|
const Drumset* drumset = instrument->drumset();
|
|
|
|
if (!drumset)
|
|
|
|
qWarning("no drumset");
|
|
|
|
for (Note* note : lnotes) {
|
|
|
|
if (!drumset)
|
|
|
|
note->setLine(0);
|
|
|
|
else {
|
|
|
|
int pitch = note->pitch();
|
2014-04-22 17:02:03 +02:00
|
|
|
if (!drumset->isValid(pitch)) {
|
2016-04-21 14:17:18 +02:00
|
|
|
note->setLine(0);
|
|
|
|
qWarning("unmapped drum note %d", pitch);
|
2014-04-22 17:02:03 +02:00
|
|
|
}
|
2014-11-15 21:28:16 +01:00
|
|
|
else if (!note->fixed()) {
|
2015-01-29 10:39:00 +01:00
|
|
|
note->undoChangeProperty(P_ID::HEAD_GROUP, int(drumset->noteHead(pitch)));
|
2016-04-21 14:17:18 +02:00
|
|
|
// note->setHeadGroup(drumset->noteHead(pitch));
|
2014-04-22 17:02:03 +02:00
|
|
|
note->setLine(drumset->line(pitch));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-28 02:40:57 +01:00
|
|
|
|
2015-02-19 10:28:25 +01:00
|
|
|
for (Chord* ch : graceNotesAfter()) {
|
|
|
|
if (staffGroup != StaffGroup::PERCUSSION) {
|
2016-02-06 22:03:43 +01:00
|
|
|
std::vector<Note*> notes(ch->notes()); // we need a copy!
|
2015-02-19 10:28:25 +01:00
|
|
|
for (Note* note : notes)
|
|
|
|
note->updateAccidental(as);
|
2014-10-03 23:20:00 +02:00
|
|
|
}
|
2015-02-19 10:28:25 +01:00
|
|
|
ch->sortNotes();
|
2014-10-03 23:20:00 +02:00
|
|
|
}
|
2014-04-22 17:02:03 +02:00
|
|
|
sortNotes();
|
|
|
|
}
|
|
|
|
|
2015-08-28 15:00:34 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// pagePos
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Chord::pagePos() const
|
|
|
|
{
|
|
|
|
if (isGrace()) {
|
|
|
|
QPointF p(pos());
|
|
|
|
if (parent() == 0)
|
|
|
|
return p;
|
|
|
|
p.rx() = pageX();
|
|
|
|
|
|
|
|
const Chord* pc = static_cast<const Chord*>(parent());
|
|
|
|
System* system = pc->segment()->system();
|
2015-08-28 15:58:42 +02:00
|
|
|
if (!system)
|
|
|
|
return p;
|
2016-04-01 14:57:24 +02:00
|
|
|
p.ry() += system->staffYpage(vStaffIdx());
|
2015-08-28 15:00:34 +02:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
return Element::pagePos();
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layout
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::layout()
|
|
|
|
{
|
|
|
|
if (_notes.empty())
|
|
|
|
return;
|
2013-05-23 15:39:14 +02:00
|
|
|
if (staff() && staff()->isTabStaff())
|
|
|
|
layoutTablature();
|
|
|
|
else
|
2013-06-16 23:33:37 +02:00
|
|
|
layoutPitched();
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
//---------------------------------------------------------
|
2013-06-16 23:33:37 +02:00
|
|
|
// layoutPitched
|
2013-05-23 15:39:14 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2013-06-16 23:33:37 +02:00
|
|
|
void Chord::layoutPitched()
|
2013-05-23 15:39:14 +02:00
|
|
|
{
|
2014-05-24 04:51:46 +02:00
|
|
|
int gi = 0;
|
|
|
|
for (Chord* c : _graceNotes) {
|
|
|
|
// HACK: graceIndex is not well-maintained on add & remove
|
|
|
|
// so rebuild now
|
|
|
|
c->setGraceIndex(gi++);
|
|
|
|
if (c->isGraceBefore())
|
|
|
|
c->layoutPitched();
|
|
|
|
}
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> graceNotesBefore = Chord::graceNotesBefore();
|
2015-02-19 10:28:25 +01:00
|
|
|
int gnb = graceNotesBefore.size();
|
|
|
|
|
2014-05-24 04:51:46 +02:00
|
|
|
// lay out grace notes after separately so they are processed left to right
|
|
|
|
// (they are normally stored right to left)
|
2015-02-19 10:28:25 +01:00
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> gna = graceNotesAfter();
|
2015-02-19 10:28:25 +01:00
|
|
|
for (Chord* c : gna)
|
|
|
|
c->layoutPitched();
|
2013-06-19 16:25:29 +02:00
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal _spatium = spatium();
|
2016-04-21 14:17:18 +02:00
|
|
|
qreal _mag = staff() ? staff()->mag() : 1.0; // palette elements do not have a staff
|
2016-03-02 13:20:19 +01:00
|
|
|
qreal dotNoteDistance = score()->styleP(StyleIdx::dotNoteDistance) * _mag;
|
|
|
|
qreal minNoteDistance = score()->styleP(StyleIdx::minNoteDistance) * _mag;
|
|
|
|
qreal minTieLength = score()->styleP(StyleIdx::MinTieLength) * _mag;
|
|
|
|
qreal ledgerLineLength = score()->styleP(StyleIdx::ledgerLineLength) * _mag;
|
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal graceMag = score()->styleD(StyleIdx::graceNoteMag);
|
|
|
|
qreal chordX = (_noteType == NoteType::NORMAL) ? ipos().x() : 0.0;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-01-07 12:36:06 +01:00
|
|
|
while (_ledgerLines) {
|
|
|
|
LedgerLine* l = _ledgerLines->next();
|
|
|
|
delete _ledgerLines;
|
|
|
|
_ledgerLines = l;
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-06-19 16:25:29 +02:00
|
|
|
qreal lll = 0.0; // space to leave at left of chord
|
|
|
|
qreal rrr = 0.0; // space to leave at right of chord
|
2014-05-24 04:51:46 +02:00
|
|
|
qreal lhead = 0.0; // amount of notehead to left of chord origin
|
2013-06-19 16:25:29 +02:00
|
|
|
Note* upnote = upNote();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
delete _tabDur; // no TAB? no duration symbol! (may happen when converting a TAB into PITCHED)
|
|
|
|
_tabDur = 0;
|
|
|
|
|
|
|
|
if (!segment()) {
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
2013-05-23 15:39:14 +02:00
|
|
|
// hack for use in palette
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
2013-05-23 15:39:14 +02:00
|
|
|
for (int i = 0; i < n; i++) {
|
2012-12-06 12:46:05 +01:00
|
|
|
Note* note = _notes.at(i);
|
2012-05-26 14:26:10 +02:00
|
|
|
note->layout();
|
2013-05-23 15:39:14 +02:00
|
|
|
qreal x = 0.0;
|
|
|
|
qreal y = note->line() * _spatium * .5;
|
|
|
|
note->setPos(x, y);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
computeUp();
|
|
|
|
layoutStem();
|
2016-05-07 05:14:00 +02:00
|
|
|
addLedgerLines();
|
2013-05-23 15:39:14 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------
|
|
|
|
// process notes
|
|
|
|
//-----------------------------------------
|
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
for (Note* note : _notes) {
|
2013-05-23 15:39:14 +02:00
|
|
|
note->layout();
|
2013-05-23 16:58:22 +02:00
|
|
|
|
2014-05-22 08:49:57 +02:00
|
|
|
qreal x1 = note->pos().x() + chordX;
|
2013-05-23 16:58:22 +02:00
|
|
|
qreal x2 = x1 + note->headWidth();
|
2016-08-07 11:04:14 +02:00
|
|
|
lll = qMax(lll, -x1);
|
|
|
|
rrr = qMax(rrr, x2);
|
2014-05-24 04:51:46 +02:00
|
|
|
// track amount of space due to notehead only
|
2016-08-07 11:04:14 +02:00
|
|
|
lhead = qMax(lhead, -x1);
|
2013-05-23 15:39:14 +02:00
|
|
|
|
|
|
|
Accidental* accidental = note->accidental();
|
2014-11-15 21:28:16 +01:00
|
|
|
if (accidental && !note->fixed()) {
|
2014-03-25 18:33:53 +01:00
|
|
|
// convert x position of accidental to segment coordinate system
|
2014-05-22 08:49:57 +02:00
|
|
|
qreal x = accidental->pos().x() + note->pos().x() + chordX;
|
2014-05-21 03:14:06 +02:00
|
|
|
// distance from accidental to note already taken into account
|
|
|
|
// but here perhaps we create more padding in *front* of accidental?
|
2016-03-02 13:20:19 +01:00
|
|
|
x -= score()->styleP(StyleIdx::accidentalDistance) * _mag;
|
2013-07-18 17:01:45 +02:00
|
|
|
lll = qMax(lll, -x);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2014-02-22 21:29:29 +01:00
|
|
|
|
|
|
|
// allow extra space for shortened ties
|
2014-02-23 21:41:50 +01:00
|
|
|
// this code must be kept synchronized
|
|
|
|
// with the tie positioning code in Tie::slurPos()
|
|
|
|
// but the allocation of space needs to be performed here
|
2014-02-22 21:29:29 +01:00
|
|
|
Tie* tie;
|
|
|
|
tie = note->tieBack();
|
|
|
|
if (tie) {
|
|
|
|
tie->calculateDirection();
|
2014-02-23 21:41:50 +01:00
|
|
|
qreal overlap = 0.0;
|
|
|
|
bool shortStart = false;
|
2014-02-23 17:16:39 +01:00
|
|
|
Note* sn = tie->startNote();
|
|
|
|
Chord* sc = sn->chord();
|
2014-02-24 18:01:55 +01:00
|
|
|
if (sc && sc->measure() == measure() && sc == prevChordRest(this)) {
|
2014-02-23 17:16:39 +01:00
|
|
|
if (sc->notes().size() > 1 || (sc->stem() && sc->up() == tie->up())) {
|
2014-02-23 21:41:50 +01:00
|
|
|
shortStart = true;
|
2014-02-23 17:16:39 +01:00
|
|
|
if (sc->width() > sn->width()) {
|
|
|
|
// chord with second?
|
|
|
|
// account for noteheads further to right
|
|
|
|
qreal snEnd = sn->x() + sn->headWidth();
|
|
|
|
qreal scEnd = snEnd;
|
2016-02-06 22:03:43 +01:00
|
|
|
for (unsigned i = 0; i < sc->notes().size(); ++i)
|
2014-02-23 17:16:39 +01:00
|
|
|
scEnd = qMax(scEnd, sc->notes().at(i)->x() + sc->notes().at(i)->headWidth());
|
2014-02-23 21:41:50 +01:00
|
|
|
overlap += scEnd - snEnd;
|
2014-02-23 17:16:39 +01:00
|
|
|
}
|
2014-02-23 21:41:50 +01:00
|
|
|
else
|
|
|
|
overlap -= sn->headWidth() * 0.12;
|
2014-02-23 17:16:39 +01:00
|
|
|
}
|
2014-02-23 21:41:50 +01:00
|
|
|
else
|
|
|
|
overlap += sn->headWidth() * 0.35;
|
2014-02-23 17:16:39 +01:00
|
|
|
if (notes().size() > 1 || (stem() && !up() && !tie->up())) {
|
|
|
|
// for positive offset:
|
|
|
|
// use available space
|
|
|
|
// for negative x offset:
|
|
|
|
// space is allocated elsewhere, so don't re-allocate here
|
2014-02-23 21:41:50 +01:00
|
|
|
if (note->ipos().x() != 0.0)
|
|
|
|
overlap += qAbs(note->ipos().x());
|
|
|
|
else
|
|
|
|
overlap -= note->headWidth() * 0.12;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (shortStart)
|
|
|
|
overlap += note->headWidth() * 0.15;
|
|
|
|
else
|
|
|
|
overlap += note->headWidth() * 0.35;
|
2014-02-23 17:16:39 +01:00
|
|
|
}
|
2014-02-23 21:41:50 +01:00
|
|
|
qreal d = qMax(minTieLength - overlap, 0.0);
|
2014-02-22 21:29:29 +01:00
|
|
|
lll = qMax(lll, d);
|
|
|
|
}
|
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
|
|
|
|
2013-08-03 01:45:46 +02:00
|
|
|
//-----------------------------------------
|
|
|
|
// create ledger lines
|
|
|
|
//-----------------------------------------
|
2013-05-24 11:44:21 +02:00
|
|
|
|
2016-05-07 05:14:00 +02:00
|
|
|
addLedgerLines();
|
2013-05-23 15:39:14 +02:00
|
|
|
|
|
|
|
if (_arpeggio) {
|
2016-03-02 13:20:19 +01:00
|
|
|
qreal arpeggioDistance = score()->styleP(StyleIdx::ArpeggioNoteDistance) * _mag;
|
2013-11-19 12:12:07 +01:00
|
|
|
_arpeggio->layout(); // only for width() !
|
2014-09-10 06:24:19 +02:00
|
|
|
lll += _arpeggio->width() + arpeggioDistance + chordX;
|
2013-11-19 12:12:07 +01:00
|
|
|
qreal y1 = upnote->pos().y() - upnote->headHeight() * .5;
|
|
|
|
_arpeggio->setPos(-lll, y1);
|
2013-09-09 18:24:44 +02:00
|
|
|
_arpeggio->adjustReadPos();
|
2013-11-19 12:12:07 +01:00
|
|
|
// _arpeggio->layout() called in layoutArpeggio2()
|
2013-05-23 15:39:14 +02:00
|
|
|
|
|
|
|
// handle the special case of _arpeggio->span() > 1
|
|
|
|
// in layoutArpeggio2() after page layout has done so we
|
|
|
|
// know the y position of the next staves
|
|
|
|
}
|
|
|
|
|
2014-05-27 05:04:49 +02:00
|
|
|
// allocate enough room for glissandi
|
2014-12-13 17:40:39 +01:00
|
|
|
if (_endsGlissando) {
|
2015-02-26 22:04:17 +01:00
|
|
|
if (rtick() // if not at beginning of measure
|
|
|
|
|| graceNotesBefore.size() > 0) // or there are graces before
|
2014-12-13 17:40:39 +01:00
|
|
|
lll += _spatium * 0.5 + minTieLength;
|
2015-02-04 18:54:03 +01:00
|
|
|
// special case of system-initial glissando final note is handled in Glissando::layout() itself
|
2014-05-27 05:04:49 +02:00
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
|
|
|
|
if (dots()) {
|
2014-05-21 00:43:28 +02:00
|
|
|
qreal x = dotPosX() + dotNoteDistance
|
2016-03-02 13:20:19 +01:00
|
|
|
+ (dots()-1) * score()->styleP(StyleIdx::dotDotDistance) * _mag;
|
2013-11-11 15:11:28 +01:00
|
|
|
x += symWidth(SymId::augmentationDot);
|
2013-07-18 17:01:45 +02:00
|
|
|
rrr = qMax(rrr, x);
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_hook) {
|
|
|
|
if (beam())
|
|
|
|
score()->undoRemoveElement(_hook);
|
2012-05-26 14:26:10 +02:00
|
|
|
else {
|
2013-05-23 15:39:14 +02:00
|
|
|
_hook->layout();
|
2013-06-22 10:55:22 +02:00
|
|
|
if (up() && stem()) {
|
2013-05-23 15:39:14 +02:00
|
|
|
// hook position is not set yet
|
2014-05-22 08:49:57 +02:00
|
|
|
qreal x = _hook->bbox().right() + stem()->hookPos().x() + chordX;
|
2013-05-23 15:39:14 +02:00
|
|
|
rrr = qMax(rrr, x);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-09-02 12:13:46 +02:00
|
|
|
if (_ledgerLines) {
|
2014-05-24 04:51:46 +02:00
|
|
|
// we may need to increase distance to previous chord
|
|
|
|
Chord* pc = 0;
|
|
|
|
|
2014-05-27 15:48:23 +02:00
|
|
|
if (_noteType == NoteType::NORMAL) {
|
2014-05-24 04:51:46 +02:00
|
|
|
// normal note
|
|
|
|
if (gnb) {
|
|
|
|
// if there are grace notes before, get last
|
|
|
|
pc = graceNotesBefore.last();
|
|
|
|
}
|
|
|
|
else if (rtick()) {
|
|
|
|
// if this is not first chord of measure, get previous chord
|
2014-06-25 11:46:10 +02:00
|
|
|
Segment* s = segment()->prev(Segment::Type::ChordRest);
|
2014-12-03 17:50:39 +01:00
|
|
|
if (s) {
|
|
|
|
// prefer chord in same voice
|
|
|
|
// but if nothing there, look at other voices
|
|
|
|
// note this still leaves the possibility
|
|
|
|
// that this voice does not have conflict but another voice does
|
|
|
|
Element* e = s->element(track());
|
|
|
|
if (e && e->type() == Element::Type::CHORD)
|
|
|
|
pc = static_cast<Chord*>(e);
|
|
|
|
else {
|
|
|
|
int startTrack = staffIdx() * VOICES;
|
|
|
|
int endTrack = startTrack + VOICES;
|
|
|
|
for (int t = startTrack; t < endTrack; ++t) {
|
|
|
|
if (t == track()) // already checked current voice
|
|
|
|
continue;
|
|
|
|
e = s->element(t);
|
|
|
|
if (e && e->type() == Element::Type::CHORD) {
|
|
|
|
pc = static_cast<Chord*>(e);
|
|
|
|
// prefer chord with ledger lines
|
|
|
|
if (pc->ledgerLines())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-24 04:51:46 +02:00
|
|
|
}
|
2016-02-06 22:03:43 +01:00
|
|
|
if (pc && !pc->graceNotes().empty()) {
|
2014-05-24 04:51:46 +02:00
|
|
|
// if previous chord has grace notes after, find last one
|
|
|
|
// which, conveniently, is stored first
|
|
|
|
for (Chord* c : pc->graceNotes()) {
|
|
|
|
if (c->isGraceAfter()) {
|
|
|
|
pc = c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// grace note
|
|
|
|
Chord* mainChord = static_cast<Chord*>(parent());
|
|
|
|
bool before = isGraceBefore();
|
|
|
|
int incIdx = before ? -1 : 1;
|
|
|
|
int endIdx = before ? -1 : mainChord->graceNotes().size();
|
|
|
|
// find previous grace note of same type
|
|
|
|
for (int i = _graceIndex + incIdx; i != endIdx; i += incIdx) {
|
|
|
|
Chord* pgc = mainChord->graceNotes().at(i);
|
|
|
|
if (pgc->isGraceBefore() == before) {
|
|
|
|
pc = pgc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pc) {
|
|
|
|
// no previous grace note found
|
|
|
|
if (!before){
|
2015-02-19 07:34:46 +01:00
|
|
|
// grace note after - we would use main note
|
|
|
|
// but it hasn't been laid out yet, so we can't be sure about its ledger lines
|
|
|
|
// err on the side of safety
|
|
|
|
lll = qMax(lll, ledgerLineLength + lhead + 0.2 * _spatium * mag());
|
2014-05-24 04:51:46 +02:00
|
|
|
}
|
|
|
|
else if (mainChord->rtick()) {
|
|
|
|
// grace note before - use previous normal note of measure
|
2014-06-25 11:46:10 +02:00
|
|
|
Segment* s = mainChord->segment()->prev(Segment::Type::ChordRest);
|
2014-06-24 18:36:02 +02:00
|
|
|
if (s && s->element(track()) && s->element(track())->type() == Element::Type::CHORD)
|
2014-05-24 04:51:46 +02:00
|
|
|
pc = static_cast<Chord*>(s->element(track()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-02 12:13:46 +02:00
|
|
|
|
2014-05-24 04:51:46 +02:00
|
|
|
if (pc) {
|
|
|
|
// previous chord found
|
|
|
|
qreal llsp = 0.0;
|
|
|
|
int pUpLine = pc->upNote()->line();
|
|
|
|
int pDownLine = pc->downNote()->line();
|
|
|
|
int upLine = upNote()->line();
|
|
|
|
int downLine = downNote()->line();
|
|
|
|
int ledgerBelow = staff()->lines() * 2;
|
|
|
|
if (pc->_ledgerLines && ((pUpLine < 0 && upLine < 0) || (pDownLine >= ledgerBelow && downLine >= ledgerBelow))) {
|
|
|
|
// both chords have ledger lines above or below staff
|
|
|
|
llsp = ledgerLineLength;
|
|
|
|
// add space between ledger lines
|
2015-02-19 07:34:46 +01:00
|
|
|
llsp += 0.2 * _spatium * pc->mag();
|
2014-05-24 04:51:46 +02:00
|
|
|
// if any portion of note extended to left of origin
|
|
|
|
// we need to include that here so it is not subsumed by ledger line
|
|
|
|
llsp += lhead;
|
|
|
|
}
|
|
|
|
else if (pc->up() && upLine < 0) {
|
|
|
|
// even if no ledger lines in previous chord,
|
|
|
|
// we may need a little space to avoid crossing stem
|
|
|
|
llsp = ledgerLineLength * 0.5;
|
2015-02-19 07:34:46 +01:00
|
|
|
llsp += 0.2 * _spatium * pc->mag();
|
2014-05-24 04:51:46 +02:00
|
|
|
llsp += lhead;
|
|
|
|
}
|
2015-02-19 07:34:46 +01:00
|
|
|
if (_noteType == NoteType::NORMAL && pc->isGraceAfter()) {
|
|
|
|
// add appropriate space to right of previous (grace note after) chord
|
|
|
|
// this will be used in calculating its position relative to this chord
|
|
|
|
// it is too late to actually allocate space for this in segment of previous chord
|
|
|
|
// so we will allocate room in left space of this chord
|
2016-02-15 12:23:28 +01:00
|
|
|
qreal oldR = pc->_spaceRw;
|
2015-02-19 07:34:46 +01:00
|
|
|
qreal stemX = pc->stemPosX();
|
|
|
|
qreal available = oldR - stemX;
|
|
|
|
qreal newR = stemX + qMax(available, llsp);
|
|
|
|
if (newR > oldR)
|
2016-01-04 14:48:58 +01:00
|
|
|
pc->_spaceRw = newR;
|
2015-02-19 07:34:46 +01:00
|
|
|
}
|
2014-05-24 04:51:46 +02:00
|
|
|
lll = qMax(llsp, lll);
|
2013-09-02 12:13:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
_spaceLw = lll;
|
|
|
|
_spaceRw = rrr;
|
2013-05-23 15:39:14 +02:00
|
|
|
|
2014-05-24 04:51:46 +02:00
|
|
|
if (gnb){
|
2016-02-04 11:27:47 +01:00
|
|
|
qreal xl = -(_spaceLw + minNoteDistance) - chordX;
|
2014-05-24 04:51:46 +02:00
|
|
|
for (int i = gnb-1; i >= 0; --i) {
|
2015-01-25 23:00:59 +01:00
|
|
|
Chord* g = graceNotesBefore.value(i);
|
2016-01-04 14:48:58 +01:00
|
|
|
xl -= g->_spaceRw/* * 1.2*/;
|
2015-01-25 23:00:59 +01:00
|
|
|
g->setPos(xl, 0);
|
2016-01-04 14:48:58 +01:00
|
|
|
xl -= g->_spaceLw + minNoteDistance * graceMag;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
if (-xl > _spaceLw)
|
|
|
|
_spaceLw = -xl;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2016-02-06 22:03:43 +01:00
|
|
|
if (!gna.empty()) {
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal xr = _spaceRw;
|
2015-02-19 10:28:25 +01:00
|
|
|
int n = gna.size();
|
|
|
|
for (int i = 0; i <= n - 1; i++) {
|
|
|
|
Chord* g = gna.value(i);
|
2016-01-04 14:48:58 +01:00
|
|
|
xr += g->_spaceLw + g->_spaceRw + minNoteDistance * graceMag;
|
2015-01-25 23:00:59 +01:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
if (xr > _spaceRw)
|
|
|
|
_spaceRw = xr;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-06-16 23:33:37 +02:00
|
|
|
for (Element* e : _el) {
|
2014-06-24 18:36:02 +02:00
|
|
|
if (e->type() == Element::Type::SLUR) // we cannot at this time as chordpositions are not fixed
|
2013-06-20 17:23:24 +02:00
|
|
|
continue;
|
|
|
|
e->layout();
|
2014-06-24 18:36:02 +02:00
|
|
|
if (e->type() == Element::Type::CHORDLINE) {
|
2014-05-22 01:46:43 +02:00
|
|
|
QRectF tbbox = e->bbox().translated(e->pos());
|
2014-05-22 08:49:57 +02:00
|
|
|
qreal lx = tbbox.left() + chordX;
|
|
|
|
qreal rx = tbbox.right() + chordX;
|
2016-01-04 14:48:58 +01:00
|
|
|
if (-lx > _spaceLw)
|
|
|
|
_spaceLw = -lx;
|
|
|
|
if (rx > _spaceRw)
|
|
|
|
_spaceRw = rx;
|
2013-06-16 23:33:37 +02:00
|
|
|
}
|
2013-06-12 14:23:57 +02:00
|
|
|
}
|
2016-02-06 11:41:16 +01:00
|
|
|
|
|
|
|
for (Note* note : _notes)
|
|
|
|
note->layout2();
|
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
QRectF bb;
|
|
|
|
processSiblings([&bb] (Element* e) { bb |= e->bbox().translated(e->pos()); } );
|
2013-05-23 16:58:22 +02:00
|
|
|
setbbox(bb.translated(_spatium*2, 0));
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layoutTablature
|
|
|
|
//---------------------------------------------------------
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
void Chord::layoutTablature()
|
|
|
|
{
|
2015-03-05 00:24:00 +01:00
|
|
|
qreal _spatium = spatium();
|
|
|
|
qreal dotNoteDistance = score()->styleS(StyleIdx::dotNoteDistance).val() * _spatium;
|
|
|
|
qreal minNoteDistance = score()->styleS(StyleIdx::minNoteDistance).val() * _spatium;
|
|
|
|
qreal minTieLength = score()->styleS(StyleIdx::MinTieLength).val() * _spatium;
|
2013-01-02 09:29:17 +01:00
|
|
|
|
2013-10-31 13:45:16 +01:00
|
|
|
for (Chord* c : _graceNotes)
|
|
|
|
c->layoutTablature();
|
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
while (_ledgerLines) {
|
|
|
|
LedgerLine* l = _ledgerLines->next();
|
|
|
|
delete _ledgerLines;
|
|
|
|
_ledgerLines = l;
|
|
|
|
}
|
2013-01-02 14:33:23 +01:00
|
|
|
|
2013-10-31 13:45:16 +01:00
|
|
|
qreal lll = 0.0; // space to leave at left of chord
|
|
|
|
qreal rrr = 0.0; // space to leave at right of chord
|
|
|
|
Note* upnote = upNote();
|
2013-11-11 15:11:28 +01:00
|
|
|
qreal headWidth = symWidth(SymId::noteheadBlack);
|
2014-04-28 18:38:50 +02:00
|
|
|
StaffType* tab = staff()->staffType();
|
2013-10-31 13:45:16 +01:00
|
|
|
qreal lineDist = tab->lineDistance().val() *_spatium;
|
|
|
|
qreal stemX = tab->chordStemPosX(this) *_spatium;
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
int ledgerLines = 0;
|
2016-03-28 13:29:43 +02:00
|
|
|
qreal llY = 0.0;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
int numOfNotes = _notes.size();
|
|
|
|
qreal minY = 1000.0; // just a very large value
|
2013-10-31 13:45:16 +01:00
|
|
|
for (int i = 0; i < numOfNotes; ++i) {
|
2013-05-23 15:39:14 +02:00
|
|
|
Note* note = _notes.at(i);
|
|
|
|
note->layout();
|
|
|
|
// set headWidth to max fret text width
|
|
|
|
qreal fretWidth = note->bbox().width();
|
|
|
|
if (headWidth < fretWidth)
|
|
|
|
headWidth = fretWidth;
|
|
|
|
// centre fret string on stem
|
|
|
|
qreal x = stemX - fretWidth*0.5;
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
qreal y = note->fixed() ? note->line() * lineDist / 2 : tab->physStringToYOffset(note->string()) * _spatium;
|
|
|
|
note->setPos(x, y);
|
|
|
|
if (y < minY)
|
|
|
|
minY = y;
|
|
|
|
int currLedgerLines = tab->numOfTabLedgerLines(note->string());
|
|
|
|
if (currLedgerLines > ledgerLines) {
|
|
|
|
ledgerLines = currLedgerLines;
|
|
|
|
llY = y;
|
|
|
|
}
|
2015-03-05 00:24:00 +01:00
|
|
|
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
// allow extra space for shortened ties; this code must be kept synchronized
|
2015-03-05 00:24:00 +01:00
|
|
|
// with the tie positioning code in Tie::slurPos()
|
|
|
|
// but the allocation of space needs to be performed here
|
|
|
|
Tie* tie;
|
|
|
|
tie = note->tieBack();
|
|
|
|
if (tie) {
|
|
|
|
tie->calculateDirection();
|
|
|
|
qreal overlap = 0.0; // how much tie can overlap start and end notes
|
|
|
|
bool shortStart = false; // whether tie should clear start note or not
|
|
|
|
Note* startNote = tie->startNote();
|
|
|
|
Chord* startChord = startNote->chord();
|
|
|
|
if (startChord && startChord->measure() == measure() && startChord == prevChordRest(this)) {
|
|
|
|
qreal startNoteWidth = startNote->width();
|
|
|
|
// overlap into start chord?
|
|
|
|
// if in start chord, there are several notes or stem and tie in same direction
|
|
|
|
if (startChord->notes().size() > 1 || (startChord->stem() && startChord->up() == tie->up())) {
|
|
|
|
// clear start note (1/8 of fret mark width)
|
|
|
|
shortStart = true;
|
|
|
|
overlap -= startNoteWidth * 0.125;
|
|
|
|
}
|
|
|
|
else // overlap start note (by ca. 1/3 of fret mark width)
|
|
|
|
overlap += startNoteWidth * 0.35;
|
|
|
|
// overlap into end chord (this)?
|
|
|
|
// if several notes or neither stem or tie are up
|
|
|
|
if (notes().size() > 1 || (stem() && !up() && !tie->up())) {
|
|
|
|
// for positive offset:
|
|
|
|
// use available space
|
|
|
|
// for negative x offset:
|
|
|
|
// space is allocated elsewhere, so don't re-allocate here
|
|
|
|
if (note->ipos().x() != 0.0) // this probably does not work for TAB, as
|
|
|
|
overlap += qAbs(note->ipos().x()); // _pos is used to centre the fret on the stem
|
|
|
|
else
|
|
|
|
overlap -= fretWidth * 0.125;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (shortStart)
|
|
|
|
overlap += fretWidth * 0.15;
|
|
|
|
else
|
|
|
|
overlap += fretWidth * 0.35;
|
|
|
|
}
|
|
|
|
qreal d = qMax(minTieLength - overlap, 0.0);
|
|
|
|
lll = qMax(lll, d);
|
|
|
|
}
|
|
|
|
}
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
}
|
2015-03-05 00:24:00 +01:00
|
|
|
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
// create ledger lines, if required (in some historic styles)
|
|
|
|
if (ledgerLines > 0) {
|
|
|
|
// there seems to be no need for widening 'ledger lines' beyond fret mark widths; more 'on the field'
|
|
|
|
// tests and usage will show if this depends on the metrics of the specific fonts used or not.
|
|
|
|
// qreal extraLen = score()->styleS(StyleIdx::ledgerLineLength).val() * _spatium;
|
|
|
|
qreal extraLen = 0;
|
|
|
|
qreal llX = stemX - (headWidth + extraLen) * 0.5;
|
|
|
|
for (int i = 0; i < ledgerLines; i++) {
|
|
|
|
LedgerLine* ldgLin = new LedgerLine(score());
|
|
|
|
ldgLin->setParent(this);
|
|
|
|
ldgLin->setTrack(track());
|
2016-10-20 11:32:07 +02:00
|
|
|
ldgLin->setVisible(visible());
|
2016-09-03 17:45:59 +02:00
|
|
|
ldgLin->setLen(headWidth + extraLen);
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
ldgLin->setPos(llX, llY);
|
|
|
|
ldgLin->setNext(_ledgerLines);
|
|
|
|
_ledgerLines = ldgLin;
|
|
|
|
ldgLin->layout();
|
|
|
|
llY += lineDist / ledgerLines;
|
|
|
|
}
|
|
|
|
headWidth += extraLen; // include ledger lines extra width in chord width
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
|
2013-05-23 15:39:14 +02:00
|
|
|
// horiz. spacing: leave half width at each side of the (potential) stem
|
|
|
|
qreal halfHeadWidth = headWidth * 0.5;
|
|
|
|
if (lll < stemX - halfHeadWidth)
|
|
|
|
lll = stemX - halfHeadWidth;
|
|
|
|
if (rrr < stemX + halfHeadWidth)
|
|
|
|
rrr = stemX + halfHeadWidth;
|
2015-02-25 00:01:28 +01:00
|
|
|
// align dots to the widest fret mark (not needed in all TAB styles, but harmless anyway)
|
|
|
|
if (segment())
|
|
|
|
segment()->setDotPosX(staffIdx(), headWidth);
|
2013-05-23 15:39:14 +02:00
|
|
|
// if tab type is stemless or chord is stemless (possible when imported from MusicXML)
|
2015-05-10 09:58:54 +02:00
|
|
|
// or measure is stemless
|
2013-05-23 15:39:14 +02:00
|
|
|
// or duration longer than half (if halves have stems) or duration longer than crochet
|
|
|
|
// remove stems
|
2015-05-10 09:58:54 +02:00
|
|
|
if (tab->slashStyle() || _noStem || measure()->slashStyle(staffIdx()) || durationType().type() <
|
2014-05-26 19:37:15 +02:00
|
|
|
(tab->minimStyle() != TablatureMinimStyle::NONE ? TDuration::DurationType::V_HALF : TDuration::DurationType::V_QUARTER) ) {
|
2014-08-13 16:36:09 +02:00
|
|
|
if (_stem)
|
|
|
|
score()->undo(new RemoveElement(_stem));
|
|
|
|
if (_hook)
|
|
|
|
score()->undo(new RemoveElement(_hook));
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
|
|
|
// if stem is required but missing, add it;
|
|
|
|
// set stem position (stem length is set in Chord:layoutStem() )
|
|
|
|
else {
|
2015-01-21 11:55:36 +01:00
|
|
|
if (_stem == 0) {
|
|
|
|
Stem* stem = new Stem(score());
|
|
|
|
stem->setParent(this);
|
|
|
|
score()->undo(new AddElement(stem));
|
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
_stem->setPos(tab->chordStemPos(this) * _spatium);
|
|
|
|
if (_hook) {
|
2013-07-11 14:44:35 +02:00
|
|
|
if (beam())
|
|
|
|
score()->undoRemoveElement(_hook);
|
2013-05-23 15:39:14 +02:00
|
|
|
else {
|
|
|
|
_hook->layout();
|
|
|
|
if (rrr < stemX + _hook->width())
|
|
|
|
rrr = stemX + _hook->width();
|
2013-03-04 12:00:02 +01:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
if (!tab->genDurations() // if tab is not set for duration symbols
|
2013-10-31 13:45:16 +01:00
|
|
|
|| track2voice(track()) // or not in first voice
|
|
|
|
|| isGrace()) { // or chord is a grace (no dur. symbols for graces
|
|
|
|
// // wich are not used in hist. tabs anyway)
|
2013-05-23 15:39:14 +02:00
|
|
|
// no tab duration symbols
|
|
|
|
//
|
|
|
|
delete _tabDur; // delete an existing duration symbol
|
|
|
|
_tabDur = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//
|
|
|
|
// tab duration symbols
|
|
|
|
//
|
|
|
|
// check duration of prev. CR segm
|
|
|
|
ChordRest * prevCR = prevChordRest(this);
|
|
|
|
// if no previous CR
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
// OR symbol repeat set to ALWAYS
|
|
|
|
// OR symbol repeat condition is triggered
|
2013-05-23 15:39:14 +02:00
|
|
|
// OR duration type and/or number of dots is different from current CR
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
// OR chord beam mode not AUTO
|
2013-05-23 15:39:14 +02:00
|
|
|
// OR previous CR is a rest
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
// AND no not-stem
|
2013-05-23 15:39:14 +02:00
|
|
|
// set a duration symbol (trying to re-use existing symbols where existing to minimize
|
|
|
|
// symbol creation and deletion)
|
2015-02-04 00:02:28 +01:00
|
|
|
TablatureSymbolRepeat symRepeat = tab->symRepeat();
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
if ( (prevCR == 0
|
2015-02-04 00:02:28 +01:00
|
|
|
|| symRepeat == TablatureSymbolRepeat::ALWAYS
|
|
|
|
|| (symRepeat == TablatureSymbolRepeat::MEASURE && measure() != prevCR->measure())
|
|
|
|
|| (symRepeat == TablatureSymbolRepeat::SYSTEM && measure()->system() != prevCR->measure()->system())
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
|| beamMode() != Beam::Mode::AUTO
|
2015-02-04 00:02:28 +01:00
|
|
|
|| prevCR->durationType().type() != durationType().type()
|
2013-05-23 15:39:14 +02:00
|
|
|
|| prevCR->dots() != dots()
|
TAB - Mixing mensural value symbols and beaming in historic tablatures
__References__: Technology Preview forum post with discussion, screen-shots and links to additional threads https://musescore.org/en/node/81051
Implements the possibility to mix, in TAB's with note symbols at staff side, mensural value symbols (discreet glyphs) with the 'grid'-shaped beaming found in historical sources and commonly used in lute literature.
The beaming is implemented by special drawing of the `TabDurationSymbol` element holding the note value symbol, using drawing primitives instead of the relevant font glyph.
The user may choose between the two renderings (discreet glyph or beaming grid), on a chord-by-chord basis, by setting the chord `BeamMode` (via for instance the relevant palette): `AUTO` selects the glyph rendering, `beam start` the start of the grid and `beam middle` the continuation of the grid beamed to the previous element.
Typographic features of the grid (stem width, stem height and beam thickness) depend on the glyph style and are hard-coded in the style definition. As well as the number of beams for note value, which also depends on the note value style.
Also:
- Implements to possibility to force the display of a note value which would not be rendered by the current note value repetition setting, by setting the chord beam mode to any other value.
- Implements the 'no stem' chord setting for this TAB style, allowing to remove a note value symbol otherwise generated by the current repetition setting.
- Improves the detection of note value font metrics (still not perfect, though, as Qt `QFontMetricsF::tightboundingRect()` returns very approximated results)
- Fixes note value glyph scaling, when the staff scale is modified.
2015-09-27 13:33:05 +02:00
|
|
|
|| prevCR->type() == Element::Type::REST)
|
|
|
|
&& !noStem() ) {
|
2013-05-23 15:39:14 +02:00
|
|
|
// symbol needed; if not exist, create; if exists, update duration
|
|
|
|
if (!_tabDur)
|
|
|
|
_tabDur = new TabDurationSymbol(score(), tab, durationType().type(), dots());
|
|
|
|
else
|
|
|
|
_tabDur->setDuration(durationType().type(), dots(), tab);
|
|
|
|
_tabDur->setParent(this);
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
// _tabDur->setMag(mag()); // useless to set grace mag: graces have no dur. symbol
|
2013-05-23 15:39:14 +02:00
|
|
|
_tabDur->layout();
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
if (minY < 0) { // if some fret extends above tab body (like bass strings)
|
|
|
|
_tabDur->rypos() += minY; // raise duration symbol
|
|
|
|
_tabDur->bbox().translate(0, minY);
|
|
|
|
}
|
2013-05-23 15:39:14 +02:00
|
|
|
}
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
else { // symbol not needed: if exists, delete
|
2013-05-23 15:39:14 +02:00
|
|
|
delete _tabDur;
|
|
|
|
_tabDur = 0;
|
|
|
|
}
|
TAB: Support for input and display of bass string notations
Supports 'standard' configuration for bass string notations in historic tablatures (lutes and other plucked instruments, as well as viols), both of the French and of the Italian style. This should fill the last 'big hole' in historic TAB support.
Bass strings (or bourdons) are extra strings in addition to the 6 'standard' strings, which are not represented by tab lines and were indicated by other typograhic devices in historic sources. Among the innumerable variations shown in sources, this implementation supports the following styles, chosen to be general enough to suit the majority of cases, without requiring new parameters in the TAB style dialogue box:
- French: the first 4 bass courses are indicated by a fret mark in the 'seventh' TAB position (below bottom string) with 0, 1, 2 or 3 slashes prefixed; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 4 on) and cannot contain a fret mark (as they didn't in historic sources).
- Italian: the first 2 bass courses are indicated by a fret mark in the 'seventh' TAB position (abover top string) with 1 or 2 'ledger lines' underneath; other bass courses are indicated, also in the 'seventh' TAB position, by the string number (from 9 on) and cannot contain a fret mark (as they didn't in historic sources). Rhythm marks above these indication are raised to leave room for them.
Both styles do not blindly assume that French style is top-to-bottom and Italian is 'upside-down' -- as historic sources are -- but adapt to the actual string order of the TAB. The choice between the two styles depends on the TAB using numbers or letters for the fret marks.
The implementation does not try to detect if the TAB is really of a historic style and applies either bass string notation whenever more strings are used than there are TAB lines. If this proves unsuitable to modern usage, some better heuristics can probably be found.
For a discussion and some screen shots, see: https://musescore.org/en/node/67261
**Note entry**
During TAB note entry, if the instruments has more strings than the TAB has lines, the string cursor can be moved outside of the TAB body, one position below for 'top-to-bottom' TAB's and one position above for 'upside-down' TAB's.
Further up or down movements add, to the 'blue cursor rectangle', markers indicating which is the actual target string (the cursor does not actually move), equal to the marks a note in that string will receive (slashes, ledger lines or string ordinal, according to the style and the string); during input the user will then receive the same info as when reading entered notes.
Other Notes:
- the `InputStatus::_string` variable, holding the current target TAB string in TAB note entry, changed meaning from the __visual__ string index to the __physical__ string index: this allows a better containment of the peculiarities of the individual TAB styles within the `StaffStyle` class, leaving other classes somehow freer of concern about TAB visual order and other peculiarities. As this variable is only used with TAB's, this change should not affect other functions.
- Some calculation for rhythm symbols have been moved from `TabDurationSymbol::draw()` to `TabDurationSymbol::layout()`, hopefully speeding up the drawing process.
- In fonts for historic styles, '10' has been replaced by 'X' both in fret numbers and in string ordinals, as this is more common in historic sources. Currently, this is not configurable; an additional style parameter could be added in future, if there will be enough request for it.
2015-07-06 17:40:02 +02:00
|
|
|
} // end of if(duration_symbols)
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
if (_arpeggio) {
|
|
|
|
qreal headHeight = upnote->headHeight();
|
|
|
|
_arpeggio->layout();
|
|
|
|
lll += _arpeggio->width() + _spatium * .5;
|
|
|
|
qreal y = upNote()->pos().y() - headHeight * .5;
|
2013-04-26 17:14:37 +02:00
|
|
|
qreal h = downNote()->pos().y() + downNote()->headHeight() - y;
|
2012-05-26 14:26:10 +02:00
|
|
|
_arpeggio->setHeight(h);
|
|
|
|
_arpeggio->setPos(-lll, y);
|
2016-01-20 04:56:13 +01:00
|
|
|
_arpeggio->adjustReadPos();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
// handle the special case of _arpeggio->span() > 1
|
|
|
|
// in layoutArpeggio2() after page layout has done so we
|
|
|
|
// know the y position of the next staves
|
|
|
|
}
|
|
|
|
|
2015-02-04 18:54:03 +01:00
|
|
|
// allocate enough room for glissandi
|
2014-12-13 17:40:39 +01:00
|
|
|
if (_endsGlissando) {
|
2015-02-04 18:54:03 +01:00
|
|
|
if (rtick()) // if not at beginning of measure
|
|
|
|
lll += (0.5 + score()->styleS(StyleIdx::MinTieLength).val()) * _spatium;
|
|
|
|
// special case of system-initial glissando final note is handled in Glissando::layout() itself
|
2014-06-02 20:42:54 +02:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
if (_hook) {
|
2013-03-08 14:59:16 +01:00
|
|
|
if (beam())
|
|
|
|
score()->undoRemoveElement(_hook);
|
2013-03-09 09:58:43 +01:00
|
|
|
else if(tab == 0) {
|
2013-03-04 12:00:02 +01:00
|
|
|
_hook->layout();
|
2013-03-25 12:45:35 +01:00
|
|
|
if (up()) {
|
|
|
|
// hook position is not set yet
|
|
|
|
qreal x = _hook->bbox().right() + stem()->hookPos().x();
|
|
|
|
rrr = qMax(rrr, x);
|
|
|
|
}
|
2013-03-04 12:00:02 +01:00
|
|
|
}
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2015-02-25 09:39:03 +01:00
|
|
|
if (dots()) {
|
|
|
|
qreal x = 0.0;
|
|
|
|
// if stems are beside staff, dots are placed near to stem
|
|
|
|
if (!tab->stemThrough()) {
|
|
|
|
// if there is an unbeamed hook, dots should start after the hook
|
|
|
|
if (_hook && !beam())
|
|
|
|
x = _hook->width() + dotNoteDistance;
|
|
|
|
// if not, dots should start at a fixed distance right after the stem
|
|
|
|
else
|
|
|
|
x = STAFFTYPE_TAB_DEFAULTDOTDIST_X * _spatium;
|
|
|
|
if (segment())
|
|
|
|
segment()->setDotPosX(staffIdx(), x);
|
|
|
|
}
|
|
|
|
// if stems are through staff, use dot position computed above on fret mark widths
|
|
|
|
else
|
|
|
|
x = dotPosX() + dotNoteDistance
|
|
|
|
+ (dots()-1) * score()->styleS(StyleIdx::dotDotDistance).val() * _spatium;
|
|
|
|
x += symWidth(SymId::augmentationDot);
|
|
|
|
rrr = qMax(rrr, x);
|
|
|
|
}
|
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
_spaceLw = lll;
|
|
|
|
_spaceRw = rrr;
|
2013-10-31 13:45:16 +01:00
|
|
|
|
2014-05-26 15:31:36 +02:00
|
|
|
qreal graceMag = score()->styleD(StyleIdx::graceNoteMag);
|
2015-02-19 10:28:25 +01:00
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> graceNotesBefore = Chord::graceNotesBefore();
|
2015-02-19 10:28:25 +01:00
|
|
|
int nb = graceNotesBefore.size();
|
|
|
|
if (nb) {
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal xl = -(_spaceLw + minNoteDistance);
|
2014-04-23 18:07:38 +02:00
|
|
|
for (int i = nb-1; i >= 0; --i) {
|
|
|
|
Chord* c = graceNotesBefore.value(i);
|
2016-01-04 14:48:58 +01:00
|
|
|
xl -= c->_spaceRw/* * 1.2*/;
|
2014-04-23 18:07:38 +02:00
|
|
|
c->setPos(xl, 0);
|
2016-01-04 14:48:58 +01:00
|
|
|
xl -= c->_spaceLw + minNoteDistance * graceMag;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
if (-xl > _spaceLw)
|
|
|
|
_spaceLw = -xl;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> gna = graceNotesAfter();
|
2015-02-19 10:28:25 +01:00
|
|
|
int na = gna.size();
|
|
|
|
if (na) {
|
2014-04-23 18:07:38 +02:00
|
|
|
// get factor for start distance after main note. Values found by testing.
|
|
|
|
qreal fc;
|
|
|
|
switch (durationType().type()) {
|
2014-05-21 15:43:19 +02:00
|
|
|
case TDuration::DurationType::V_LONG: fc = 3.8; break;
|
|
|
|
case TDuration::DurationType::V_BREVE: fc = 3.8; break;
|
|
|
|
case TDuration::DurationType::V_WHOLE: fc = 3.8; break;
|
|
|
|
case TDuration::DurationType::V_HALF: fc = 3.6; break;
|
|
|
|
case TDuration::DurationType::V_QUARTER: fc = 2.1; break;
|
2014-08-15 18:32:48 +02:00
|
|
|
case TDuration::DurationType::V_EIGHTH: fc = 1.4; break;
|
2014-05-21 15:43:19 +02:00
|
|
|
case TDuration::DurationType::V_16TH: fc = 1.2; break;
|
2014-04-23 18:07:38 +02:00
|
|
|
default: fc = 1;
|
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
qreal xr = fc * (_spaceRw + minNoteDistance);
|
2014-04-23 18:07:38 +02:00
|
|
|
for (int i = 0; i <= na - 1; i++) {
|
2015-02-19 10:28:25 +01:00
|
|
|
Chord* c = gna.value(i);
|
2016-01-04 14:48:58 +01:00
|
|
|
xr += c->_spaceLw * (i == 0 ? 1.3 : 1);
|
2014-04-23 18:07:38 +02:00
|
|
|
c->setPos(xr, 0);
|
2016-01-04 14:48:58 +01:00
|
|
|
xr += c->_spaceRw + minNoteDistance * graceMag;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
if (xr > _spaceRw)
|
|
|
|
_spaceRw = xr;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2013-03-25 16:27:20 +01:00
|
|
|
for (Element* e : _el) {
|
2012-05-26 14:26:10 +02:00
|
|
|
e->layout();
|
2014-06-24 18:36:02 +02:00
|
|
|
if (e->type() == Element::Type::CHORDLINE) {
|
2014-06-02 20:42:54 +02:00
|
|
|
QRectF tbbox = e->bbox().translated(e->pos());
|
|
|
|
qreal lx = tbbox.left();
|
|
|
|
qreal rx = tbbox.right();
|
2016-01-04 14:48:58 +01:00
|
|
|
if (-lx > _spaceLw)
|
|
|
|
_spaceLw = -lx;
|
|
|
|
if (rx > _spaceRw)
|
|
|
|
_spaceRw = rx;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-31 13:45:16 +01:00
|
|
|
for (int i = 0; i < numOfNotes; ++i)
|
2013-03-25 16:27:20 +01:00
|
|
|
_notes.at(i)->layout2();
|
2012-07-24 14:20:43 +02:00
|
|
|
QRectF bb;
|
2013-03-25 16:27:20 +01:00
|
|
|
processSiblings([&bb] (Element* e) { bb |= e->bbox().translated(e->pos()); } );
|
2013-05-23 15:39:14 +02:00
|
|
|
if (_tabDur)
|
2012-09-08 01:22:36 +02:00
|
|
|
bb |= _tabDur->bbox().translated(_tabDur->pos());
|
2012-07-24 14:20:43 +02:00
|
|
|
setbbox(bb);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
2013-05-12 12:51:42 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// crossMeasureSetup
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::crossMeasureSetup(bool on)
|
|
|
|
{
|
2013-05-22 15:20:14 +02:00
|
|
|
if (!on) {
|
2014-05-21 15:41:23 +02:00
|
|
|
if (_crossMeasure != CrossMeasure::UNKNOWN) {
|
|
|
|
_crossMeasure = CrossMeasure::UNKNOWN;
|
2013-08-28 10:48:28 +02:00
|
|
|
layoutStem1();
|
|
|
|
}
|
2013-05-12 12:51:42 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-21 15:41:23 +02:00
|
|
|
if (_crossMeasure == CrossMeasure::UNKNOWN) {
|
|
|
|
CrossMeasure tempCross = CrossMeasure::NONE; // assume no cross-measure modification
|
2013-05-12 12:51:42 +02:00
|
|
|
// if chord has only one note and note is tied forward
|
2016-02-06 22:03:43 +01:00
|
|
|
if (notes().size() == 1 && _notes[0]->tieFor()) {
|
2013-05-12 12:51:42 +02:00
|
|
|
Chord* tiedChord = _notes[0]->tieFor()->endNote()->chord();
|
|
|
|
// if tied note belongs to another measure and to a single-note chord
|
2016-02-06 22:03:43 +01:00
|
|
|
if (tiedChord->measure() != measure() && tiedChord->notes().size() == 1) {
|
2013-05-12 12:51:42 +02:00
|
|
|
// get total duration
|
2016-02-06 22:03:43 +01:00
|
|
|
std::vector<TDuration> durList = toDurationList(
|
2013-05-12 12:51:42 +02:00
|
|
|
actualDurationType().fraction() +
|
|
|
|
tiedChord->actualDurationType().fraction(), true);
|
|
|
|
// if duration can be expressed as a single duration
|
|
|
|
// apply cross-measure modification
|
2016-02-06 22:03:43 +01:00
|
|
|
if (durList.size() == 1) {
|
2014-05-21 15:41:23 +02:00
|
|
|
_crossMeasure = tempCross = CrossMeasure::FIRST;
|
2013-05-12 12:51:42 +02:00
|
|
|
_crossMeasureTDur = durList[0];
|
2013-08-28 10:48:28 +02:00
|
|
|
layoutStem1();
|
2013-05-12 12:51:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_crossMeasure = tempCross;
|
2014-05-21 15:41:23 +02:00
|
|
|
tiedChord->setCrossMeasure(tempCross == CrossMeasure::FIRST ?
|
|
|
|
CrossMeasure::SECOND : CrossMeasure::NONE);
|
2013-05-12 12:51:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// layoutArpeggio2
|
|
|
|
// called after layout of page
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::layoutArpeggio2()
|
|
|
|
{
|
|
|
|
if (!_arpeggio)
|
|
|
|
return;
|
2013-11-19 12:12:07 +01:00
|
|
|
qreal y = upNote()->pagePos().y() - upNote()->headHeight() * .5;
|
2012-05-26 14:26:10 +02:00
|
|
|
int span = _arpeggio->span();
|
|
|
|
int btrack = track() + (span - 1) * VOICES;
|
|
|
|
ChordRest* bchord = static_cast<ChordRest*>(segment()->element(btrack));
|
2014-06-24 18:36:02 +02:00
|
|
|
Note* dnote = (bchord && bchord->type() == Element::Type::CHORD) ? static_cast<Chord*>(bchord)->downNote() : downNote();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-11-19 12:12:07 +01:00
|
|
|
qreal h = dnote->pagePos().y() + dnote->headHeight() * .5 - y;
|
2012-05-26 14:26:10 +02:00
|
|
|
_arpeggio->setHeight(h);
|
2013-11-19 12:12:07 +01:00
|
|
|
_arpeggio->layout();
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-11-19 12:12:07 +01:00
|
|
|
#if 0 // collect notes for arpeggio
|
2012-05-26 14:26:10 +02:00
|
|
|
QList<Note*> notes;
|
|
|
|
int n = _notes.size();
|
|
|
|
for (int j = n - 1; j >= 0; --j) {
|
|
|
|
Note* note = _notes[j];
|
|
|
|
if (note->tieBack())
|
|
|
|
continue;
|
|
|
|
notes.prepend(note);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 1; i < span; ++i) {
|
|
|
|
ChordRest* c = static_cast<ChordRest*>(segment()->element(track() + i * VOICES));
|
|
|
|
if (c && c->type() == CHORD) {
|
|
|
|
QList<Note*> nl = static_cast<Chord*>(c)->notes();
|
|
|
|
int n = nl.size();
|
|
|
|
for (int j = n - 1; j >= 0; --j) {
|
|
|
|
Note* note = nl[j];
|
|
|
|
if (note->tieBack())
|
|
|
|
continue;
|
|
|
|
notes.prepend(note);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-19 12:12:07 +01:00
|
|
|
#endif
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// findNote
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Note* Chord::findNote(int pitch) const
|
|
|
|
{
|
2012-12-06 12:46:05 +01:00
|
|
|
int n = _notes.size();
|
|
|
|
for (int i = 0; i < n; ++i) {
|
|
|
|
Note* n = _notes.at(i);
|
2012-05-26 14:26:10 +02:00
|
|
|
if (n->pitch() == pitch)
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// drop
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Element* Chord::drop(const DropData& data)
|
|
|
|
{
|
|
|
|
Element* e = data.element;
|
|
|
|
switch (e->type()) {
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::ARTICULATION:
|
2012-05-26 14:26:10 +02:00
|
|
|
{
|
|
|
|
Articulation* atr = static_cast<Articulation*>(e);
|
|
|
|
Articulation* oa = hasArticulation(atr);
|
|
|
|
if (oa) {
|
|
|
|
delete atr;
|
|
|
|
atr = 0;
|
|
|
|
// if attribute is already there, remove
|
|
|
|
// score()->cmdRemove(oa); // unexpected behaviour?
|
2014-05-27 10:34:08 +02:00
|
|
|
score()->select(oa, SelectType::SINGLE, 0);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
atr->setParent(this);
|
|
|
|
atr->setTrack(track());
|
|
|
|
score()->undoAddElement(atr);
|
|
|
|
}
|
|
|
|
return atr;
|
|
|
|
}
|
2012-11-19 10:08:15 +01:00
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::CHORDLINE:
|
2012-05-26 14:26:10 +02:00
|
|
|
e->setParent(this);
|
2013-02-28 15:06:54 +01:00
|
|
|
e->setTrack(track());
|
2012-05-26 14:26:10 +02:00
|
|
|
score()->undoAddElement(e);
|
|
|
|
break;
|
2012-11-19 10:08:15 +01:00
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::TREMOLO:
|
2012-11-19 10:08:15 +01:00
|
|
|
{
|
|
|
|
Tremolo* t = static_cast<Tremolo*>(e);
|
|
|
|
if (t->twoNotes()) {
|
|
|
|
Segment* s = segment()->next();
|
|
|
|
while (s) {
|
2014-06-24 18:36:02 +02:00
|
|
|
if (s->element(track()) && s->element(track())->type() == Element::Type::CHORD)
|
2012-11-19 10:08:15 +01:00
|
|
|
break;
|
|
|
|
s = s->next();
|
|
|
|
}
|
|
|
|
if (s == 0) {
|
2014-03-25 13:33:47 +01:00
|
|
|
qDebug("no segment for second note of tremolo found");
|
2012-11-19 10:08:15 +01:00
|
|
|
delete e;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Chord* ch2 = static_cast<Chord*>(s->element(track()));
|
2015-02-25 19:55:31 +01:00
|
|
|
if (ch2->duration() != duration()) {
|
|
|
|
qDebug("no matching chord for second note of tremolo found");
|
|
|
|
delete e;
|
|
|
|
return 0;
|
|
|
|
}
|
2012-11-19 10:08:15 +01:00
|
|
|
t->setChords(this, ch2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tremolo())
|
|
|
|
score()->undoRemoveElement(tremolo());
|
|
|
|
e->setParent(this);
|
|
|
|
e->setTrack(track());
|
|
|
|
score()->undoAddElement(e);
|
|
|
|
break;
|
|
|
|
|
2014-06-24 18:36:02 +02:00
|
|
|
case Element::Type::ARPEGGIO:
|
2012-11-20 20:51:18 +01:00
|
|
|
{
|
|
|
|
Arpeggio* a = static_cast<Arpeggio*>(e);
|
2013-04-26 18:40:26 +02:00
|
|
|
if (arpeggio())
|
|
|
|
score()->undoRemoveElement(arpeggio());
|
2013-02-28 17:46:30 +01:00
|
|
|
a->setTrack(track());
|
2012-11-20 20:51:18 +01:00
|
|
|
a->setParent(this);
|
|
|
|
a->setHeight(spatium() * 5); //DEBUG
|
|
|
|
score()->undoAddElement(a);
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
default:
|
|
|
|
return ChordRest::drop(data);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// dotPosX
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::dotPosX() const
|
|
|
|
{
|
2013-05-29 17:11:57 +02:00
|
|
|
if (parent())
|
2013-05-28 23:24:49 +02:00
|
|
|
return segment()->dotPosX(staffIdx());
|
|
|
|
return -1000.0;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// getProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QVariant Chord::getProperty(P_ID propertyId) const
|
|
|
|
{
|
2016-05-25 19:48:18 +02:00
|
|
|
switch (propertyId) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::NO_STEM: return noStem();
|
|
|
|
case P_ID::SMALL: return small();
|
2016-05-20 10:09:11 +02:00
|
|
|
case P_ID::STEM_DIRECTION: return stemDirection();
|
2012-05-26 14:26:10 +02:00
|
|
|
default:
|
|
|
|
return ChordRest::getProperty(propertyId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-14 13:30:25 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// propertyDefault
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QVariant Chord::propertyDefault(P_ID propertyId) const
|
|
|
|
{
|
2016-05-25 19:48:18 +02:00
|
|
|
switch (propertyId) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::NO_STEM: return false;
|
|
|
|
case P_ID::SMALL: return false;
|
2016-07-10 12:00:57 +02:00
|
|
|
case P_ID::STEM_DIRECTION: return Direction_AUTO;
|
2013-03-14 13:30:25 +01:00
|
|
|
default:
|
2014-08-30 05:28:43 +02:00
|
|
|
return ChordRest::propertyDefault(propertyId);
|
2013-03-14 13:30:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// setProperty
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool Chord::setProperty(P_ID propertyId, const QVariant& v)
|
|
|
|
{
|
2016-05-25 19:48:18 +02:00
|
|
|
switch (propertyId) {
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::NO_STEM:
|
2012-05-26 14:26:10 +02:00
|
|
|
setNoStem(v.toBool());
|
|
|
|
break;
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::SMALL:
|
2012-05-26 14:26:10 +02:00
|
|
|
setSmall(v.toBool());
|
|
|
|
break;
|
2014-05-26 18:18:01 +02:00
|
|
|
case P_ID::STEM_DIRECTION:
|
2016-05-20 10:09:11 +02:00
|
|
|
setStemDirection(v.value<Direction>());
|
2012-05-26 14:26:10 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ChordRest::setProperty(propertyId, v);
|
|
|
|
}
|
2016-06-14 10:32:34 +02:00
|
|
|
triggerLayout();
|
2012-05-26 14:26:10 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// layoutArticulation
|
2016-10-06 12:21:28 +02:00
|
|
|
// called from ChordRest()->layoutArticulations()
|
2012-05-26 14:26:10 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
QPointF Chord::layoutArticulation(Articulation* a)
|
|
|
|
{
|
2013-03-09 09:58:43 +01:00
|
|
|
qreal _spatium = spatium();
|
2016-04-06 15:28:10 +02:00
|
|
|
qreal pld = staff()->lineDistance();
|
|
|
|
qreal lld = staff()->logicalLineDistance();
|
|
|
|
bool scale = staff()->scaleNotesToLines();
|
2015-09-01 20:18:28 +02:00
|
|
|
qreal _spStaff = _spatium * pld; // scaled to physical staff line distance
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
ArticulationAnchor aa = a->anchor();
|
|
|
|
|
|
|
|
qreal chordTopY = upPos(); // note position of highest note
|
|
|
|
qreal chordBotY = downPos(); // note position of lowest note
|
|
|
|
qreal x = centerX();
|
2016-04-06 15:28:10 +02:00
|
|
|
qreal y = 0.0;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2016-05-03 01:21:42 +02:00
|
|
|
// TENUTO and STACCATO: always near the notehead (or stem end if beyond a stem)
|
2016-10-06 12:21:28 +02:00
|
|
|
if ((a->isTenuto() || a->isStaccato() || a->isAccent())
|
|
|
|
&& (aa != ArticulationAnchor::TOP_STAFF && aa != ArticulationAnchor::BOTTOM_STAFF)) {
|
2013-03-09 09:58:43 +01:00
|
|
|
bool bottom; // true: artic. is below chord | false: artic. is above chord
|
2014-12-28 23:41:09 +01:00
|
|
|
bool alignToStem = false;
|
2013-03-09 09:58:43 +01:00
|
|
|
// if there area voices, articulation is on stem side
|
2014-05-21 15:37:28 +02:00
|
|
|
if ((aa == ArticulationAnchor::CHORD) && measure()->hasVoices(a->staffIdx()))
|
2012-05-26 14:26:10 +02:00
|
|
|
bottom = !up();
|
2013-03-09 09:58:43 +01:00
|
|
|
// otherwise, look at specific anchor type (and at chord up/down if necessary)
|
2012-05-26 14:26:10 +02:00
|
|
|
else
|
2014-05-21 15:37:28 +02:00
|
|
|
bottom = (aa == ArticulationAnchor::BOTTOM_CHORD) || (aa == ArticulationAnchor::CHORD && up());
|
2013-03-09 09:58:43 +01:00
|
|
|
bool stemSide = (bottom != up()) && stem(); // true if there a stem between the nearest note and the articulation
|
2012-05-26 14:26:10 +02:00
|
|
|
a->setUp(!bottom);
|
|
|
|
|
2013-03-09 09:58:43 +01:00
|
|
|
QPointF pos; // computed articulation position
|
|
|
|
if (stem()) // if there is a stem, assume artic. will be beyond the stem
|
2012-05-26 14:26:10 +02:00
|
|
|
pos = stem()->hookPos();
|
2014-07-22 04:09:25 +02:00
|
|
|
else { // otherwise, compute horizontal position as if there were a stem
|
|
|
|
pos.rx() = stemPosX();
|
|
|
|
if (!_up)
|
2016-03-19 11:41:38 +01:00
|
|
|
pos.rx() += score()->styleP(StyleIdx::stemWidth);
|
2014-07-22 04:09:25 +02:00
|
|
|
}
|
2014-04-23 16:57:52 +02:00
|
|
|
a->layout();
|
2014-04-28 18:38:50 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
qreal _spatium2 = _spatium * .5;
|
2013-03-09 09:58:43 +01:00
|
|
|
qreal _spStaff2 = _spStaff * .5;
|
|
|
|
if (stemSide) { // if artic. is really beyond a stem,
|
2015-09-01 20:18:28 +02:00
|
|
|
qreal lineDelta = up() ? -_spStaff2 : _spStaff2; // move it 1/2sp away from stem
|
|
|
|
int line = lrint((pos.y() + lineDelta) / _spStaff); // round to nearest staff line
|
2013-03-09 09:58:43 +01:00
|
|
|
if (line >= 0 && line <= staff()->lines()-1) // if within staff, align between staff lines
|
|
|
|
pos.ry() = (line * _spStaff) + (bottom ? _spStaff2 : -_spStaff2);
|
|
|
|
else { // if outside staff, add some more space (?)
|
2014-05-26 15:31:36 +02:00
|
|
|
qreal dy = (score()->styleS(StyleIdx::beamWidth).val() + 1) * _spatium2;
|
2012-05-26 14:26:10 +02:00
|
|
|
pos.ry() += bottom ? dy : - dy;
|
|
|
|
}
|
2016-10-06 12:21:28 +02:00
|
|
|
alignToStem = a->isStaccato() && articulations().size() == 1;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-03-09 09:58:43 +01:00
|
|
|
else { // if articulation is not beyond a stem
|
2015-09-01 20:18:28 +02:00
|
|
|
int lline; // logical line of note
|
|
|
|
int line; // physical line of note
|
2015-08-10 06:54:24 +02:00
|
|
|
int staffOff; // offset that should account for line spacing
|
2015-09-01 20:18:28 +02:00
|
|
|
int extraOff = 0; // offset that should not acocunt for line spacing
|
2015-08-10 06:54:24 +02:00
|
|
|
int lines = (staff()->lines() - 1) * 2; // num. of staff positions within staff
|
2016-10-06 12:21:28 +02:00
|
|
|
int add = a->isAccent() ? 1 : 0; // sforzato accent needs more offset
|
2013-03-09 09:58:43 +01:00
|
|
|
if (bottom) { // if below chord
|
2015-09-01 20:18:28 +02:00
|
|
|
lline = downLine(); // logical line of chord lowest note
|
|
|
|
line = scale ? lline : lline * (lld / pld); // corresponding physical line
|
2013-03-09 09:58:43 +01:00
|
|
|
if (line < lines) // if note above staff bottom line
|
2015-08-10 06:54:24 +02:00
|
|
|
staffOff = 3 - ((line - add) & 1) + add; // round to next space below
|
2013-03-09 09:58:43 +01:00
|
|
|
else // if note on or below staff bottom line,
|
2015-08-10 06:54:24 +02:00
|
|
|
staffOff = 2 + add; // move 1 whole space below
|
2015-09-01 20:18:28 +02:00
|
|
|
if (pld != 1.0) {
|
|
|
|
// on staves with non-standard line spacing
|
|
|
|
// we need to consider line spacing for the portion of the offset that is within staff or ledger lines
|
|
|
|
// but not for any offset beyond that
|
|
|
|
int clearLine = qMax(line, lines); // line we need to clear
|
|
|
|
int headRoom = qMax(clearLine - line, 0); // amount of room between note and line we need to clear
|
|
|
|
extraOff = staffOff - qMin(staffOff, headRoom); // amount by which we do not need to consider line distance
|
|
|
|
staffOff -= extraOff; // amount by which we need to consider line distance
|
|
|
|
if (!scale && lline > clearLine * pld)
|
|
|
|
extraOff += lline - floor(line * pld); // adjust for rounding of physical line
|
2015-08-10 06:54:24 +02:00
|
|
|
}
|
2014-04-23 16:57:52 +02:00
|
|
|
pos.ry() = -a->height() / 2; // symbol is below baseline, shift if a bit up
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2013-03-09 09:58:43 +01:00
|
|
|
else { // if above chord
|
2015-09-01 20:18:28 +02:00
|
|
|
lline = upLine(); // logical line of chord highest note
|
|
|
|
line = scale ? lline : lline * (lld / pld); // corresponding physical line
|
2013-03-09 09:58:43 +01:00
|
|
|
if (line > 0) // if note below staff top line
|
2015-08-10 06:54:24 +02:00
|
|
|
staffOff = -3 + ((line + add) & 1) - add; // round to next space above
|
2013-03-09 09:58:43 +01:00
|
|
|
else // if note or or above staff top line
|
2015-08-10 06:54:24 +02:00
|
|
|
staffOff = -2 - add; // move 1 whole space above
|
2015-09-01 20:18:28 +02:00
|
|
|
if (pld != 1.0) {
|
|
|
|
// see corresponding code above
|
2015-08-10 06:54:24 +02:00
|
|
|
int clearLine = qMin(line, 0);
|
|
|
|
int headRoom = qMax(line - clearLine, 0);
|
|
|
|
extraOff = staffOff + qMin(-staffOff, headRoom);
|
|
|
|
staffOff -= extraOff;
|
2015-09-01 20:18:28 +02:00
|
|
|
if (!scale && lline < clearLine * pld)
|
|
|
|
extraOff += lline - ceil(line * pld);
|
2015-08-10 06:54:24 +02:00
|
|
|
}
|
2014-04-23 16:57:52 +02:00
|
|
|
pos.ry() = a->height() / 2; // symbol is on baseline, shift it a bit down
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
2015-09-01 20:18:28 +02:00
|
|
|
pos.ry() += (line + staffOff) * _spStaff2; // offset that needs to account for line distance
|
|
|
|
pos.ry() += extraOff * _spatium2; // additional offset that need not account for line distance
|
2014-10-15 18:21:04 +02:00
|
|
|
}
|
2014-12-28 23:41:09 +01:00
|
|
|
if (!staff()->isTabStaff() && !alignToStem) {
|
2014-10-15 18:21:04 +02:00
|
|
|
if (up())
|
|
|
|
pos.rx() -= upNote()->headWidth() * .5; // move half-a-note-head to left
|
|
|
|
else
|
|
|
|
pos.rx() += upNote()->headWidth() * .5; // move half-a-note-head to right
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
a->setPos(pos);
|
|
|
|
a->adjustReadPos();
|
|
|
|
return QPointF(pos);
|
|
|
|
}
|
|
|
|
|
2014-09-08 19:03:20 +02:00
|
|
|
// Lute fingering are always in the middle of the space right below the fret mark,
|
2016-10-06 12:21:28 +02:00
|
|
|
else if (staff() && staff()->staffGroup() == StaffGroup::TAB && a->isLuteFingering()) {
|
2014-09-08 19:03:20 +02:00
|
|
|
// lute fing. glyphs are vertically registered in the middle of bottom space;
|
|
|
|
// move down of half a space to have the glyph on the line
|
|
|
|
y = chordBotY + _spatium * 0.5;
|
|
|
|
if (staff()->staffType()->onLines()) { // if fret marks are on lines
|
|
|
|
// move down by half the height of fret marks (extending below the line)
|
|
|
|
// and half of the remaing space below,
|
|
|
|
// to centre the symbol between the fret mark and the line below
|
|
|
|
// fretBoxH/2 + (spStaff - fretBoxH/2) / 2 becomes:
|
|
|
|
y += (staff()->staffType()->fretBoxH()*0.5 + _spStaff) * 0.5;
|
|
|
|
}
|
|
|
|
else { // if marks are between lines
|
|
|
|
// move down by half a sp to pace the glyph right below the mark,
|
|
|
|
// and not too far away (as it would have been, if centred in the line space below)
|
|
|
|
y += _spatium * 0.5;
|
|
|
|
}
|
|
|
|
a->layout();
|
|
|
|
a->setPos(x, y);
|
|
|
|
a->adjustReadPos();
|
|
|
|
return QPointF(x, y);
|
|
|
|
}
|
|
|
|
|
2013-03-09 09:58:43 +01:00
|
|
|
// other articulations are outside of area occupied by the staff or the chord
|
2012-05-26 14:26:10 +02:00
|
|
|
// reserve space for slur
|
|
|
|
bool botGap = false;
|
|
|
|
bool topGap = false;
|
2013-08-14 10:49:39 +02:00
|
|
|
|
2016-01-13 20:13:08 +01:00
|
|
|
auto si = score()->spannerMap().findOverlapping(tick(), tick());
|
|
|
|
for (auto is : si) {
|
2013-08-14 10:49:39 +02:00
|
|
|
Spanner* sp = is.value;
|
2014-06-24 18:36:02 +02:00
|
|
|
if ((sp->type() != Element::Type::SLUR) || (sp->tick() != tick() && sp->tick2() != tick()))
|
2012-05-26 14:26:10 +02:00
|
|
|
continue;
|
2014-02-12 21:52:03 +01:00
|
|
|
if ( sp->tick() == tick() && sp->track() != track())
|
|
|
|
continue;
|
|
|
|
if ( sp->tick2() == tick() && sp->track2() != track())
|
|
|
|
continue;
|
2012-05-26 14:26:10 +02:00
|
|
|
Slur* s = static_cast<Slur*>(sp);
|
|
|
|
if (s->up())
|
|
|
|
topGap = true;
|
|
|
|
else
|
|
|
|
botGap = true;
|
|
|
|
}
|
2013-08-14 10:49:39 +02:00
|
|
|
|
2012-05-26 14:26:10 +02:00
|
|
|
if (botGap)
|
2015-08-10 06:54:24 +02:00
|
|
|
chordBotY += _spatium;
|
2012-05-26 14:26:10 +02:00
|
|
|
else
|
2015-08-10 06:54:24 +02:00
|
|
|
chordBotY += _spatium * .5;
|
2012-05-26 14:26:10 +02:00
|
|
|
if (topGap)
|
2015-08-10 06:54:24 +02:00
|
|
|
chordTopY -= _spatium;
|
2012-05-26 14:26:10 +02:00
|
|
|
else
|
2015-08-10 06:54:24 +02:00
|
|
|
chordTopY -= _spatium * .5;
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
// avoid collisions of staff articulations with chord notes:
|
|
|
|
// gap between note and staff articulation is distance0 + 0.5 spatium
|
|
|
|
|
2013-03-09 09:58:43 +01:00
|
|
|
qreal staffTopY = 0; // top of occupied area
|
|
|
|
qreal staffBotY = staff()->height(); // bottom of occupied area
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-03-09 09:58:43 +01:00
|
|
|
if (stem()) { // if there is a stem, occupied area may be larger
|
2012-05-26 14:26:10 +02:00
|
|
|
#if 0
|
|
|
|
y = stem()->pos().y() + pos().y();
|
|
|
|
if (up() && stem()->stemLen() < 0.0)
|
|
|
|
y += stem()->stemLen();
|
|
|
|
else if (!up() && stem()->stemLen() > 0.0)
|
|
|
|
y -= stem()->stemLen();
|
|
|
|
#endif
|
2013-03-09 09:58:43 +01:00
|
|
|
y = stem()->hookPos().y() + pos().y(); // vert. pos. of end of stem
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2013-03-09 09:58:43 +01:00
|
|
|
if (beam()) { // if there is a beam, stem end is further away
|
2016-03-19 11:41:38 +01:00
|
|
|
qreal bw = score()->styleP(StyleIdx::beamWidth);
|
2012-05-26 14:26:10 +02:00
|
|
|
y += up() ? -bw : bw;
|
|
|
|
}
|
2013-03-09 09:58:43 +01:00
|
|
|
if (up()) // if up chord, top is topmost between staff top and stem end
|
2012-05-26 14:26:10 +02:00
|
|
|
staffTopY = qMin(staffTopY, y);
|
2013-03-09 09:58:43 +01:00
|
|
|
else // if chord is down, bottom is bottommost btw staff bottom and stem end
|
2012-05-26 14:26:10 +02:00
|
|
|
staffBotY = qMax(staffBotY, y);
|
|
|
|
}
|
|
|
|
|
2013-03-09 09:58:43 +01:00
|
|
|
staffTopY = qMin(staffTopY, qreal(chordTopY)); // top is topmost between staff top and chord stop
|
|
|
|
staffBotY = qMax(staffBotY, qreal(chordBotY)); // bottom is bottom between staff bottom and chord bottom
|
2012-05-26 14:26:10 +02:00
|
|
|
|
|
|
|
//
|
2016-03-02 13:20:19 +01:00
|
|
|
// determine Direction
|
2012-05-26 14:26:10 +02:00
|
|
|
//
|
2016-07-10 12:00:57 +02:00
|
|
|
if (a->direction() != Direction_AUTO) {
|
|
|
|
a->setUp(a->direction() == Direction_UP);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (measure()->hasVoices(a->staffIdx())) {
|
|
|
|
a->setUp(up());
|
2014-05-21 15:37:28 +02:00
|
|
|
aa = up() ? ArticulationAnchor::TOP_STAFF : ArticulationAnchor::BOTTOM_STAFF;
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
else {
|
2014-05-21 15:37:28 +02:00
|
|
|
if (aa == ArticulationAnchor::CHORD)
|
2012-05-26 14:26:10 +02:00
|
|
|
a->setUp(!up());
|
|
|
|
else
|
2014-05-21 15:37:28 +02:00
|
|
|
a->setUp(aa == ArticulationAnchor::TOP_STAFF || aa == ArticulationAnchor::TOP_CHORD);
|
2012-05-26 14:26:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-06 12:21:28 +02:00
|
|
|
qreal dist; // distance between occupied area and articulation
|
|
|
|
if (a->symId() == SymId::articMarcatoAbove || a->symId() == SymId::articMarcatoBelow)
|
|
|
|
dist = 1.0 * _spatium;
|
|
|
|
else if (a->isAccent())
|
|
|
|
dist = 1.5 * _spatium;
|
|
|
|
else
|
|
|
|
dist = score()->styleP(StyleIdx::propertyDistance);
|
2012-05-26 14:26:10 +02:00
|
|
|
|
2014-05-21 15:37:28 +02:00
|
|
|
if (aa == ArticulationAnchor::CHORD || aa == ArticulationAnchor::TOP_CHORD || aa == ArticulationAnchor::BOTTOM_CHORD) {
|
2012-05-26 14:26:10 +02:00
|
|
|
bool bottom;
|
2014-05-21 15:37:28 +02:00
|
|
|
if ((aa == ArticulationAnchor::CHORD) && measure()->hasVoices(a->staffIdx()))
|
2012-05-26 14:26:10 +02:00
|
|
|
bottom = !up();
|
|
|
|
else
|
2014-05-21 15:37:28 +02:00
|
|
|
bottom = (aa == ArticulationAnchor::BOTTOM_CHORD) || (aa == ArticulationAnchor::CHORD && up());
|
2012-05-26 14:26:10 +02:00
|
|
|
y = bottom ? chordBotY + dist : chordTopY - dist;
|
|
|
|
}
|
2014-05-21 15:37:28 +02:00
|
|
|
else if (aa == ArticulationAnchor::TOP_STAFF || aa == ArticulationAnchor::BOTTOM_STAFF) {
|
2012-05-26 14:26:10 +02:00
|
|
|
y = a->up() ? staffTopY - dist : staffBotY + dist;
|
|
|
|
}
|
2014-03-29 20:09:00 +01:00
|
|
|
a->layout();
|
2012-05-26 14:26:10 +02:00
|
|
|
a->setPos(x, y);
|
|
|
|
a->adjustReadPos();
|
|
|
|
return QPointF(x, y);
|
|
|
|
}
|
2012-08-23 17:40:04 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2012-11-19 10:08:15 +01:00
|
|
|
// reset
|
2012-08-23 17:40:04 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2012-11-19 10:08:15 +01:00
|
|
|
void Chord::reset()
|
2012-08-23 17:40:04 +02:00
|
|
|
{
|
2016-07-10 12:00:57 +02:00
|
|
|
undoChangeProperty(P_ID::STEM_DIRECTION, Direction_AUTO);
|
2016-06-09 09:26:13 +02:00
|
|
|
undoChangeProperty(P_ID::BEAM_MODE, int(Beam::Mode::AUTO));
|
2013-07-01 16:28:39 +02:00
|
|
|
score()->createPlayEvents(this);
|
2012-11-19 10:08:15 +01:00
|
|
|
ChordRest::reset();
|
2012-08-23 17:40:04 +02:00
|
|
|
}
|
|
|
|
|
2014-11-15 21:28:16 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// slash
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
bool Chord::slash()
|
|
|
|
{
|
|
|
|
Note* n = upNote();
|
2014-11-26 01:59:57 +01:00
|
|
|
return n->fixed();
|
2014-11-15 21:28:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// setSlash
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::setSlash(bool flag, bool stemless)
|
|
|
|
{
|
|
|
|
int line = 0;
|
2014-11-26 01:59:57 +01:00
|
|
|
NoteHead::Group head = NoteHead::Group::HEAD_SLASH;
|
2014-11-15 21:28:16 +01:00
|
|
|
|
|
|
|
if (!flag) {
|
|
|
|
// restore to normal
|
|
|
|
undoChangeProperty(P_ID::NO_STEM, false);
|
|
|
|
undoChangeProperty(P_ID::SMALL, false);
|
|
|
|
undoChangeProperty(P_ID::USER_OFF, QPointF());
|
|
|
|
for (Note* n : _notes) {
|
|
|
|
n->undoChangeProperty(P_ID::HEAD_GROUP, int(NoteHead::Group::HEAD_NORMAL));
|
|
|
|
n->undoChangeProperty(P_ID::FIXED, false);
|
|
|
|
n->undoChangeProperty(P_ID::FIXED_LINE, 0);
|
|
|
|
n->undoChangeProperty(P_ID::PLAY, true);
|
|
|
|
n->undoChangeProperty(P_ID::VISIBLE, true);
|
2014-11-26 01:59:57 +01:00
|
|
|
if (staff()->isDrumStaff()) {
|
2015-03-13 11:16:43 +01:00
|
|
|
const Drumset* ds = part()->instrument()->drumset();
|
2014-11-26 01:59:57 +01:00
|
|
|
int pitch = n->pitch();
|
|
|
|
if (ds && ds->isValid(pitch)) {
|
2016-07-10 12:00:57 +02:00
|
|
|
undoChangeProperty(P_ID::STEM_DIRECTION, ds->stemDirection(pitch));
|
2016-05-20 11:33:22 +02:00
|
|
|
n->undoChangeProperty(P_ID::HEAD_GROUP, int(ds->noteHead(pitch)));
|
2014-11-26 01:59:57 +01:00
|
|
|
}
|
|
|
|
}
|
2014-11-15 21:28:16 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// set stem to auto (mostly important for rhythmic notation on drum staves)
|
2016-07-10 12:00:57 +02:00
|
|
|
undoChangeProperty(P_ID::STEM_DIRECTION, Direction_AUTO);
|
2014-11-15 21:28:16 +01:00
|
|
|
|
|
|
|
// make stemless if asked
|
|
|
|
if (stemless)
|
|
|
|
undoChangeProperty(P_ID::NO_STEM, true);
|
|
|
|
|
2014-11-26 01:59:57 +01:00
|
|
|
// voice-dependent attributes - line, size, offset, head
|
2014-11-15 21:28:16 +01:00
|
|
|
if (track() % VOICES < 2) {
|
|
|
|
// use middle line
|
2015-09-01 06:19:20 +02:00
|
|
|
line = staff()->middleLine();
|
2014-11-15 21:28:16 +01:00
|
|
|
}
|
|
|
|
else {
|
2014-11-26 01:59:57 +01:00
|
|
|
// set small
|
|
|
|
undoChangeProperty(P_ID::SMALL, true);
|
2014-11-15 21:28:16 +01:00
|
|
|
// set outside the staff
|
|
|
|
qreal y = 0.0;
|
|
|
|
if (track() % 2) {
|
2015-09-01 06:19:20 +02:00
|
|
|
line = staff()->bottomLine() + 1;
|
2016-06-05 10:23:37 +02:00
|
|
|
y = 0.5 * spatium();
|
2014-11-15 21:28:16 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
line = -1;
|
2014-11-26 01:59:57 +01:00
|
|
|
if (!staff()->isDrumStaff())
|
2015-09-01 06:19:20 +02:00
|
|
|
y = -0.5 * spatium();
|
2014-11-15 21:28:16 +01:00
|
|
|
}
|
2014-11-26 01:59:57 +01:00
|
|
|
// for non-drum staves, add an additional offset
|
|
|
|
// for drum staves, no offset, but use normal head
|
|
|
|
if (!staff()->isDrumStaff())
|
|
|
|
undoChangeProperty(P_ID::USER_OFF, QPointF(0.0, y));
|
|
|
|
else
|
|
|
|
head = NoteHead::Group::HEAD_NORMAL;
|
2014-11-15 21:28:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int ns = _notes.size();
|
|
|
|
for (int i = 0; i < ns; ++i) {
|
|
|
|
Note* n = _notes[i];
|
2014-11-26 01:59:57 +01:00
|
|
|
n->undoChangeProperty(P_ID::HEAD_GROUP, static_cast<int>(head));
|
2014-11-15 21:28:16 +01:00
|
|
|
n->undoChangeProperty(P_ID::FIXED, true);
|
|
|
|
n->undoChangeProperty(P_ID::FIXED_LINE, line);
|
|
|
|
n->undoChangeProperty(P_ID::PLAY, false);
|
|
|
|
// hide all but first notehead
|
|
|
|
if (i)
|
|
|
|
n->undoChangeProperty(P_ID::VISIBLE, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Fixes #19155, #22861 (duplicate of the former) and #23100.
__References__:
Issues: https://musescore.org/en/node/19155 https://musescore.org/en/node/22861 https://musescore.org/en/node/23100
__Description__:
Allows to change the start and end note to which a glissando is anchored after it has been entered. Either anchor can be changed independently.
The user interface follows the current working of other 'snappable' lines. Once either the start or end grip is selected:
- `[Shift]+[Left]` snaps the anchor to the previous chord, defaulting to its top note.
- `[Shift]+[Right]` snaps to the next chord, defaulting to its top note.
- `[Shift]+[Up]` snaps to the note above (possibly in a chord, voice or staff above the current one).
- `[Shift]+[Down]` snaps to the note below (possibly in a chord, voice or staff below the current one).
This permits to set the anchor points of a glissando to any note in the score, allowing several glissandi between the notes of the same two chords and other complex configurations (glissandi skipping intermediate chords, start and end notes in different voices or staves, and so on).
It is possible to move the anchor to a different staff of the same instrument, but not to a different instrument; also, it is not possible to 'cross' a change of instrument in the same staff.
__Known limitations__:
- The `[Shift]+[Up]` and `[Shift]+[Down]` use the same note-finding functions as the `[Alt]+[Up]` and `[Alt]+[Down]`actions which move the selection cursor to the above and below note, even across voices or staves. Occasionally, in particular if the note immediately above or below is not time-aligned, the algorithm has little expected results; however, the behaviour is already known to the user. Improving the algorithm would benefit both uses.
__Notes__:
- Most of the added infrastructure is not specific to glissando but to any spanner anchored to notes, then it should also add after-the-fact "snap to" note support to note-anchored text line.
- When moving an anchor, the algorithm usually prefers a note in the same voice/staff of the old note if it exists; if there is none, it tries other voices of the same staff.
- The change of anchor is undoable.
- The fix corrects the management of the `Chord::_endsGlissando` flag, taking into account that a chord can be the ending point of several glissandi and removing one of them not necessarily means the chord no longer ends a glissando (another glissando may still exists).
- The fix also improved the rendering of the glissando wavy line, with better alignment with anchor notes and, with glissando text, better text-line spacing.
2015-08-06 11:11:16 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// updateEndsGlissando
|
|
|
|
// sets/resets the chord _endsGlissando according any glissando (or more)
|
|
|
|
// end into this chord or no.
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::updateEndsGlissando()
|
|
|
|
{
|
|
|
|
_endsGlissando = false; // assume no glissando ends here
|
|
|
|
// scan all chord notes for glissandi ending on this chord
|
|
|
|
for (Note* note : notes()) {
|
|
|
|
for (Spanner* sp : note->spannerBack())
|
|
|
|
if (sp->type() == Element::Type::GLISSANDO) {
|
|
|
|
_endsGlissando = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-27 04:03:47 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// removeMarkings
|
|
|
|
// - this is normally called after cloning a chord to tie a note over the barline
|
|
|
|
// - there is no special undo handling; the assumption is that undo will simply remove the cloned chord
|
|
|
|
// - two note tremolos are converted into simple notes
|
|
|
|
// - single note tremolos are optionally retained
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::removeMarkings(bool keepTremolo)
|
|
|
|
{
|
|
|
|
if (tremolo() && !keepTremolo)
|
|
|
|
remove(tremolo());
|
|
|
|
if (arpeggio())
|
|
|
|
remove(arpeggio());
|
|
|
|
for (Element* e : el())
|
|
|
|
remove(e);
|
|
|
|
for (Element* e : articulations())
|
|
|
|
remove(e);
|
2016-08-17 12:52:35 +02:00
|
|
|
for (Element* e : lyrics())
|
2015-05-27 04:03:47 +02:00
|
|
|
remove(e);
|
|
|
|
for (Element* e : graceNotes())
|
|
|
|
remove(e);
|
|
|
|
for (Note* n : notes()) {
|
|
|
|
for (Element* e : n->el())
|
|
|
|
n->remove(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-28 15:42:02 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// mag
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
qreal Chord::mag() const
|
|
|
|
{
|
2013-05-28 16:55:02 +02:00
|
|
|
qreal m = staff() ? staff()->mag() : 1.0;
|
2013-05-28 15:42:02 +02:00
|
|
|
if (small())
|
2014-05-26 15:31:36 +02:00
|
|
|
m *= score()->styleD(StyleIdx::smallNoteMag);
|
2014-05-27 10:35:28 +02:00
|
|
|
if (_noteType != NoteType::NORMAL)
|
2014-05-26 15:31:36 +02:00
|
|
|
m *= score()->styleD(StyleIdx::graceNoteMag);
|
2013-05-28 15:42:02 +02:00
|
|
|
return m;
|
|
|
|
}
|
2013-06-10 21:13:04 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// segment
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Segment* Chord::segment() const
|
|
|
|
{
|
|
|
|
Element* e = parent();
|
2014-06-24 18:36:02 +02:00
|
|
|
for (; e && e->type() != Element::Type::SEGMENT; e = e->parent())
|
2013-06-10 21:13:04 +02:00
|
|
|
;
|
|
|
|
return static_cast<Segment*>(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// measure
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Measure* Chord::measure() const
|
|
|
|
{
|
|
|
|
Element* e = parent();
|
2014-06-24 18:36:02 +02:00
|
|
|
for (; e && e->type() != Element::Type::MEASURE; e = e->parent())
|
2013-06-10 21:13:04 +02:00
|
|
|
;
|
|
|
|
return static_cast<Measure*>(e);
|
|
|
|
}
|
2013-06-16 23:33:37 +02:00
|
|
|
|
2014-04-23 18:07:38 +02:00
|
|
|
//---------------------------------------------------------
|
2015-02-19 10:28:25 +01:00
|
|
|
// graceNotesBefore
|
2014-04-23 18:07:38 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> Chord::graceNotesBefore() const
|
2014-04-23 18:07:38 +02:00
|
|
|
{
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> cl;
|
2015-02-19 10:28:25 +01:00
|
|
|
for (Chord* c : _graceNotes) {
|
2016-02-15 12:23:28 +01:00
|
|
|
if (c->noteType() & (NoteType::ACCIACCATURA
|
|
|
|
| NoteType::APPOGGIATURA
|
|
|
|
| NoteType::GRACE4
|
|
|
|
| NoteType::GRACE16
|
|
|
|
| NoteType::GRACE32))
|
2016-02-06 22:03:43 +01:00
|
|
|
cl.push_back(c);
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2015-02-19 10:28:25 +01:00
|
|
|
return cl;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
2015-02-19 10:28:25 +01:00
|
|
|
// graceNotesAfter
|
2014-04-23 18:07:38 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> Chord::graceNotesAfter() const
|
2014-04-23 18:07:38 +02:00
|
|
|
{
|
2016-02-06 22:03:43 +01:00
|
|
|
QVector<Chord*> cl;
|
|
|
|
for (int i = _graceNotes.size() - 1; i >= 0; i--) {
|
|
|
|
Chord* c = _graceNotes[i];
|
2016-02-15 12:23:28 +01:00
|
|
|
if (c->noteType() & (NoteType::GRACE8_AFTER | NoteType::GRACE16_AFTER | NoteType::GRACE32_AFTER))
|
2016-02-06 22:03:43 +01:00
|
|
|
cl.push_back(c);
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
2015-02-19 10:28:25 +01:00
|
|
|
return cl;
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
|
|
|
|
2014-04-09 09:40:25 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// sortNotes
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::sortNotes()
|
|
|
|
{
|
|
|
|
std::sort(notes().begin(), notes().end(),
|
|
|
|
[](const Note* a,const Note* b)->bool { return b->line() < a->line(); }
|
|
|
|
);
|
2014-04-23 18:07:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-19 22:58:23 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// nextTiedChord
|
|
|
|
// Return next chord if all notes in this chord are tied to it.
|
|
|
|
// Set backwards=true to return the previous chord instead.
|
|
|
|
//
|
|
|
|
// Note: the next chord might have extra notes that are not tied
|
|
|
|
// back to this one. Set sameSize=true to return 0 in this case.
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Chord* Chord::nextTiedChord(bool backwards, bool sameSize)
|
|
|
|
{
|
|
|
|
Segment* nextSeg = backwards ? segment()->prev1(Segment::Type::ChordRest) : segment()->next1(Segment::Type::ChordRest);
|
|
|
|
if (!nextSeg)
|
|
|
|
return 0;
|
|
|
|
ChordRest* nextCR = nextSeg->cr(track());
|
|
|
|
if (!nextCR || !nextCR->isChord())
|
|
|
|
return 0;
|
|
|
|
Chord* next = toChord(nextCR);
|
|
|
|
if (sameSize && notes().size() != next->notes().size())
|
|
|
|
return 0; // sizes don't match so some notes can't be tied
|
|
|
|
for (Note* n : _notes) {
|
|
|
|
Tie* tie = backwards ? n->tieBack() : n->tieFor();
|
|
|
|
if (!tie)
|
|
|
|
return 0; // not tied
|
|
|
|
Note* nn = backwards ? tie->startNote() : tie->endNote();
|
|
|
|
if (!nn || nn->chord() != next)
|
|
|
|
return 0; // tied to note in wrong voice, or tied over rest
|
|
|
|
}
|
|
|
|
return next; // all notes in this chord are tied to notes in next chord
|
|
|
|
}
|
|
|
|
|
2014-04-23 18:07:38 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// toGraceAfter
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
void Chord::toGraceAfter()
|
|
|
|
{
|
|
|
|
switch (noteType()) {
|
2016-02-15 12:23:28 +01:00
|
|
|
case NoteType::APPOGGIATURA: setNoteType(NoteType::GRACE8_AFTER); break;
|
|
|
|
case NoteType::GRACE16: setNoteType(NoteType::GRACE16_AFTER); break;
|
|
|
|
case NoteType::GRACE32: setNoteType(NoteType::GRACE32_AFTER); break;
|
2014-04-23 18:07:38 +02:00
|
|
|
default: break;
|
|
|
|
}
|
2014-04-09 09:40:25 +02:00
|
|
|
}
|
2014-05-15 13:42:03 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// tremoloChordType
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
TremoloChordType Chord::tremoloChordType() const
|
|
|
|
{
|
|
|
|
if (_tremolo) {
|
|
|
|
if (_tremolo->twoNotes()) {
|
|
|
|
if (_tremolo->chord1() == this)
|
|
|
|
return TremoloChordType::TremoloFirstNote;
|
|
|
|
else if (_tremolo->chord2() == this)
|
|
|
|
return TremoloChordType::TremoloSecondNote;
|
|
|
|
else
|
2015-01-29 10:19:25 +01:00
|
|
|
qDebug("Chord::tremoloChordType(): inconsistency %p - %p", _tremolo->chord1(), _tremolo->chord2());
|
2014-05-15 13:42:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return TremoloChordType::TremoloSingle;
|
|
|
|
}
|
2014-06-20 22:48:34 +02:00
|
|
|
|
2014-07-10 14:13:37 +02:00
|
|
|
|
2014-06-20 22:48:34 +02:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// nextElement
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Element* Chord::nextElement()
|
|
|
|
{
|
|
|
|
for (int v = track() + 1; staffIdx() == v/VOICES; ++v) {
|
|
|
|
Element* e = segment()->element(v);
|
|
|
|
if (e) {
|
|
|
|
if (e->type() == Element::Type::CHORD)
|
|
|
|
return static_cast<Chord*>(e)->notes().back();
|
|
|
|
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ChordRest::nextElement();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// prevElement
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Element* Chord::prevElement()
|
|
|
|
{
|
|
|
|
for (int v = track() - 1; staffIdx() == v/VOICES; --v) {
|
|
|
|
Element* e = segment()->element(v);
|
|
|
|
if (e) {
|
|
|
|
if (e->type() == Element::Type::CHORD)
|
2016-02-06 22:03:43 +01:00
|
|
|
return static_cast<Chord*>(e)->notes().front();
|
2014-06-20 22:48:34 +02:00
|
|
|
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ChordRest::prevElement();
|
|
|
|
}
|
|
|
|
|
2016-01-04 14:48:58 +01:00
|
|
|
//---------------------------------------------------------
|
|
|
|
// accessibleExtraInfo
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
2016-02-04 17:06:32 +01:00
|
|
|
QString Chord::accessibleExtraInfo() const
|
2014-07-10 14:13:37 +02:00
|
|
|
{
|
|
|
|
QString rez = "";
|
|
|
|
|
|
|
|
if (!isGrace()) {
|
|
|
|
foreach (Chord* c, graceNotes()) {
|
2015-02-03 01:55:37 +01:00
|
|
|
if (!score()->selectionFilter().canSelect(c)) continue;
|
2014-07-10 14:13:37 +02:00
|
|
|
foreach (Note* n, c->notes()) {
|
2014-08-21 18:32:52 +02:00
|
|
|
rez = QString("%1 %2").arg(rez).arg(n->screenReaderInfo());
|
2014-07-10 14:13:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-03 01:55:37 +01:00
|
|
|
if (arpeggio() && score()->selectionFilter().canSelect(arpeggio()))
|
2014-08-21 18:32:52 +02:00
|
|
|
rez = QString("%1 %2").arg(rez).arg(arpeggio()->screenReaderInfo());
|
2014-07-10 14:13:37 +02:00
|
|
|
|
2015-02-03 01:55:37 +01:00
|
|
|
if (tremolo() && score()->selectionFilter().canSelect(tremolo()))
|
2014-08-21 18:32:52 +02:00
|
|
|
rez = QString("%1 %2").arg(rez).arg(tremolo()->screenReaderInfo());
|
2014-07-10 14:13:37 +02:00
|
|
|
|
2015-02-03 01:55:37 +01:00
|
|
|
foreach (Element* e, el()) {
|
2016-06-02 10:38:36 +02:00
|
|
|
if (!score()->selectionFilter().canSelect(e))
|
|
|
|
continue;
|
2014-08-21 18:32:52 +02:00
|
|
|
rez = QString("%1 %2").arg(rez).arg(e->screenReaderInfo());
|
2015-02-03 01:55:37 +01:00
|
|
|
}
|
2014-07-10 14:13:37 +02:00
|
|
|
|
2014-08-21 18:32:52 +02:00
|
|
|
return QString("%1 %2").arg(rez).arg(ChordRest::accessibleExtraInfo());
|
2014-07-10 14:13:37 +02:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// shape
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
Shape Chord::shape() const
|
|
|
|
{
|
|
|
|
Shape shape;
|
|
|
|
processSiblings([&shape, this] (Element* e) {
|
2016-07-01 16:52:13 +02:00
|
|
|
if (!e->isLedgerLine()) // dont add ledger lines to shape
|
2016-03-19 08:18:54 +01:00
|
|
|
shape.add(e->shape());
|
2016-01-04 14:48:58 +01:00
|
|
|
});
|
2016-02-06 11:41:16 +01:00
|
|
|
shape.add(ChordRest::shape()); // add articulation + lyrics
|
|
|
|
return shape.translated(pos());
|
2016-01-04 14:48:58 +01:00
|
|
|
}
|
2013-05-13 18:49:17 +02:00
|
|
|
}
|
2016-01-04 14:48:58 +01:00
|
|
|
|