Skip to content

Commit

Permalink
Dynamics popup: change existing hairpin instead of creating new one
Browse files Browse the repository at this point in the history
Resolves: point 8 from musescore#26019
  • Loading branch information
cbjeukendrup committed Feb 27, 2025
1 parent 82475d4 commit ec856e5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/notation/view/internal/dynamicpopupmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,27 @@ void DynamicPopupModel::addHairpinToDynamic(ItemType itemType)
return;
}

beginCommand(TranslatableString("undoableAction", "Add hairpin"));
engraving::Dynamic* dynamic = toDynamic(m_item);

Hairpin* pin = Factory::createHairpin(m_item->score()->dummy()->segment());
if (itemType == ItemType::Crescendo) {
pin->setHairpinType(HairpinType::CRESC_HAIRPIN);
} else if (itemType == ItemType::Decrescendo) {
pin->setHairpinType(HairpinType::DECRESC_HAIRPIN);
}
HairpinType hairpinType = itemType == ItemType::Crescendo
? HairpinType::CRESC_HAIRPIN
: HairpinType::DECRESC_HAIRPIN;

m_item->score()->addHairpinToDynamic(pin, toDynamic(m_item));
if (Hairpin* existingHairpin = dynamic->rightHairpin()) {
if (existingHairpin->hairpinType() == hairpinType) {
return;
}
beginCommand(TranslatableString("undoableAction", "Change hairpin type"));
existingHairpin->undoChangeProperty(Pid::HAIRPIN_TYPE, int(hairpinType));
endCommand();
updateNotation();
return;
}

beginCommand(TranslatableString("undoableAction", "Add hairpin"));
Hairpin* hairpin = Factory::createHairpin(m_item->score()->dummy()->segment());
hairpin->setHairpinType(hairpinType);
m_item->score()->addHairpinToDynamic(hairpin, dynamic);
endCommand();
updateNotation();
}

0 comments on commit ec856e5

Please sign in to comment.