Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glissando as a multi-segment line. #1536

Merged
merged 11 commits into from
Feb 18, 2015
69 changes: 38 additions & 31 deletions libmscore/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Chord::Chord(Score* s)
_stemDirection = MScore::Direction::AUTO;
_arpeggio = 0;
_tremolo = 0;
_glissando = 0;
_endsGlissando = false;
_noteType = NoteType::NORMAL;
_stemSlash = 0;
_noStem = false;
Expand Down Expand Up @@ -221,7 +221,7 @@ Chord::Chord(const Chord& c, bool link)

_stem = 0;
_hook = 0;
_glissando = 0;
_endsGlissando = false;
_arpeggio = 0;
_stemSlash = 0;
_tremolo = 0;
Expand All @@ -240,12 +240,12 @@ Chord::Chord(const Chord& c, bool link)
if (c._stemSlash) {
add(new StemSlash(*(c._stemSlash)));
}
if (c._glissando) {
/* if (c._glissando) {
Glissando* g = new Glissando(*(c._glissando));
add(g);
if (link)
g->linkTo(c._glissando);
}
} */
if (c._arpeggio) {
Arpeggio* a = new Arpeggio(*(c._arpeggio));
add(a);
Expand Down Expand Up @@ -282,8 +282,8 @@ void Chord::undoUnlink()
for (Chord* gn : graceNotes())
gn->undoUnlink();

if (_glissando)
_glissando->undoUnlink();
/* if (_glissando)
_glissando->undoUnlink(); */
if (_arpeggio)
_arpeggio->undoUnlink();
if (_tremolo && !_tremolo->twoNotes())
Expand All @@ -307,7 +307,6 @@ Chord::~Chord()
_tremolo->chord2()->setTremolo(0);
delete _tremolo;
}
delete _glissando;
delete _stemSlash;
delete _stem;
delete _hook;
Expand Down Expand Up @@ -461,7 +460,7 @@ void Chord::add(Element* e)
}
break;
case Element::Type::GLISSANDO:
_glissando = static_cast<Glissando*>(e);
_endsGlissando = true;
break;
case Element::Type::STEM:
Q_ASSERT(!_stem);
Expand Down Expand Up @@ -543,7 +542,7 @@ void Chord::remove(Element* e)
}
break;
case Element::Type::GLISSANDO:
_glissando = 0;
_endsGlissando = false;
break;
case Element::Type::STEM:
_stem = 0;
Expand Down Expand Up @@ -961,8 +960,6 @@ void Chord::write(Xml& xml) const
n->write(xml);
if (_arpeggio)
_arpeggio->write(xml);
if (_glissando)
_glissando->write(xml);
if (_tremolo && tremoloChordType() != TremoloChordType::TremoloSecondNote)
_tremolo->write(xml);
for (Element* e : _el)
Expand Down Expand Up @@ -1048,11 +1045,26 @@ void Chord::read(XmlReader& e)
_arpeggio->read(e);
_arpeggio->setParent(this);
}
// old glissando format, chord-to-chord, attached to its final chord
else if (tag == "Glissando") {
_glissando = new Glissando(score());
_glissando->setTrack(track());
_glissando->read(e);
_glissando->setParent(this);
// 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());
Expand Down Expand Up @@ -1143,8 +1155,6 @@ void Chord::scanElements(void* data, void (*func)(void*, Element*), bool all)
func(data, _arpeggio);
if (_tremolo && (tremoloChordType() != TremoloChordType::TremoloSecondNote))
func(data, _tremolo);
if (_glissando)
func(data, _glissando);
if (staff() && staff()->showLedgerLines())
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
func(data, ll);
Expand Down Expand Up @@ -1175,8 +1185,6 @@ void Chord::processSiblings(std::function<void(Element*)> func)
func(_arpeggio);
if (_tremolo)
func(_tremolo);
if (_glissando)
func(_glissando);
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
func(ll);
for (int i = 0; i < _notes.size(); ++i)
Expand Down Expand Up @@ -1497,8 +1505,6 @@ void Chord::layout2()
for (Chord* c : _graceNotes)
c->layout2();

if (glissando())
glissando()->layout();
qreal _spatium = spatium();

//
Expand Down Expand Up @@ -1848,10 +1854,10 @@ void Chord::layoutPitched()
}

