Skip to content

Commit ab71a5b

Browse files
committed
Align left to left of note, centre to centre etc.
Change tooltips in inspector Refine align and position buttons in edit style Fix button spacing Add vtest Migrate old scores Refactor `positionRelativeToNoteheadRest`
1 parent f960340 commit ab71a5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+809
-715
lines changed

src/engraving/compat/engravingcompat.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ void EngravingCompat::doPreLayoutCompatIfNeeded(MasterScore* score)
4141
{
4242
int mscVersion = score->mscVersion();
4343

44+
if (mscVersion < 470) {
45+
adjustTextOffset(score);
46+
}
47+
4448
if (mscVersion < 460) {
4549
resetMarkerLeftFontSize(score);
4650
resetRestVerticalOffsets(score);
@@ -233,6 +237,39 @@ void EngravingCompat::adjustVBoxDistances(MasterScore* masterScore)
233237
}
234238
}
235239

240+
void EngravingCompat::adjustTextOffset(MasterScore* masterScore)
241+
{
242+
auto doAdjustTextOffset = [](EngravingItem* item) {
243+
if (!item->isTextBase()) {
244+
return;
245+
}
246+
247+
TextBase* text = toTextBase(item);
248+
249+
// Staff text, system text, and harp pedal diagrams are the only types which are attached to notes and weren't already
250+
// placed with their left edges / centres / right edges aligned to the left / centre / right of the notehead
251+
if (text->positionRelativeToNoteheadRest() && (text->isStaffText() || text->isSystemText() || text->isHarpPedalDiagram())) {
252+
double mag = item->staff() ? item->staff()->staffMag(item) : 1.0;
253+
double xAdj = item->symWidth(SymId::noteheadBlack) * mag;
254+
255+
switch (text->position()) {
256+
case AlignH::HCENTER:
257+
text->setProperty(Pid::OFFSET, PointF(text->offset().x() - xAdj / 2, text->offset().y()));
258+
break;
259+
case AlignH::RIGHT:
260+
text->setProperty(Pid::OFFSET, PointF(text->offset().x() - xAdj, text->offset().y()));
261+
break;
262+
default:
263+
break;
264+
}
265+
}
266+
};
267+
268+
for (Score* score : masterScore->scoreList()) {
269+
score->scanElements(doAdjustTextOffset);
270+
}
271+
}
272+
236273
void EngravingCompat::doPostLayoutCompatIfNeeded(MasterScore* score)
237274
{
238275
bool needRelayout = false;

src/engraving/compat/engravingcompat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class EngravingCompat
4040
static void resetMarkerLeftFontSize(MasterScore* masterScore);
4141
static void resetRestVerticalOffsets(MasterScore* masterScore);
4242
static void adjustVBoxDistances(MasterScore* masterScore);
43+
static void adjustTextOffset(MasterScore* masterScore);
4344

4445
static bool relayoutUserModifiedCrossStaffBeams(MasterScore* score);
4546
static bool resetHookHeightSign(MasterScore* masterScore);

src/engraving/dom/dynamic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class Dynamic final : public TextBase
120120

121121
bool isEditAllowed(EditData&) const override;
122122

123+
bool positionRelativeToNoteheadRest() const override { return true; }
124+
123125
Hairpin* leftHairpin() const { return m_leftHairpin; }
124126
Hairpin* rightHairpin() const { return m_rightHairpin; }
125127

src/engraving/dom/expression.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@ class Expression final : public TextBase
5959
bool hasVoiceAssignmentProperties() const override { return true; }
6060

6161
void reset() override;
62+
63+
bool positionRelativeToNoteheadRest() const override { return true; }
6264
};
6365
}

src/engraving/dom/figuredbass.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ class FiguredBass final : public TextBase
291291
bool setProperty(Pid propertyId, const PropertyValue&) override;
292292
PropertyValue propertyDefault(Pid) const override;
293293

294+
bool positionRelativeToNoteheadRest() const override { return true; }
295+
294296
size_t itemsCount() const { return m_items.size(); }
295297
void appendItem(FiguredBassItem* item) { m_items.push_back(item); }
296298
const std::vector<FiguredBassItem*>& items() const { return m_items; }

src/engraving/dom/fingering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Fingering final : public TextBase
5656
String accessibleInfo() const override;
5757

5858
bool isOnCrossBeamSide() const;
59+
60+
bool positionRelativeToNoteheadRest() const override { return false; }
5961
};
6062
} // namespace mu::engraving
6163
#endif

src/engraving/dom/guitarbend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,7 @@ class GuitarBendText final : public TextBase
266266
GuitarBendText* clone() const override { return new GuitarBendText(*this); }
267267

268268
bool isEditable() const override { return false; }
269+
270+
bool positionRelativeToNoteheadRest() const override { return false; }
269271
};
270272
}

src/engraving/dom/hammeronpulloff.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class HammerOnPullOffText final : public TextBase
5454

5555
PropertyValue propertyDefault(Pid id) const override;
5656

57+
bool positionRelativeToNoteheadRest() const override { return false; }
58+
5759
private:
5860
Chord* m_startChord = nullptr;
5961
Chord* m_endChord = nullptr;

src/engraving/dom/harmony.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,11 @@ PropertyValue Harmony::propertyDefault(Pid id) const
16151615
return v;
16161616
}
16171617

1618+
bool Harmony::positionRelativeToNoteheadRest() const
1619+
{
1620+
return !parent()->isFretDiagram();
1621+
}
1622+
16181623
//---------------------------------------------------------
16191624
// getPropertyStyle
16201625
//---------------------------------------------------------

src/engraving/dom/harmony.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class Harmony final : public TextBase
289289
bool setProperty(Pid propertyId, const PropertyValue& v) override;
290290
PropertyValue propertyDefault(Pid id) const override;
291291

292+
bool positionRelativeToNoteheadRest() const override;
293+
292294
double mag() const override;
293295

294296
double bassScale() const { return m_bassScale; }

0 commit comments

Comments
 (0)