Skip to content

Commit

Permalink
partial fix #88861: show current staff name after instrument change
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcSabatella committed Dec 3, 2018
1 parent 1b1912d commit b5be6f9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion libmscore/layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2970,7 +2970,8 @@ System* Score::collectSystem(LayoutContext& lc)
lc.startWithLongNames = lc.firstSystem && measure->sectionBreakElement()->startWithLongNames();
}
System* system = getNextSystem(lc);
system->setInstrumentNames(lc.startWithLongNames);
int lcmTick = lc.curMeasure ? lc.curMeasure->tick() : 0;
system->setInstrumentNames(lc.startWithLongNames, lcmTick);

qreal minWidth = 0;
bool firstMeasure = true;
Expand Down
6 changes: 1 addition & 5 deletions libmscore/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ void System::layout2()
// setInstrumentNames
//---------------------------------------------------------

void System::setInstrumentNames(bool longName)
void System::setInstrumentNames(bool longName, int tick)
{
//
// remark: add/remove instrument names is not undo/redoable
Expand All @@ -612,10 +612,6 @@ void System::setInstrumentNames(bool longName)
return;
}

// TODO: ml is normally empty here, so we are unable to retrieve tick
// thus, staff name does not reflect current instrument

int tick = ml.empty() ? 0 : ml.front()->tick();
int staffIdx = 0;
for (SysStaff* staff : _staves) {
Staff* s = score()->staff(staffIdx);
Expand Down
2 changes: 1 addition & 1 deletion libmscore/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class System final : public Element {
void removeStaff(int);

int y2staff(qreal y) const;
void setInstrumentNames(bool longName);
void setInstrumentNames(bool longName, int tick = 0);
int snap(int tick, const QPointF p) const;
int snapNote(int tick, const QPointF p, int staff) const;

Expand Down
8 changes: 4 additions & 4 deletions mscore/continuouspanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ void ContinuousPanel::paint(const QRect&, QPainter& painter)
Segment* parent = _score->tick2segment(tick);

// Find maximum width for the staff name
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument(tick)->longNames();
QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
if (staffName == "") {
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument(tick)->shortNames();
staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
}
Text* newName = new Text(_score);
Expand Down Expand Up @@ -345,10 +345,10 @@ void ContinuousPanel::paint(const QRect&, QPainter& painter)
barLine.draw(&painter);

// Draw the current staff name
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument()->longNames();
QList<StaffName>& staffNamesLong = currentStaff->part()->instrument(tick)->longNames();
QString staffName = staffNamesLong.isEmpty() ? " " : staffNamesLong[0].name();
if (staffName == "") {
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument()->shortNames();
QList<StaffName>& staffNamesShort = currentStaff->part()->instrument(tick)->shortNames();
staffName = staffNamesShort.isEmpty() ? "" : staffNamesShort[0].name();
}

Expand Down

0 comments on commit b5be6f9

Please sign in to comment.