Skip to content

Commit

Permalink
fix #198486: copy fretboard list
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Jun 12, 2017
1 parent 89ffa04 commit 8d80981
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
42 changes: 27 additions & 15 deletions libmscore/paste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "staff.h"
#include "measure.h"
#include "harmony.h"
#include "fret.h"
#include "breath.h"
#include "beam.h"
#include "figuredbass.h"
Expand Down Expand Up @@ -634,10 +635,11 @@ void Score::pasteSymbols(XmlReader& e, ChordRest* dst)
segDelta = e.readInt();
else {

if (tag == "Harmony") {
if (tag == "Harmony" || tag == "FretDiagram") {
//
// Harmony elements (= chord symbols) are positioned respecting
// the original tickOffset: advance to destTick (or near)
// same for FretDiagram elements
//
Segment* harmSegm;
for (harmSegm = startSegm; harmSegm && (harmSegm->tick() < destTick);
Expand All @@ -656,21 +658,31 @@ void Score::pasteSymbols(XmlReader& e, ChordRest* dst)
e.skipCurrentElement(); // ignore
continue;
}
Harmony* el = new Harmony(this);
el->setTrack(trackZeroVoice(destTrack));
el->read(e);
el->setTrack(trackZeroVoice(destTrack));
// transpose
Part* partDest = staff(track2staff(destTrack))->part();
Interval interval = partDest->instrument(destTick)->transpose();
if (!styleB(StyleIdx::concertPitch) && !interval.isZero()) {
interval.flip();
int rootTpc = transposeTpc(el->rootTpc(), interval, true);
int baseTpc = transposeTpc(el->baseTpc(), interval, true);
undoTransposeHarmony(el, rootTpc, baseTpc);
if (tag == "Harmony") {
Harmony* el = new Harmony(this);
el->setTrack(trackZeroVoice(destTrack));
el->read(e);
el->setTrack(trackZeroVoice(destTrack));
// transpose
Part* partDest = staff(track2staff(destTrack))->part();
Interval interval = partDest->instrument(destTick)->transpose();
if (!styleB(StyleIdx::concertPitch) && !interval.isZero()) {
interval.flip();
int rootTpc = transposeTpc(el->rootTpc(), interval, true);
int baseTpc = transposeTpc(el->baseTpc(), interval, true);
undoTransposeHarmony(el, rootTpc, baseTpc);
}
el->setParent(harmSegm);
undoAddElement(el);
}
else if (tag == "FretDiagram") {
FretDiagram* el = new FretDiagram(this);
el->setTrack(trackZeroVoice(destTrack));
el->read(e);
el->setTrack(trackZeroVoice(destTrack));
el->setParent(harmSegm);
undoAddElement(el);
}
el->setParent(harmSegm);
undoAddElement(el);
}
else {
//
Expand Down
9 changes: 8 additions & 1 deletion libmscore/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "figuredbass.h"
#include "glissando.h"
#include "harmony.h"
#include "fret.h"
#include "hook.h"
#include "input.h"
#include "limits.h"
Expand Down Expand Up @@ -780,7 +781,6 @@ Enabling copying of more element types requires enabling pasting in Score::paste
case Element::Type::STAFF_TEXT:
case Element::Type::REHEARSAL_MARK:
case Element::Type::INSTRUMENT_CHANGE:
case Element::Type::FRET_DIAGRAM:
case Element::Type::BEND:
case Element::Type::TREMOLOBAR:
case Element::Type::VOLTA:
Expand Down Expand Up @@ -853,6 +853,13 @@ Enabling copying of more element types requires enabling pasting in Score::paste
break;
}
continue;
case Element::Type::FRET_DIAGRAM:
// ignore fret diagrams not attached to segment
if (e->parent()->type() == Element::Type::SEGMENT) {
seg = static_cast<Segment*>( (static_cast<FretDiagram*>(e))->parent() );
break;
}
continue;
case Element::Type::LYRICS:
seg = (static_cast<Lyrics*>(e))->segment();
break;
Expand Down

0 comments on commit 8d80981

Please sign in to comment.