fix #138706: Draw brace from musical font instead of hardcoded
This commit is contained in:
parent
2eb7be1833
commit
e8b7932ea5
4 changed files with 99 additions and 29 deletions
|
@ -35,9 +35,33 @@ Bracket::Bracket(Score* s)
|
|||
_span = 0;
|
||||
_firstStaff = 0;
|
||||
_lastStaff = 0;
|
||||
_braceSymbol = SymId::brace;
|
||||
setGenerated(true); // brackets are not saved
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// setSpan
|
||||
//---------------------------------------------------------
|
||||
|
||||
void Bracket::setSpan(int v)
|
||||
{
|
||||
_span = v;
|
||||
if (bracketType() == BracketType::BRACE) {
|
||||
// total default height of a system of n staves / height of a 5 line staff
|
||||
_magx = v + ((v - 1) * score()->styleS(StyleIdx::akkoladeDistance).val() / 4.0);
|
||||
if (v == 1)
|
||||
_braceSymbol = SymId::braceSmall;
|
||||
else if (v <= 2)
|
||||
_braceSymbol = SymId::brace;
|
||||
else if (v <= 3)
|
||||
_braceSymbol = SymId::braceLarge;
|
||||
else
|
||||
_braceSymbol = SymId::braceLarger;
|
||||
if (!symIsValid(_braceSymbol))
|
||||
_braceSymbol = SymId::brace;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// setHeight
|
||||
//---------------------------------------------------------
|
||||
|
@ -56,7 +80,10 @@ qreal Bracket::width() const
|
|||
qreal w;
|
||||
switch (bracketType()) {
|
||||
case BracketType::BRACE:
|
||||
w = score()->styleP(StyleIdx::akkoladeWidth) + score()->styleP(StyleIdx::akkoladeBarDistance);
|
||||
if (score()->styleSt(StyleIdx::MusicalSymbolFont) == "Emmentaler" || score()->styleSt(StyleIdx::MusicalSymbolFont) == "Gonville")
|
||||
w = score()->styleP(StyleIdx::akkoladeWidth) + score()->styleP(StyleIdx::akkoladeBarDistance);
|
||||
else
|
||||
w = (symWidth(_braceSymbol) * _magx) + score()->styleP(StyleIdx::akkoladeBarDistance);
|
||||
break;
|
||||
case BracketType::NORMAL:
|
||||
w = score()->styleP(StyleIdx::bracketWidth) + score()->styleP(StyleIdx::bracketDistance);
|
||||
|
@ -86,34 +113,41 @@ void Bracket::layout()
|
|||
return;
|
||||
|
||||
switch (bracketType()) {
|
||||
case BracketType::BRACE: {
|
||||
qreal w = score()->styleP(StyleIdx::akkoladeWidth);
|
||||
case BracketType::BRACE: {
|
||||
if (score()->styleSt(StyleIdx::MusicalSymbolFont) == "Emmentaler" || score()->styleSt(StyleIdx::MusicalSymbolFont) == "Gonville") {
|
||||
qreal w = score()->styleP(StyleIdx::akkoladeWidth);
|
||||
|
||||
#define XM(a) (a+700)*w/700
|
||||
#define YM(a) (a+7100)*h2/7100
|
||||
|
||||
path.moveTo( XM( -8), YM(-2048));
|
||||
path.cubicTo(XM( -8), YM(-3192), XM(-360), YM(-4304), XM( -360), YM(-5400)); // c 0
|
||||
path.cubicTo(XM( -360), YM(-5952), XM(-264), YM(-6488), XM( 32), YM(-6968)); // c 1
|
||||
path.cubicTo(XM( 36), YM(-6974), XM( 38), YM(-6984), XM( 38), YM(-6990)); // c 0
|
||||
path.cubicTo(XM( 38), YM(-7008), XM( 16), YM(-7024), XM( 0), YM(-7024)); // c 0
|
||||
path.cubicTo(XM( -8), YM(-7024), XM( -22), YM(-7022), XM( -32), YM(-7008)); // c 1
|
||||
path.cubicTo(XM( -416), YM(-6392), XM(-544), YM(-5680), XM( -544), YM(-4960)); // c 0
|
||||
path.cubicTo(XM( -544), YM(-3800), XM(-168), YM(-2680), XM( -168), YM(-1568)); // c 0
|
||||
path.cubicTo(XM( -168), YM(-1016), XM(-264), YM( -496), XM( -560), YM( -16)); // c 1
|
||||
path.lineTo( XM( -560), YM( 0)); // l 1
|
||||
path.lineTo( XM( -560), YM( 16)); // l 1
|
||||
path.cubicTo(XM( -264), YM( 496), XM(-168), YM( 1016), XM( -168), YM( 1568)); // c 0
|
||||
path.cubicTo(XM( -168), YM( 2680), XM(-544), YM( 3800), XM( -544), YM( 4960)); // c 0
|
||||
path.cubicTo(XM( -544), YM( 5680), XM(-416), YM( 6392), XM( -32), YM( 7008)); // c 1
|
||||
path.cubicTo(XM( -22), YM( 7022), XM( -8), YM( 7024), XM( 0), YM( 7024)); // c 0
|
||||
path.cubicTo(XM( 16), YM( 7024), XM( 38), YM( 7008), XM( 38), YM( 6990)); // c 0
|
||||
path.cubicTo(XM( 38), YM( 6984), XM( 36), YM( 6974), XM( 32), YM( 6968)); // c 1
|
||||
path.cubicTo(XM( -264), YM( 6488), XM(-360), YM( 5952), XM( -360), YM( 5400)); // c 0
|
||||
path.cubicTo(XM( -360), YM( 4304), XM( -8), YM( 3192), XM( -8), YM( 2048)); // c 0
|
||||
path.cubicTo(XM( - 8), YM( 1320), XM(-136), YM( 624), XM( -512), YM( 0)); // c 1
|
||||
path.cubicTo(XM( -136), YM( -624), XM( -8), YM(-1320), XM( -8), YM(-2048)); // c 0
|
||||
setbbox(path.boundingRect());
|
||||
path.moveTo( XM( -8), YM(-2048));
|
||||
path.cubicTo(XM( -8), YM(-3192), XM(-360), YM(-4304), XM( -360), YM(-5400)); // c 0
|
||||
path.cubicTo(XM( -360), YM(-5952), XM(-264), YM(-6488), XM( 32), YM(-6968)); // c 1
|
||||
path.cubicTo(XM( 36), YM(-6974), XM( 38), YM(-6984), XM( 38), YM(-6990)); // c 0
|
||||
path.cubicTo(XM( 38), YM(-7008), XM( 16), YM(-7024), XM( 0), YM(-7024)); // c 0
|
||||
path.cubicTo(XM( -8), YM(-7024), XM( -22), YM(-7022), XM( -32), YM(-7008)); // c 1
|
||||
path.cubicTo(XM( -416), YM(-6392), XM(-544), YM(-5680), XM( -544), YM(-4960)); // c 0
|
||||
path.cubicTo(XM( -544), YM(-3800), XM(-168), YM(-2680), XM( -168), YM(-1568)); // c 0
|
||||
path.cubicTo(XM( -168), YM(-1016), XM(-264), YM( -496), XM( -560), YM( -16)); // c 1
|
||||
path.lineTo( XM( -560), YM( 0)); // l 1
|
||||
path.lineTo( XM( -560), YM( 16)); // l 1
|
||||
path.cubicTo(XM( -264), YM( 496), XM(-168), YM( 1016), XM( -168), YM( 1568)); // c 0
|
||||
path.cubicTo(XM( -168), YM( 2680), XM(-544), YM( 3800), XM( -544), YM( 4960)); // c 0
|
||||
path.cubicTo(XM( -544), YM( 5680), XM(-416), YM( 6392), XM( -32), YM( 7008)); // c 1
|
||||
path.cubicTo(XM( -22), YM( 7022), XM( -8), YM( 7024), XM( 0), YM( 7024)); // c 0
|
||||
path.cubicTo(XM( 16), YM( 7024), XM( 38), YM( 7008), XM( 38), YM( 6990)); // c 0
|
||||
path.cubicTo(XM( 38), YM( 6984), XM( 36), YM( 6974), XM( 32), YM( 6968)); // c 1
|
||||
path.cubicTo(XM( -264), YM( 6488), XM(-360), YM( 5952), XM( -360), YM( 5400)); // c 0
|
||||
path.cubicTo(XM( -360), YM( 4304), XM( -8), YM( 3192), XM( -8), YM( 2048)); // c 0
|
||||
path.cubicTo(XM( - 8), YM( 1320), XM(-136), YM( 624), XM( -512), YM( 0)); // c 1
|
||||
path.cubicTo(XM( -136), YM( -624), XM( -8), YM(-1320), XM( -8), YM(-2048)); // c 0*/
|
||||
setbbox(path.boundingRect());
|
||||
}
|
||||
else {
|
||||
qreal h = h2 * 2;
|
||||
qreal w = symWidth(_braceSymbol) * _magx;
|
||||
bbox().setRect(0, 0, w, h);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BracketType::NORMAL: {
|
||||
|
@ -160,10 +194,21 @@ void Bracket::draw(QPainter* painter) const
|
|||
if (h2 == 0.0)
|
||||
return;
|
||||
switch (bracketType()) {
|
||||
case BracketType::BRACE:
|
||||
case BracketType::BRACE: {
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setBrush(QBrush(curColor()));
|
||||
painter->drawPath(path);
|
||||
if (score()->styleSt(StyleIdx::MusicalSymbolFont) == "Emmentaler" || score()->styleSt(StyleIdx::MusicalSymbolFont) == "Gonville")
|
||||
painter->drawPath(path);
|
||||
else {
|
||||
qreal h = 2 * h2;
|
||||
qreal _spatium = spatium();
|
||||
qreal mag = h / (4 *_spatium);
|
||||
painter->save();
|
||||
painter->scale(_magx, mag);
|
||||
drawSymbol(_braceSymbol, painter, QPointF(0, h/mag));
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BracketType::NORMAL: {
|
||||
qreal h = 2 * h2;
|
||||
|
|
|
@ -40,6 +40,11 @@ class Bracket : public Element {
|
|||
|
||||
QPainterPath path;
|
||||
|
||||
SymId _braceSymbol;
|
||||
// horizontal scaling factor for brace symbol. Cannot be equal to magY or depend on h
|
||||
// because layout needs width of brace before knowing height of system...
|
||||
qreal _magx;
|
||||
|
||||
public:
|
||||
Bracket(Score*);
|
||||
virtual Bracket* clone() const override { return new Bracket(*this); }
|
||||
|
@ -57,7 +62,7 @@ class Bracket : public Element {
|
|||
int level() const { return _column; }
|
||||
void setLevel(int v) { _column = v; }
|
||||
int span() const { return _span; }
|
||||
void setSpan(int v) { _span = v; }
|
||||
void setSpan(int v);
|
||||
System* system() const { return (System*)parent(); }
|
||||
|
||||
virtual void setHeight(qreal) override;
|
||||
|
|
|
@ -2655,6 +2655,9 @@ QVector<const char*> Sym::symNames = {
|
|||
"cClefFrench20C",
|
||||
"fClefFrench",
|
||||
"fClef19thCentury",
|
||||
"braceSmall",
|
||||
"braceLarge",
|
||||
"braceLarger",
|
||||
|
||||
// MuseScore local symbols, precomposed symbols to mimic some emmentaler glyphs
|
||||
|
||||
|
@ -5289,6 +5292,9 @@ QVector<QString> Sym::symUserNames = {
|
|||
"C clef (French, 20th century)",
|
||||
"F clef (French, 18th century)",
|
||||
"F clef (19th century)",
|
||||
"Small brace",
|
||||
"Large brace",
|
||||
"Larger brace",
|
||||
|
||||
// MuseScore local symbols, precomposed symbols to mimic some Emmentaler glyphs
|
||||
|
||||
|
@ -6067,6 +6073,18 @@ void ScoreFont::load()
|
|||
{ QString("noteheadDoubleWhole"),
|
||||
QString("noteheadDoubleWholeAlt"),
|
||||
SymId::noteheadDoubleWholeAlt
|
||||
},
|
||||
{ QString("brace"),
|
||||
QString("braceSmall"),
|
||||
SymId::braceSmall
|
||||
},
|
||||
{ QString("brace"),
|
||||
QString("braceLarge"),
|
||||
SymId::braceLarge
|
||||
},
|
||||
{ QString("brace"),
|
||||
QString("braceLarger"),
|
||||
SymId::braceLarger
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2641,7 +2641,9 @@ enum class SymId {
|
|||
cClefFrench20C,
|
||||
fClefFrench,
|
||||
fClef19thCentury,
|
||||
|
||||
braceSmall,
|
||||
braceLarge,
|
||||
braceLarger,
|
||||
|
||||
// MuseScore local symbols, precomposed symbols to mimic some emmentaler glyphs
|
||||
|
||||
|
|
Loading…
Reference in a new issue