Skip to content

Commit

Permalink
fix #15121: Ledger lines don't appear for notes beyond staff in drum …
Browse files Browse the repository at this point in the history
…palette
  • Loading branch information
Fyrult authored and lasconic committed May 12, 2016
1 parent 72838e7 commit b46ddd3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
47 changes: 30 additions & 17 deletions libmscore/chord.cpp
Expand Up @@ -633,7 +633,7 @@ void Chord::addLedgerLine(int track, int line, bool visible, qreal x, Spatium le

//---------------------------------------------------------
// createLedgerLines
/// Creates the ledger lines fro a chord
/// Creates the ledger lines for a chord
/// \arg track track the ledger line belongs to
/// \arg lines a vector of LedgerLineData describing thelines to add
/// \arg visible whether the line is visible or not
Expand All @@ -658,22 +658,34 @@ void Chord::createLedgerLines(int track, vector<LedgerLineData>& vecLines, bool
// addLedgerLines
//---------------------------------------------------------

void Chord::addLedgerLines(int move)
void Chord::addLedgerLines()
{
LedgerLineData lld;
qreal _spatium = spatium();
int idx = staffIdx() + move;
int track = staff2track(idx); // the track lines belong to
qreal hw = _notes[0]->headWidth();
LedgerLineData lld;
// initialize for palette
int track = 0; // the track lines belong to
// the line pos corresponding to the bottom line of the staff
int lineBelow = (score()->staff(idx)->lines()-1) * 2;
int lineBelow = 8; // assuming 5-lined "staff"
qreal lineDistance = 1, _mag = 1;
bool staffVisible = true;

if (segment()) { //not palette
int idx = staffIdx() + staffMove();
track = staff2track(idx);
Staff* st = score()->staff(idx);
lineBelow = (st->lines() - 1) * 2;
lineDistance = st->lineDistance();
_mag = staff()->mag();
staffVisible = !staff()->invisible();
}

// the extra length of a ledger line with respect to notehead (half of it on each side)
qreal extraLen = score()->styleP(StyleIdx::ledgerLineLength) * _mag * 0.5;
qreal hw = _notes[0]->headWidth();
qreal minX, maxX; // note extrema in raster units
// qreal minXr, maxXr; // ledger line extrema in raster units
int minLine, maxLine;
bool visible = false;
qreal x;
// the extra length of a ledger line with respect to notehead (half of it on each side)
qreal extraLen = score()->styleS(StyleIdx::ledgerLineLength).val() * _spatium * 0.5;

// scan chord notes, collecting visibility and x and y extrema
// NOTE: notes are sorted from bottom to top (line no. decreasing)
Expand Down Expand Up @@ -763,11 +775,8 @@ void Chord::addLedgerLines(int move)
}
}
if (minLine < 0 || maxLine > lineBelow)
createLedgerLines(track, vecLines, !staff()->invisible());
createLedgerLines(track, vecLines, staffVisible);
}

return; // no ledger lines for this chord

}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1164,7 +1173,8 @@ void Chord::scanElements(void* data, void (*func)(void*, Element*), bool all)
func(data, _arpeggio);
if (_tremolo && (tremoloChordType() != TremoloChordType::TremoloSecondNote))
func(data, _tremolo);
if (staff() && staff()->showLedgerLines())
Staff* st = staff();
if ((st && st->showLedgerLines()) || !st) // also for palette
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
func(data, ll);
int n = _notes.size();
Expand All @@ -1182,7 +1192,7 @@ void Chord::scanElements(void* data, void (*func)(void*, Element*), bool all)
// processSiblings
//---------------------------------------------------------

void Chord::processSiblings(std::function<void(Element*)> func)
void Chord::processSiblings(std::function<void(Element*)> func) const
{
if (_hook)
func(_hook);
Expand Down Expand Up @@ -1791,6 +1801,9 @@ void Chord::layoutPitched()
}
computeUp();
layoutStem();
addLedgerLines();
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
ll->layout();
return;
}

Expand Down Expand Up @@ -1882,7 +1895,7 @@ void Chord::layoutPitched()
// create ledger lines
//-----------------------------------------

addLedgerLines(staffMove());
addLedgerLines();
for (LedgerLine* ll = _ledgerLines; ll; ll = ll->next())
ll->layout();

Expand Down
4 changes: 2 additions & 2 deletions libmscore/chord.h
Expand Up @@ -100,8 +100,8 @@ class Chord : public ChordRest {
virtual qreal downPos() const;
virtual qreal centerX() const;
void createLedgerLines(int track, std::vector<LedgerLineData> &vecLines, bool visible);
void addLedgerLines(int move);
void processSiblings(std::function<void(Element*)> func);
void addLedgerLines();
void processSiblings(std::function<void(Element*)> func) const;
void layoutPitched();
void layoutTablature();

Expand Down
3 changes: 2 additions & 1 deletion libmscore/ledgerline.cpp
Expand Up @@ -61,7 +61,8 @@ qreal LedgerLine::measureXPos() const
void LedgerLine::layout()
{
setLineWidth(score()->styleS(StyleIdx::ledgerLineWidth) * chord()->mag());
setColor(staff()->color());
if (staff())
setColor(staff()->color());
Line::layout();
}

Expand Down

0 comments on commit b46ddd3

Please sign in to comment.