Skip to content

Commit

Permalink
propagate rehearsal mark to all parts
Browse files Browse the repository at this point in the history
  • Loading branch information
wschweer committed Feb 25, 2013
1 parent a80f730 commit 6eabaf5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libmscore/rehearsalmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
class RehearsalMark : public Text {
Q_OBJECT


public:
RehearsalMark(Score* score);
virtual RehearsalMark* clone() const { return new RehearsalMark(*this); }
virtual ElementType type() const { return REHEARSAL_MARK; }
Segment* segment() const { return (Segment*)parent(); }
};

#endif
Expand Down
39 changes: 38 additions & 1 deletion libmscore/undo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "articulation.h"
#include "noteevent.h"
#include "slur.h"
// #include "excerpt.h"
#include "tempotext.h"
#include "instrchange.h"
#include "box.h"
Expand All @@ -67,6 +66,8 @@
#include "sequencer.h"
#include "breath.h"
#include "fingering.h"
#include "rehearsalmark.h"
#include "excerpt.h"

extern Measure* tick2measure(int tick);

Expand Down Expand Up @@ -751,6 +752,42 @@ void Score::undoAddElement(Element* element)

Element::ElementType et = element->type();


// some elements are replicated for all parts regardless of
// linking:

if (et == Element::REHEARSAL_MARK) {
foreach(Excerpt* excerpt, rootScore()->excerpts())
staffList.append(excerpt->score()->staff(0));

foreach(Staff* staff, staffList) {
Score* score = staff->score();
int staffIdx = score->staffIdx(staff);
Element* ne;
if (staff == ostaff)
ne = element;
else {
ne = element->linkedClone();
ne->setScore(score);
ne->setSelected(false);
ne->setTrack(staffIdx * VOICES + element->voice());
}
if (element->type() == Element::REHEARSAL_MARK) {
RehearsalMark* d = static_cast<RehearsalMark*>(element);
Segment* segment = d->segment();
int tick = segment->tick();
Measure* m = score->tick2measure(tick);
Segment* seg = m->findSegment(Segment::SegChordRest, tick);
RehearsalMark* nd = static_cast<RehearsalMark*>(ne);
int ntrack = staffIdx * VOICES + d->voice();
nd->setTrack(ntrack);
nd->setParent(seg);
undo(new AddElement(nd));
}
}
return;
}

if (et == Element::FINGERING
|| et == Element::IMAGE
|| et == Element::SYMBOL
Expand Down

0 comments on commit 6eabaf5

Please sign in to comment.