Skip to content

Commit

Permalink
Fix musescore#17891: Instrument names follow largest stave spatium in…
Browse files Browse the repository at this point in the history
… part
  • Loading branch information
miiizen committed Aug 24, 2023
1 parent 2abc6c2 commit f0ba9cc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/engraving/libmscore/engravingitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class EngravingItem : public EngravingObject

virtual bool isEngravingItem() const override { return true; }

double spatium() const;
virtual double spatium() const;

inline void setFlag(ElementFlag f, bool v)
{
Expand Down
25 changes: 25 additions & 0 deletions src/engraving/libmscore/instrumentname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include "instrumentname.h"

#include "measure.h"
#include "part.h"
#include "staff.h"
#include "style/style.h"
#include "system.h"

#include "log.h"
Expand Down Expand Up @@ -80,6 +83,28 @@ void InstrumentName::setInstrumentNameType(const String& s)
}
}

double InstrumentName::spatium() const
{
if (systemFlag() || (explicitParent() && parentItem()->systemFlag())) {
return style().spatium();
}

// Get spatium for instrument names from largest staff of part,
// instead of staff it is attached to
Part* p = part();
if (!part()) {
return style().spatium();
}
double largestSpatium = 0;
for (Staff* s: p->staves()) {
double sp = s->spatium(tick());
if (sp > largestSpatium) {
largestSpatium = sp;
}
}
return largestSpatium;
}

//---------------------------------------------------------
// setInstrumentNameType
//---------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/libmscore/instrumentname.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class InstrumentName final : public TextBase
SysStaff* sysStaff() const { return _sysStaff; }
void setSysStaff(SysStaff* s) { _sysStaff = s; }

double spatium() const override;

Fraction playTick() const override;
bool isEditable() const override { return false; }
PropertyValue getProperty(Pid propertyId) const override;
Expand Down
Binary file added vtest/scores/instrument-names.mscz
Binary file not shown.

0 comments on commit f0ba9cc

Please sign in to comment.