Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various articulation improvements #17303

Merged
merged 1 commit into from May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 43 additions & 3 deletions src/engraving/libmscore/articulation.cpp
Expand Up @@ -622,6 +622,28 @@ bool Articulation::isOrnament(int subtype)
return ornaments.find(symId) != ornaments.end();
}

bool Articulation::isBasicArticulation() const
{
static const std::set<SymId> articulations{
SymId::articAccentAbove, SymId::articAccentBelow,
SymId::articStaccatoAbove, SymId::articStaccatoBelow,
SymId::articTenutoAbove, SymId::articTenutoBelow,
SymId::articMarcatoAbove, SymId::articMarcatoBelow,

SymId::articAccentStaccatoAbove, SymId::articAccentStaccatoBelow,
SymId::articMarcatoStaccatoAbove, SymId::articMarcatoStaccatoBelow,
SymId::articMarcatoTenutoAbove, SymId::articMarcatoTenutoBelow,
SymId::articTenutoStaccatoAbove, SymId::articTenutoStaccatoBelow,
SymId::articTenutoAccentAbove, SymId::articTenutoAccentBelow,
SymId::articStaccatissimoAbove, SymId::articStaccatissimoBelow,
SymId::articStaccatissimoStrokeAbove, SymId::articStaccatissimoStrokeBelow,
SymId::articStaccatissimoWedgeAbove, SymId::articStaccatissimoWedgeBelow,
SymId::articStressAbove, SymId::articStressBelow
};
SymId symId = static_cast<SymId>(subtype());
return articulations.find(symId) != articulations.end();
}

//---------------------------------------------------------
// accessibleInfo
//---------------------------------------------------------
Expand Down Expand Up @@ -766,6 +788,14 @@ static std::map<SymId, ArticulationGroup> articulationAboveSplitGroups = {
{ SymId::articMarcatoTenutoAbove, { SymId::articTenutoAbove, SymId::articMarcatoAbove } },
};

static std::map<SymId, ArticulationGroup> articulationBelowSplitGroups = {
{ SymId::articAccentStaccatoBelow, { SymId::articStaccatoBelow, SymId::articAccentBelow } },
{ SymId::articTenutoAccentBelow, { SymId::articTenutoBelow, SymId::articAccentBelow } },
{ SymId::articTenutoStaccatoBelow, { SymId::articTenutoBelow, SymId::articStaccatoBelow } },
{ SymId::articMarcatoStaccatoBelow, { SymId::articStaccatoBelow, SymId::articMarcatoBelow } },
{ SymId::articMarcatoTenutoBelow, { SymId::articTenutoBelow, SymId::articMarcatoBelow } },
};

static std::map<ArticulationGroup, SymId> articulationAboveJoinGroups = {
{ { SymId::articStaccatoAbove, SymId::articAccentAbove }, SymId::articAccentStaccatoAbove },
{ { SymId::articTenutoAbove, SymId::articAccentAbove }, SymId::articTenutoAccentAbove },
Expand Down Expand Up @@ -795,11 +825,20 @@ std::set<SymId> splitArticulations(const std::set<SymId>& articulationSymbolIds)
for (const SymId& articulationSymbolId: articulationSymbolIds) {
auto artic = articulationAboveSplitGroups.find(articulationSymbolId);
if (artic != articulationAboveSplitGroups.end()) {
// check above
ArticulationGroup group = articulationAboveSplitGroups[articulationSymbolId];
result.insert(group.first);
result.insert(group.second);
} else {
result.insert(articulationSymbolId);
// check below
artic = articulationBelowSplitGroups.find(articulationSymbolId);
if (artic != articulationBelowSplitGroups.end()) {
ArticulationGroup group = articulationBelowSplitGroups[articulationSymbolId];
result.insert(group.first);
result.insert(group.second);
} else {
result.insert(articulationSymbolId);
}
}
}

Expand Down Expand Up @@ -911,8 +950,9 @@ std::set<SymId> updateArticulations(const std::set<SymId>& articulationSymbolIds
default:
break;
}

return joinArticulations(splittedArticulations);
// we no longer want to join articulations when adding or removing individual ones. combined articulations can still
// be added by the palette (which doesn't perform any of this splitting)
return splittedArticulations;
}

std::set<SymId> flipArticulations(const std::set<SymId>& articulationSymbolIds, PlacementV placement)
Expand Down
9 changes: 9 additions & 0 deletions src/engraving/libmscore/articulation.h
Expand Up @@ -61,6 +61,14 @@ enum class ArticulationAnchor : char {
BOTTOM_CHORD, // attribute is placed at bottom of chord
};

enum class ArticulationStemSideAlign : char
{
// horizontal align for stem-side articulation layout
STEM, // attribute is placed directly over the stem
NOTEHEAD, // attribute is centered on the notehead
AVERAGE, // attribute is placed at the average of stem pos and notehead center
};

// flags:
enum class ArticulationShowIn : char {
PITCHED_STAFF = 1, TABLATURE = 2
Expand Down Expand Up @@ -198,6 +206,7 @@ class Articulation final : public EngravingItem

bool isOrnament() const;
static bool isOrnament(int subtype);
bool isBasicArticulation() const;

void doAutoplace();

Expand Down