-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Copy annotations and hairpins when exploding/imploding staves #23787
Conversation
d97ae16
to
9bd670a
Compare
src/engraving/dom/engravingitem.cpp
Outdated
const VoiceAssignment voiceAssignment = getProperty(Pid::VOICE_ASSIGNMENT).value<VoiceAssignment>(); | ||
if (voiceAssignment == VoiceAssignment::CURRENT_VOICE_ONLY && track() == refTrack) { | ||
return true; | ||
} | ||
|
||
if (voiceAssignment == VoiceAssignment::ALL_VOICE_IN_STAFF && track2staff(track()) == track2staff(refTrack)) { | ||
return true; | ||
} | ||
|
||
const Part* elementPart = part(); | ||
if (!elementPart) { | ||
return false; | ||
} | ||
|
||
if (voiceAssignment == VoiceAssignment::ALL_VOICE_IN_INSTRUMENT && (elementPart->startTrack() <= refTrack | ||
&& elementPart->endTrack() - 1 >= refTrack)) { | ||
return true; | ||
} | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is repeated identical in Spanner::elementAppliesToTrack in order to check for both track() and track2(). Here's a suggestion for how to improve it.
Move this bit of code into a protected static function, something like:
protected:
static bool elementAppliesToTrack(track_idx_t elementTrack, track_idx_t refTrack, VoiceAssignment voiceAssignment);
Then you can have:
bool EngravingItem::appliesToTrack(track_idx_t refTrack) const
{
if (!hasVoiceAssignmentProperties()) {
return refTrack == track();
}
return elementAppliesToTrack(track(), refTrack, voiceAssignment());
}
and the Spanner version as:
bool Spanner::appliesToTrack(track_idx_t refTrack) const
{
if (!hasVoiceAssignmentProperties()) {
return refTrack == track() || refTrack == track2();
}
return elementAppliesToTrack(track(), refTrack, voiceAssignment()) || elementAppliesToTrack(track2(), refTrack, voiceAssignment());
}
src/engraving/dom/edit.cpp
Outdated
|
||
EngravingItem* newAnnotation; | ||
//does a linked clone to create just this element | ||
//otherwise element will be add in every linked stave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused by this comment. Do I understand correctly that the cloneVoice function is used both for creating linked copies (as in parts) and non-linked copies (as in the explode command)? What do you mean by "does a linked clone to create just this element"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, copied this from above. It's unclear, I'll correct it!
9bd670a
to
7a836f3
Compare
Resolves: #23767
This PR copies annotations (dynamics, text etc.) and hairpins when exploding and imploding staves. Where there are voice assignments (in the case of dynamics and hairpins), these are taken into account.
Screen.Recording.2024-07-26.at.17.13.55.mov