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

Retain dynamics and hairpins properties upon respective drop operations #23305

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
When dropping dynamic on dynamic, don't create new one, but edit the …
…current
  • Loading branch information
mike-spa committed Jun 21, 2024
commit 73cd6c21eea9e96bacb836474024dc33c57272e3
27 changes: 16 additions & 11 deletions src/engraving/dom/dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,19 +456,24 @@ EngravingItem* Dynamic::drop(EditData& ed)
return item;
}

if (!(item->isDynamic() || item->isExpression())) {
return nullptr;
}

item->setTrack(track());
item->setParent(segment());
score()->undoAddElement(item);
item->undoChangeProperty(Pid::PLACEMENT, placement(), PropertyFlags::UNSTYLED);
if (item->isDynamic()) {
toDynamic(item)->setAnchorToEndOfPrevious(anchorToEndOfPrevious());
score()->undoRemoveElement(this); // swap this dynamic for the newly added one
Dynamic* dynamic = toDynamic(item);
undoChangeProperty(Pid::DYNAMIC_TYPE, dynamic->dynamicType());
undoChangeProperty(Pid::TEXT, dynamic->xmlText());
delete dynamic;
ed.dropElement = this;
return this;
}

if (item->isExpression()) {
item->setTrack(track());
item->setParent(segment());
toExpression(item)->setApplyToVoice(applyToVoice());
score()->undoAddElement(item);
return item;
}
return item;

return nullptr;
}

int Dynamic::dynamicVelocity(DynamicType t)
Expand Down
2 changes: 2 additions & 0 deletions src/engraving/dom/edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3853,6 +3853,8 @@ void Score::addHairpinToDynamic(Hairpin* hairpin, Dynamic* dynamic)

hairpin->setTick2(endTick);

hairpin->setApplyToVoice(dynamic->applyToVoice());

undoAddElement(hairpin);
}

Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/hairpin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ EngravingItem* HairpinSegment::drop(EditData& data)
Dynamic* d = toDynamic(e->clone());
d->setTrack(hairpin()->track());
d->setParent(segment);
d->setApplyToVoice(hairpin()->applyToVoice());
score()->undoAddElement(d);

return d;
Expand Down
5 changes: 4 additions & 1 deletion src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,10 @@ void NotationInteraction::applyDropPaletteElement(mu::engraving::Score* score, m
}

if (el && el->hasVoiceApplicationProperties()) {
el->setInitialTrackAndVoiceApplication(el->track());
// If target has voice application properties, dropped element takes those and discards the default
if (!target->hasVoiceApplicationProperties()) {
el->setInitialTrackAndVoiceApplication(el->track());
}
}

if (el && !score->inputState().noteEntryMode()) {
Expand Down
Loading