Skip to content

Commit aaefe51

Browse files
committed
Fix 308771: (including Color)
1 parent 8b847d4 commit aaefe51

11 files changed

+323
-252
lines changed

libmscore/ledgerline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void LedgerLine::layout()
6464
{
6565
setLineWidth(score()->styleP(Sid::ledgerLineWidth) * chord()->mag());
6666
if (staff())
67-
setColor(staff()->color());
67+
setColor(staff()->staffType(tick())->color()); //or staff()->color(tick()) ?
6868
qreal w2 = _width * .5;
6969
if (vertical)
7070
bbox().setRect(-w2, -w2, _width, _len + _width);

libmscore/staff.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ void Staff::write(XmlWriter& xml) const
651651
}
652652

653653
if (invisible(Fraction(0,1)))
654-
xml.tag("invisible", invisible(Fraction(0,1))); //obsolete?
654+
xml.tag("invisible", invisible(Fraction(0,1)));
655655
if (hideWhenEmpty() != HideMode::AUTO)
656656
xml.tag("hideWhenEmpty", int(hideWhenEmpty()));
657657
if (cutaway())
@@ -723,7 +723,7 @@ bool Staff::readProperties(XmlReader& e)
723723
else if (tag == "small") // obsolete
724724
staffType(Fraction(0,1))->setSmall(e.readInt());
725725
else if (tag == "invisible")
726-
staffType(Fraction(0,1))->setInvisible(e.readInt()); // obsolete?
726+
staffType(Fraction(0,1))->setInvisible(e.readInt()); // same as: setInvisible(Fraction(0,1)), e.readInt())
727727
else if (tag == "hideWhenEmpty")
728728
setHideWhenEmpty(HideMode(e.readInt()));
729729
else if (tag == "cutaway")
@@ -775,7 +775,7 @@ bool Staff::readProperties(XmlReader& e)
775775
}
776776
}
777777
else if (tag == "color")
778-
_color = e.readColor();
778+
staffType(Fraction(0,1))->setColor(e.readColor());
779779
else if (tag == "transposeDiatonic")
780780
e.setTransposeDiatonic(e.readInt());
781781
else if (tag == "transposeChromatic")
@@ -1177,6 +1177,24 @@ bool Staff::showLedgerLines(const Fraction& tick) const
11771177
return staffType(tick)->showLedgerLines();
11781178
}
11791179

1180+
//---------------------------------------------------------
1181+
// color
1182+
//---------------------------------------------------------
1183+
1184+
QColor Staff::color(const Fraction& tick) const
1185+
{
1186+
return staffType(tick)->color();
1187+
}
1188+
1189+
//---------------------------------------------------------
1190+
// setColor
1191+
//---------------------------------------------------------
1192+
1193+
void Staff::setColor(const Fraction& tick, const QColor& val)
1194+
{
1195+
staffType(tick)->setColor(val);
1196+
}
1197+
11801198
//---------------------------------------------------------
11811199
// updateOttava
11821200
//---------------------------------------------------------
@@ -1313,8 +1331,10 @@ QVariant Staff::getProperty(Pid id) const
13131331
return staffType(Fraction(0,1))->small();
13141332
case Pid::MAG:
13151333
return staffType(Fraction(0,1))->userMag();
1334+
case Pid::STAFF_INVISIBLE:
1335+
return staffType(Fraction(0,1))->invisible();
13161336
case Pid::COLOR:
1317-
return color();
1337+
return staffType(Fraction(0,1))->color();
13181338
case Pid::PLAYBACK_VOICE1:
13191339
return playbackVoice(0);
13201340
case Pid::PLAYBACK_VOICE2:
@@ -1359,7 +1379,7 @@ bool Staff::setProperty(Pid id, const QVariant& v)
13591379
}
13601380
break;
13611381
case Pid::COLOR:
1362-
setColor(v.value<QColor>());
1382+
setColor(Fraction(0,1),v.value<QColor>());
13631383
break;
13641384
case Pid::PLAYBACK_VOICE1:
13651385
setPlaybackVoice(0, v.toBool());
@@ -1550,4 +1570,3 @@ void Staff::setInvisible(const Fraction& tick, bool val)
15501570
}
15511571

15521572

1553-

libmscore/staff.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ class Staff final : public ScoreElement {
167167

168168
bool show() const;
169169
bool stemless(const Fraction&) const;
170-
//bool invisible() const { return _invisible; } //obsolete
171-
//void setInvisible(bool val) { _invisible = val; } //obsolete
172170
bool cutaway() const { return _cutaway; }
173171
void setCutaway(bool val) { _cutaway = val; }
174172
bool showIfEmpty() const { return _showIfEmpty; }
@@ -222,8 +220,8 @@ class Staff final : public ScoreElement {
222220
void setLines(const Fraction&, int lines);
223221
qreal lineDistance(const Fraction&) const;
224222

225-
bool invisible(const Fraction& tick) const;
226-
void setInvisible(const Fraction& tick, bool val);
223+
bool invisible(const Fraction&) const;
224+
void setInvisible(const Fraction&, bool val);
227225

228226
void setSlashStyle(const Fraction&, bool val);
229227
int middleLine(const Fraction&) const;
@@ -252,9 +250,9 @@ class Staff final : public ScoreElement {
252250
bool genKeySig();
253251
bool showLedgerLines(const Fraction&) const;
254252

255-
QColor color() const { return _color; }
256-
void setColor(const QColor& val) { _color = val; }
257-
void undoSetColor(const QColor& val);
253+
QColor color(const Fraction&) const;
254+
void setColor(const Fraction&, const QColor& val);
255+
void undoSetColor(const QColor& val); //disabled?
258256
void insertTime(const Fraction&, const Fraction& len);
259257

260258
QVariant getProperty(Pid) const override;

libmscore/stafflines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void StaffLines::layoutForWidth(qreal w)
9494
if (s) {
9595
setMag(s->mag(measure()->tick()));
9696
setVisible(!s->invisible(measure()->tick()));
97-
setColor(s->color());
97+
setColor(s->color(measure()->tick()));
9898
const StaffType* st = s->staffType(measure()->tick());
9999
dist *= st->lineDistance().val();
100100
_lines = st->lines();

0 commit comments

Comments
 (0)