// allocate enough room for glissandi
if (_glissando) {
lll += _spatium * 0.5;
if (rtick())
lll += minTieLength;
if (_endsGlissando) {
if (rtick()) // if not at beginning of measure
lll += _spatium * 0.5 + minTieLength;
// special case of system-initial glissando final note is handled in Glissando::layout() itself
}

if (dots()) {
Expand Down Expand Up @@ -2166,10 +2172,11 @@ void Chord::layoutTablature()
// know the y position of the next staves
}

if (_glissando) {
lll += _spatium * 0.5;
if (rtick())
lll += score()->styleS(StyleIdx::MinTieLength).val() * _spatium;
// allocate enough room for glissandi
if (_endsGlissando) {
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
}

if (dots()) {
Expand Down Expand Up @@ -3002,8 +3009,8 @@ QString Chord::accessibleExtraInfo()
if (tremolo() && score()->selectionFilter().canSelect(tremolo()))
rez = QString("%1 %2").arg(rez).arg(tremolo()->screenReaderInfo());

if (glissando() && score()->selectionFilter().canSelect(glissando()))
rez = QString("%1 %2").arg(rez).arg(glissando()->screenReaderInfo());
// if (glissando() && score()->selectionFilter().canSelect(glissando()))
// rez = QString("%1 %2").arg(rez).arg(glissando()->screenReaderInfo());

foreach (Element* e, el()) {
if (!score()->selectionFilter().canSelect(e)) continue;
Expand Down
9 changes: 6 additions & 3 deletions libmscore/chord.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Hook;
class Arpeggio;
class Tremolo;
class Chord;
class Glissando;
//class Glissando;
class Stem;
class Chord;
class StemSlash;
Expand Down Expand Up @@ -78,7 +78,8 @@ class Chord : public ChordRest {

Arpeggio* _arpeggio;
Tremolo* _tremolo;
Glissando* _glissando;
// Glissando* _glissando;
bool _endsGlissando;///< true if this chord is the ending point of a glissando (nneeded for layout)
ElementList _el; ///< chordline, slur
QList<Chord*> _graceNotes;
int _graceIndex; ///< if this is a grace note, index in parent list
Expand Down Expand Up @@ -146,7 +147,9 @@ class Chord : public ChordRest {
Arpeggio* arpeggio() const { return _arpeggio; }
Tremolo* tremolo() const { return _tremolo; }
void setTremolo(Tremolo* t) { _tremolo = t; }
Glissando* glissando() const { return _glissando; }
// Glissando* glissando() const { return _glissando; }
bool endsGlissando() const { return _endsGlissando; }
void setEndsGlissando (bool val) { _endsGlissando = val; }
StemSlash* stemSlash() const { return _stemSlash; }
bool slash();
void setSlash(bool flag, bool stemless);
Expand Down
1 change: 1 addition & 0 deletions libmscore/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,7 @@ void Score::deleteItem(Element* el)
case Element::Type::SLUR_SEGMENT:
case Element::Type::PEDAL_SEGMENT:
// case Element::Type::LYRICSLINE_SEGMENT:
case Element::Type::GLISSANDO_SEGMENT:
el = static_cast<SpannerSegment*>(el)->spanner();

default:
Expand Down
4 changes: 3 additions & 1 deletion libmscore/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ static const ElementName elementNames[] = {
ElementName("TextLineSegment", QT_TRANSLATE_NOOP("elementName", "Text Line Segment")),
ElementName("VoltaSegment", QT_TRANSLATE_NOOP("elementName", "Volta Segment")),
ElementName("PedalSegment", QT_TRANSLATE_NOOP("elementName", "Pedal Segment")),
ElementName("LyricsLineSegment", QT_TRANSLATE_NOOP("elementName", "Melisma Line Segment")),
ElementName("LyricsLineSegment", QT_TRANSLATE_NOOP("elementName", "Lyrics Line Segment")),
ElementName("GlissandoSegment", QT_TRANSLATE_NOOP("elementName", "Glissando Segment")),
ElementName("LayoutBreak", QT_TRANSLATE_NOOP("elementName", "Layout Break")),
ElementName("Spacer", QT_TRANSLATE_NOOP("elementName", "Spacer")),
ElementName("StaffState", QT_TRANSLATE_NOOP("elementName", "Staff State")),
Expand Down Expand Up @@ -1286,6 +1287,7 @@ Element* Element::create(Element::Type type, Score* score)
case Element::Type::AMBITUS: return new Ambitus(score);

case Element::Type::TEXTLINE_SEGMENT: // return new TextLineSegment(score);
case Element::Type::GLISSANDO_SEGMENT:

case Element::Type::SLUR_SEGMENT:
case Element::Type::STEM_SLASH:
Expand Down
1 change: 1 addition & 0 deletions libmscore/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class Element : public QObject, public ScoreElement {
VOLTA_SEGMENT,
PEDAL_SEGMENT,
LYRICSLINE_SEGMENT,
GLISSANDO_SEGMENT,
LAYOUT_BREAK,
SPACER,
STAFF_STATE,
Expand Down
68 changes: 67 additions & 1 deletion libmscore/excerpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,40 @@ void cloneStaves(Score* oscore, Score* score, const QList<int>& map)
tie->setEndNote(nn);
}
else {
qDebug("cloneStave: cannot find tie");
qDebug("cloneStaves: cannot find tie");
}
}
// add back spanners (going back from end to start spanner element
// makes sure the 'other' spanner anchor element is already set up)
// 'on' is the old spanner end note and 'nn' is the new spanner end note
for (Spanner* oldSp : on->spannerBack()) {
// determining the new spanner start element:
Note* oldStart = static_cast<Note*>(oldSp->startElement());
Note* newStart = nullptr;
// determine the track offset from the spanner end to the spanner start
int newTrack = nn->track() + (on->track() - oldStart->track());
// look in notes linked to oldStart for a note with the same
// score as new score and required track offset
for (ScoreElement* newEl : oldStart->linkList())
if (static_cast<Note*>(newEl)->score() == score
&& static_cast<Note*>(newEl)->track() == newTrack) {
newStart = static_cast<Note*>(newEl);
break;
}
if (newStart != nullptr) {
Spanner* newSp = static_cast<Spanner*>(oldSp->linkedClone());
newSp->setScore(score);
newSp->setParent(newStart);
newSp->setStartElement(newStart);
newSp->setEndElement(nn);
newSp->setTick(newStart->chord()->tick());
newSp->setTick2(nch->tick());
newSp->setTrack(newTrack);
newSp->setTrack2(nn->track());
score->addElement(newSp);
}
else {
qDebug("cloneStaves: cannot find spanner start note");
}
}
}
Expand Down Expand Up @@ -687,6 +720,39 @@ void cloneStaff(Staff* srcStaff, Staff* dstStaff)
qDebug("cloneStave: cannot find tie");
}
}
// add back spanners (going back from end to start spanner element
// makes sure the 'other' spanner anchor element is already set up)
// 'on' is the old spanner end note and 'nn' is the new spanner end note
for (Spanner* oldSp : on->spannerBack()) {
// determining the new spanner start element:
Note* oldStart = static_cast<Note*>(oldSp->startElement());
Note* newStart = nullptr;
// determine the track offset from the spanner end to the spanner start
int newTrack = nn->track() + (on->track() - oldStart->track());
// look in notes linked to oldStart for a note with the same
// score as new score and required track offset
for (ScoreElement* newEl : oldStart->linkList())
if (static_cast<Note*>(newEl)->score() == score
&& static_cast<Note*>(newEl)->track() == newTrack) {
newStart = static_cast<Note*>(newEl);
break;
}
if (newStart != nullptr) {
Spanner* newSp = static_cast<Spanner*>(oldSp->linkedClone());
newSp->setScore(score);
newSp->setParent(newStart);
newSp->setStartElement(newStart);
newSp->setEndElement(nn);
newSp->setTick(newStart->chord()->tick());
newSp->setTick2(nch->tick());
newSp->setTrack(newTrack);
newSp->setTrack2(nn->track());
score->addElement(newSp);
}
else {
qDebug("cloneStave: cannot find spanner start note");
}
}
}
}
}
Expand Down
Loading