Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions src/engraving/dom/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2046,65 +2046,6 @@ EngravingItem* Note::drop(EditData& data)
return 0;
}

//---------------------------------------------------------
// setDotY
// dotMove is number of staff spaces/lines to move from the note's
// space or line
//---------------------------------------------------------

void Note::setDotRelativeLine(int dotMove)
{
double y = dotMove / 2.0;
if (staff()->isTabStaff(chord()->tick())) {
// with TAB's, dotPosX is not set:
// get dot X from width of fret text and use TAB default spacing
const Staff* st = staff();
const StaffType* tab = st->staffTypeForElement(this);
if (tab->stemThrough()) {
// if fret mark on lines, use standard processing
if (!tab->onLines()) {
// if fret marks above lines, raise the dots by half line distance
y = -0.5;
}
if (dotMove == 0) {
bool oddVoice = voice() & 1;
y = oddVoice ? 0.5 : -0.5;
} else {
y = 0.5;
}
}
// if stems beside staff, do nothing
else {
return;
}
}
y *= spatium() * staff()->lineDistance(tick());

// apply to dots

int cdots = static_cast<int>(chord()->dots());
int ndots = static_cast<int>(m_dots.size());

int n = cdots - ndots;
for (int i = 0; i < n; ++i) {
NoteDot* dot = Factory::createNoteDot(this);
dot->setParent(this);
dot->setTrack(track()); // needed to know the staff it belongs to (and detect tablature)
dot->setVisible(visible());
score()->undoAddElement(dot);
}
if (n < 0) {
for (int i = 0; i < -n; ++i) {
score()->undoRemoveElement(m_dots.back());
}
}

for (NoteDot* dot : m_dots) {
renderer()->layoutItem(dot);
dot->mutldata()->setPosY(y);
}
}

//---------------------------------------------------------
// dotIsUp
//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/engraving/dom/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ class Note final : public EngravingItem
bool mark() const { return m_mark; }
void setMark(bool v) const { m_mark = v; }
void setScore(Score* s) override;
void setDotRelativeLine(int);

