Skip to content

Commit 04122ec

Browse files
authored
Merge pull request #22860 from miiizen/tab-full-layout
Avoid collisions in full tab layout
2 parents 229fb0a + 41f9c7a commit 04122ec

File tree

9 files changed

+137
-83
lines changed

9 files changed

+137
-83
lines changed

src/engraving/dom/note.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,10 @@ double Note::bboxRightPos() const
10051005
//---------------------------------------------------------
10061006
double Note::headBodyWidth() const
10071007
{
1008+
const StaffType* st = staffType();
1009+
if (st && st->isTabStaff()) {
1010+
return tabHeadWidth(st);
1011+
}
10081012
return headWidth() + 2 * bboxXShift();
10091013
}
10101014

@@ -3818,4 +3822,10 @@ bool Note::negativeFretUsed() const
38183822
{
38193823
return configuration()->negativeFretsAllowed() && m_fret < 0;
38203824
}
3825+
3826+
int Note::stringOrLine() const
3827+
{
3828+
// The number string() returns doesn't count spaces. This should be used where it is expected even numbers are spaces and odd are lines
3829+
return staff()->staffType(tick())->isTabStaff() ? string() * 2 : line();
3830+
}
38213831
}

src/engraving/dom/note.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class Note final : public EngravingItem
272272
bool negativeFretUsed() const;
273273
int string() const { return m_string; }
274274
void setString(int val) { m_string = val; }
275+
int stringOrLine() const;
275276

276277
bool ghost() const { return m_ghost; }
277278
void setGhost(bool val) { m_ghost = val; }

src/engraving/rendering/dev/chordlayout.cpp

Lines changed: 119 additions & 80 deletions
Large diffs are not rendered by default.

src/engraving/rendering/dev/tdraw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,7 @@ void TDraw::draw(const Note* item, Painter* painter)
22452245
const StaffType* tab = st->staffTypeForElement(item);
22462246
// draw background, if required (to hide a segment of string line or to show a fretting conflict)
22472247
if (!tab->linesThrough() || item->fretConflict()) {
2248-
double d = item->spatium() * .1;
2248+
double d = item->style().styleS(Sid::tabFretPadding).val() * item->spatium();
22492249
RectF bb = RectF(ldata->bbox().x() - d,
22502250
tab->fretMaskY() * item->magS(),
22512251
ldata->bbox().width() + 2 * d,
@@ -2832,7 +2832,7 @@ void TDraw::draw(const Symbol* item, Painter* painter)
28322832
// Draw background for parentheses on TAB staves
28332833
auto config = item->configuration();
28342834
const Symbol::LayoutData* ldata = item->ldata();
2835-
double d = item->spatium() * .1;
2835+
double d = item->style().styleS(Sid::tabFretPadding).val() * item->spatium();
28362836
RectF bb = RectF(ldata->bbox().x() - d,
28372837
ldata->bbox().y() - d,
28382838
ldata->bbox().width() + 2 * d,

src/engraving/rendering/dev/tlayout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4321,7 +4321,7 @@ void TLayout::layoutNote(const Note* item, Note::LayoutData* ldata)
43214321
const_cast<Note*>(item)->setHeadHasParentheses(false, /* addToLinked= */ false);
43224322
}
43234323

4324-
double w = item->tabHeadWidth(tab); // !! use _fretString
4324+
double w = item->tabHeadWidth(tab);
43254325
double mags = item->magS();
43264326

43274327
const MStyle& style = item->style();

src/engraving/style/styledef.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,8 @@ const std::array<StyleDef::StyleValue, size_t(Sid::STYLES)> StyleDef::styleValue
17011701
styleDef(tabParenthesizeTiedFret, int(ParenthesizeTiedFret::START_OF_SYSTEM)),
17021702
styleDef(parenthesizeTiedFretIfArticulation, true),
17031703

1704+
styleDef(tabFretPadding, Spatium(0.1)),
1705+
17041706
styleDef(chordlineThickness, Spatium(0.16)),
17051707

17061708
styleDef(dummyMusicalSymbolsScale, 1.0),

src/engraving/style/styledef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,6 +1711,8 @@ enum class Sid {
17111711
tabParenthesizeTiedFret,
17121712
parenthesizeTiedFretIfArticulation,
17131713

1714+
tabFretPadding,
1715+
17141716
chordlineThickness,
17151717

17161718
dummyMusicalSymbolsScale,

vtest/scores/tablature-2.mscz

3.18 KB
Binary file not shown.

vtest/scores/tablature-5.mscz

24.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)