static SymId noteHead(int direction, NoteHeadGroup, NoteHeadType, int tpc, Key key, NoteHeadScheme scheme);
static SymId noteHead(int direction, NoteHeadGroup, NoteHeadType);
Expand Down
72 changes: 62 additions & 10 deletions src/engraving/rendering/score/chordlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void ChordLayout::layoutTablature(Chord* item, LayoutContext& ctx)
for (size_t i = 0; i < numOfNotes; ++i) {
Note* note = item->notes().at(i);
note->updateFrettingForTiesAndBends();
note->setDotRelativeLine(0);
ChordLayout::setDotRelativeLine(note, 0, ctx);
TLayout::layoutNote(note, note->mutldata());
// set headWidth to max fret text width
double fretWidth = note->ldata()->bbox().width();
Expand Down Expand Up @@ -2463,7 +2463,7 @@ double ChordLayout::centerX(const Chord* chord)
// placeDots
//---------------------------------------------------------

void ChordLayout::placeDots(const std::vector<Chord*>& chords, const std::vector<Note*>& notes)
void ChordLayout::placeDots(const std::vector<Chord*>& chords, const std::vector<Note*>& notes, LayoutContext& ctx)
{
Chord* chord = nullptr;
for (Chord* c : chords) {
Expand All @@ -2472,7 +2472,7 @@ void ChordLayout::placeDots(const std::vector<Chord*>& chords, const std::vector
break;
} else {
for (Note* note : c->notes()) {
note->setDotRelativeLine(0); // this manages the deletion of dots
ChordLayout::setDotRelativeLine(note, 0, ctx); // this manages the deletion of dots
}
}
}
Expand Down Expand Up @@ -2505,7 +2505,7 @@ void ChordLayout::placeDots(const std::vector<Chord*>& chords, const std::vector
}
// set y for this note
if (note == otherNote) {
note->setDotRelativeLine(dotMove);
ChordLayout::setDotRelativeLine(note, dotMove, ctx);
finished = true;
anchoredDots.push_back(note->line() + dotMove);
alreadyAdded[otherNote->line() + dotMove] = otherNote;
Expand All @@ -2528,7 +2528,7 @@ void ChordLayout::placeDots(const std::vector<Chord*>& chords, const std::vector
}
// set y for this note
if (note == otherNote) {
note->setDotRelativeLine(dotMove);
ChordLayout::setDotRelativeLine(note, dotMove, ctx);
finished = true;
anchoredDots.push_back(note->line() + dotMove);
break;
Expand All @@ -2541,26 +2541,78 @@ void ChordLayout::placeDots(const std::vector<Chord*>& chords, const std::vector
IF_ASSERT_FAILED(finished) {
// this should never happen
// the note is on a line and topDownNotes and bottomUpNotes are all of the lined notes
note->setDotRelativeLine(0);
ChordLayout::setDotRelativeLine(note, 0, ctx);
}
} else {
// on a space; usually this means the dot is on this same line, but there is an exception
// for a unison within the same chord.
for (Note* otherNote : note->chord()->notes()) {
if (note == otherNote) {
note->setDotRelativeLine(0); // same space as notehead
ChordLayout::setDotRelativeLine(note, 0, ctx); // same space as notehead
break;
}
if (note->line() == otherNote->line()) {
bool adjustDown = (note->chord()->voice() & 1) && !note->chord()->up();
note->setDotRelativeLine(adjustDown ? 2 : -2);
ChordLayout::setDotRelativeLine(note, adjustDown ? 2 : -2, ctx);
break;
}
}
}
}
}

void ChordLayout::setDotRelativeLine(Note* note, int dotMove, LayoutContext& ctx)
{
double y = dotMove / 2.0;
if (note->staff()->isTabStaff(note->chord()->tick())) {
// with TAB's, dotPosX is not set:
// get dot X from width of fret text and use TAB default spacing
const Staff* st = note->staff();
const StaffType* tab = st->staffTypeForElement(note);
if (tab->stemThrough()) {
// if fret mark on lines, use standard processing
if (!tab->onLines()) {
// if fret marks above lines, raise the dots by half line distance
y = -0.5;
} else if (dotMove == 0) {
bool oddVoice = note->voice() & 1;
y = oddVoice ? 0.5 : -0.5;
} else {
y = 0.5;
}
Comment on lines +2574 to +2582
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for any history or comments about the onLines() TAB dot logic
# to understand if this dead code was intentional

# Search for related comments or TODOs
rg -n -C3 'onLines|fret marks above' --type=cpp src/engraving/

Repository: musescore/MuseScore

Length of output: 12165


🏁 Script executed:

# Search for the original Note::setDotRelativeLine
rg -n 'Note::setDotRelativeLine' --type=cpp src/

Repository: musescore/MuseScore

Length of output: 45


🏁 Script executed:

# Search for other dot-related positioning logic
rg -n 'setDotRelativeLine|dotMove|NoteDot' --type=cpp src/engraving/rendering/ -A2 -B2 | head -100

# Check if there's a prior version of this function or related logic
git log --oneline -n 20 src/engraving/rendering/score/chordlayout.cpp

Repository: musescore/MuseScore

Length of output: 8044


🏁 Script executed:

# Show the commit that moved setDotRelativeLine to ChordLayout
git show a65e0990e9 --stat

# Also search for where this function came from before the move
git show a65e0990e9 -- src/engraving/rendering/score/chordlayout.cpp | head -200

Repository: musescore/MuseScore

Length of output: 50376


🏁 Script executed:

# Get the specific diff for the setDotRelativeLine function in the commit
git show a65e0990e9 -- src/engraving/rendering/score/chordlayout.cpp | grep -A 40 "setDotRelativeLine"

Repository: musescore/MuseScore

Length of output: 11084


🏁 Script executed:

# Search for where setDotRelativeLine existed before this commit
git log --all --source --reverse -S "setDotRelativeLine" -- src/dom/note.cpp | head -20

# Also check if it existed in note.cpp at all
git show a65e0990e9^:src/dom/note.cpp 2>/dev/null | grep -A 50 "setDotRelativeLine" | head -60

Repository: musescore/MuseScore

Length of output: 45


🏁 Script executed:

# Check the parent commit to see what was there before
git show a65e0990e9^:src/engraving/rendering/score/chordlayout.cpp 2>/dev/null | wc -l

# Search for setDotRelativeLine in all files in the parent commit
git show a65e0990e9^ | grep -l "setDotRelativeLine" 2>/dev/null || echo "Not found in parent commit"

# Let's check the specific lines in the current code to understand the TAB logic
git show HEAD:src/engraving/rendering/score/chordlayout.cpp | sed -n '2564,2615p'

Repository: musescore/MuseScore

Length of output: 2064


Remove or refactor the unreachable !tab->onLines() branch.

The assignment y = -0.5 when !tab->onLines() is true (line 2576) is immediately overwritten by the subsequent if (dotMove == 0) ... else ... block (lines 2578-2583). This branch is dead code and should be either removed or refactored if the intent was to condition the entire if/else block on the stemThrough() and onLines() checks.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/engraving/rendering/score/chordlayout.cpp` around lines 2574 - 2583, The
assignment to y inside the !tab->onLines() branch is dead because y is
immediately overwritten by the subsequent dotMove conditional; remove the
unreachable branch or refactor so the onLines() check actually affects the dot
positioning. Specifically, update the logic around tab->onLines(), dotMove and
note->voice() (the y variable assignment in this block of chordlayout.cpp) so
either (a) delete the if (!tab->onLines()) { y = -0.5; } line, or (b) wrap the
dotMove/voice-based assignment in an outer if/else that differentiates behavior
when tab->onLines() is false versus true, preserving the intended fret-mark
adjustment while ensuring y is not overwritten.

}
// if stems beside staff, do nothing
else {
return;
}
}
y *= note->spatium() * note->staff()->lineDistance(note->tick());

// apply to dots

int cdots = static_cast<int>(note->chord()->dots());
int ndots = static_cast<int>(note->dots().size());

int n = cdots - ndots;
for (int i = 0; i < n; ++i) {
NoteDot* dot = Factory::createNoteDot(note);
dot->setParent(note);
dot->setTrack(note->track()); // needed to know the staff it belongs to (and detect tablature)
dot->setVisible(note->visible());
ctx.mutDom().undoAddElement(dot);
}
if (n < 0) {
for (int i = 0; i < -n; ++i) {
ctx.mutDom().undoRemoveElement(note->dots().back());
}
}

for (NoteDot* dot : note->dots()) {
TLayout::layoutNoteDot(dot, dot->mutldata());
dot->mutldata()->setPosY(y);
}
}

void ChordLayout::setDotX(const std::vector<Chord*>& chords, const std::array<double, 3 * VOICES>& dotPos, const Staff* staff,
const double upDotPosX, const double downDotPosX)
{
Expand Down Expand Up @@ -2701,7 +2753,7 @@ void ChordLayout::layoutChords3(const std::vector<Chord*>& chords,
}

// Now, we can resolve note conflicts as a superchord
placeDots(chords, notes);
placeDots(chords, notes, ctx);

// Calculate the chords' dotPosX, and find the leftmost point for accidental layout
for (Chord* chord : chords) {
Expand Down Expand Up @@ -3167,7 +3219,7 @@ void ChordLayout::layoutNote2(Note* item, LayoutContext& ctx)
// with TAB's, dot Y is not calculated during layoutChords3(),
// as layoutChords3() is not even called for TAB's;
// setDotRelativeLine() actually also manages creation/deletion of NoteDot's
item->setDotRelativeLine(0);
ChordLayout::setDotRelativeLine(item, 0, ctx);

// use TAB default note-to-dot spacing
dd = STAFFTYPE_TAB_DEFAULTDOTDIST_X.toAbsolute(item->spatium());
Expand Down
3 changes: 2 additions & 1 deletion src/engraving/rendering/score/chordlayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ class ChordLayout

static void createParenGroups(Chord* chord);

static void placeDots(const std::vector<Chord*>& chords, const std::vector<Note*>& notes);
static void placeDots(const std::vector<Chord*>& chords, const std::vector<Note*>& notes, LayoutContext& ctx);

static void setDotRelativeLine(Note* note, int dotMove, LayoutContext& ctx);
static void setDotX(const std::vector<Chord*>& chords, const std::array<double, 3 * VOICES>& dotPos, const Staff* staff,
const double upDotPosX, const double downDotPosX);

Expand Down
Binary file added vtest/scores/tablature-8.mscz
Binary file not shown.
Loading