Skip to content
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
3 changes: 2 additions & 1 deletion src/engraving/api/v1/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ void Cursor::add(EngravingItem* wrapped)
s->setParent(curElement);
m_score->undoAddElement(s);
}
} // FALLTHROUGH
[[fallthrough]];
}
case ElementType::FINGERING:
case ElementType::BEND:
case ElementType::NOTEHEAD: {
Expand Down
4 changes: 2 additions & 2 deletions src/engraving/data/harmony_to_diagram.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33782,14 +33782,14 @@
<marker>circle</marker>
</string>
<string no="4">
<marker>circle</marker>
<dot fret="2">normal</dot>
</string>
<string no="5">
<marker>circle</marker>
</string>
</fretDiagram>
</FretDiagram>
<pattern>O[2-O][2-O]OOO</pattern>
<pattern>O[2-O][2-O]O[2-O]O</pattern>
<Harmony>
<name>c#m7b5/e</name>
</Harmony>
Expand Down
21 changes: 6 additions & 15 deletions src/engraving/dom/anchors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,17 @@ void MoveElementAnchors::moveElementAnchors(EngravingItem* element, KeyboardKey
return;
}

bool leftRightKey = key == Key_Left || key == Key_Right;
bool altMod = mod & AltModifier;
bool shiftMod = mod & ShiftModifier;

bool changeAnchorType = shiftMod && altMod && leftRightKey && canAnchorToEndOfPrevious(element);
bool anchorToEndOfPrevious = element->getProperty(Pid::ANCHOR_TO_END_OF_PREVIOUS).toBool();
if (changeAnchorType) {
bool changeAnchorType = altMod && canAnchorToEndOfPrevious(element);
bool resetAnchorType = !altMod && anchorToEndOfPrevious;
if (changeAnchorType || resetAnchorType) {
element->undoChangeProperty(Pid::ANCHOR_TO_END_OF_PREVIOUS, !anchorToEndOfPrevious,
element->propertyFlags(Pid::ANCHOR_TO_END_OF_PREVIOUS));

bool doesntNeedMoveSeg = ((key == Key_Left && anchorToEndOfPrevious) || (key == Key_Right && !anchorToEndOfPrevious));
if (doesntNeedMoveSeg) {
bool needMoveSeg = (key == Key_Left && anchorToEndOfPrevious) || (key == Key_Right && !anchorToEndOfPrevious);
if (!needMoveSeg) {
checkMeasureBoundariesAndMoveIfNeed(element);
return;
}
Expand Down Expand Up @@ -199,7 +198,7 @@ void MoveElementAnchors::checkMeasureBoundariesAndMoveIfNeed(EngravingItem* elem
Measure* curMeasure = curSeg->measure();
Measure* prevMeasure = curMeasure->prevMeasure();
bool anchorToEndOfPrevious = element->getProperty(Pid::ANCHOR_TO_END_OF_PREVIOUS).toBool();
bool needMoveToNext = curTick == curMeasure->endTick() && anchorToEndOfPrevious;
bool needMoveToNext = curTick == curMeasure->endTick() && !anchorToEndOfPrevious;
bool needMoveToPrevious = curSeg->rtick().isZero() && anchorToEndOfPrevious && prevMeasure;

if (!needMoveToPrevious && !needMoveToNext) {
Expand Down Expand Up @@ -251,14 +250,6 @@ void MoveElementAnchors::moveElementAnchorsOnDrag(EngravingItem* element, EditDa

void MoveElementAnchors::moveSegment(EngravingItem* element, bool forward)
{
if (canAnchorToEndOfPrevious(element)) {
bool cachedAnchorToEndOfPrevious = element->getProperty(Pid::ANCHOR_TO_END_OF_PREVIOUS).toBool();
element->undoResetProperty(Pid::ANCHOR_TO_END_OF_PREVIOUS);
if (cachedAnchorToEndOfPrevious && forward) {
return;
}
}

Segment* curSeg = toSegment(element->parentItem());
Segment* newSeg = getNewSegment(element, curSeg, forward);

Expand Down
118 changes: 26 additions & 92 deletions src/engraving/dom/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@ FBox::FBox(System* parent)
resetProperty(Pid::BOTTOM_MARGIN);
resetProperty(Pid::TOP_GAP);
resetProperty(Pid::BOTTOM_GAP);
resetProperty(Pid::EXCLUDE_FROM_OTHER_PARTS);
resetProperty(Pid::APPEARANCE_LINKED_TO_MASTER);
resetProperty(Pid::POSITION_LINKED_TO_MASTER);
}

void FBox::init()
Expand All @@ -722,7 +725,7 @@ void FBox::init()

StringList diagramsNamesInScore;
std::vector<EngravingItem*> harmonyOrDiagramsInScore;
for (mu::engraving::Segment* segment = masterScore()->firstSegment(mu::engraving::SegmentType::ChordRest); segment;
for (mu::engraving::Segment* segment = score()->firstSegment(mu::engraving::SegmentType::ChordRest); segment;
segment = segment->next1(mu::engraving::SegmentType::ChordRest)) {
for (EngravingItem* item : segment->annotations()) {
if (!item || !item->part()) {
Expand All @@ -749,6 +752,8 @@ void FBox::init()
}
}

m_diagramsOrderInScore = diagramsNamesInScore;

for (size_t i = 0; i < oldDiagramsNames.size(); ++i) {
String oldName = oldDiagramsNames[i];
if (!muse::contains(diagramsNamesInScore, oldName)) {
Expand All @@ -766,19 +771,6 @@ void FBox::init()
score()->undo(new AddFretDiagramToFretBox(newDiagram, idx));
}
}

StringList currentDiagrams;
for (EngravingItem* item : el()) {
currentDiagrams.push_back(toFretDiagram(item)->harmonyText().toLower());
}

if (!m_invisibleDiagrams.empty()) {
updateInvisibleDiagrams(currentDiagrams);
}

if (!m_diagramsOrder.empty()) {
updateDiagramsOrder(currentDiagrams);
}
}

void FBox::add(EngravingItem* e)
Expand Down Expand Up @@ -848,9 +840,7 @@ PropertyValue FBox::getProperty(Pid propertyId) const
case Pid::RIGHT_MARGIN:
return m_contentAlignmentH == AlignH::RIGHT ? VBox::getProperty(propertyId) : PropertyValue();
case Pid::FRET_FRAME_DIAGRAMS_ORDER:
return !m_diagramsOrder.empty() ? m_diagramsOrder.join(FRET_BOX_DIAGRAMS_SEPARATOR) : PropertyValue();
case Pid::FRET_FRAME_INVISIBLE_DIAGRAMS:
return !m_invisibleDiagrams.empty() ? m_invisibleDiagrams.join(FRET_BOX_DIAGRAMS_SEPARATOR) : PropertyValue();
return diagramsOrder().join(FRET_BOX_DIAGRAMS_SEPARATOR);
default:
return VBox::getProperty(propertyId);
}
Expand Down Expand Up @@ -880,10 +870,7 @@ bool FBox::setProperty(Pid propertyId, const PropertyValue& val)
resetProperty(Pid::RIGHT_MARGIN);
break;
case Pid::FRET_FRAME_DIAGRAMS_ORDER:
m_diagramsOrder = val.value<String>().split(FRET_BOX_DIAGRAMS_SEPARATOR);
break;
case Pid::FRET_FRAME_INVISIBLE_DIAGRAMS:
m_invisibleDiagrams = val.value<String>().split(FRET_BOX_DIAGRAMS_SEPARATOR);
reorderElements(val.value<String>().split(FRET_BOX_DIAGRAMS_SEPARATOR));
break;
default:
return VBox::setProperty(propertyId, val);
Expand All @@ -907,9 +894,12 @@ PropertyValue FBox::propertyDefault(Pid propertyId) const
case Pid::FRET_FRAME_H_ALIGN:
return static_cast<int>(AlignH::HCENTER);
case Pid::FRET_FRAME_DIAGRAMS_ORDER:
return PropertyValue();
case Pid::FRET_FRAME_INVISIBLE_DIAGRAMS:
return PropertyValue();
return m_diagramsOrderInScore.join(FRET_BOX_DIAGRAMS_SEPARATOR);
case Pid::EXCLUDE_FROM_OTHER_PARTS:
return true;
case Pid::APPEARANCE_LINKED_TO_MASTER:
case Pid::POSITION_LINKED_TO_MASTER:
return false;
default:
return VBox::propertyDefault(propertyId);
}
Expand Down Expand Up @@ -946,81 +936,25 @@ void FBox::undoReorderElements(const StringList& newOrder)
triggerLayout();
}

ElementList FBox::orderedElements(bool includeInvisible) const
void FBox::reorderElements(const StringList& newOrder)
{
ElementList elements = el();
const StringList& diagramsOrder = this->diagramsOrder();
if (diagramsOrder.empty()) {
return elements;
}

std::sort(elements.begin(), elements.end(), [&diagramsOrder](const EngravingItem* a, const EngravingItem* b) {
const FretDiagram* diagramA = toFretDiagram(a);
const String diagramAHarmonyName = diagramA->harmonyText().toLower();

const FretDiagram* diagramB = toFretDiagram(b);
const String diagramBHarmonyName = diagramB->harmonyText().toLower();

auto itA = std::find(diagramsOrder.begin(), diagramsOrder.end(), diagramAHarmonyName);
auto itB = std::find(diagramsOrder.begin(), diagramsOrder.end(), diagramBHarmonyName);

return itA < itB;
std::sort(m_el.begin(), m_el.end(), [&](EngravingItem* a, EngravingItem* b) {
String nameA = toFretDiagram(a)->harmonyText().toLower();
String nameB = toFretDiagram(b)->harmonyText().toLower();
auto iterA = std::find(newOrder.begin(), newOrder.end(), nameA);
auto iterB = std::find(newOrder.begin(), newOrder.end(), nameB);
return iterA < iterB;
});

if (!includeInvisible) {
const StringList& invisibleDiagrams = this->invisibleDiagrams();

muse::remove_if(elements, [&invisibleDiagrams](const EngravingItem* element){
const FretDiagram* diagram = toFretDiagram(element);
const String diagramHarmonyName = diagram->harmonyText().toLower();
return muse::contains(invisibleDiagrams, diagramHarmonyName);
});
}

return elements;
}

void FBox::undoSetInvisibleDiagrams(const StringList& invisibleDiagrams)
StringList FBox::diagramsOrder() const
{
StringList diagrams;
for (const String& harmonyName : invisibleDiagrams) {
diagrams.push_back(harmonyName.toLower());
}

undoChangeProperty(Pid::FRET_FRAME_INVISIBLE_DIAGRAMS, diagrams.join(FRET_BOX_DIAGRAMS_SEPARATOR));
triggerLayout();
}

void FBox::updateDiagramsOrder(const StringList& currentDiagrams)
{
if (currentDiagrams == m_diagramsOrder) {
return;
}

m_diagramsOrder.erase(std::remove_if(m_diagramsOrder.begin(), m_diagramsOrder.end(),
[&](const String& harmonyName) { return !muse::contains(currentDiagrams, harmonyName); }),
m_diagramsOrder.end());

String previousHarmonyName;
for (const String& harmonyName : currentDiagrams) {
if (!muse::contains(m_diagramsOrder, harmonyName)) {
size_t index = 0;
if (!previousHarmonyName.empty()) {
index = std::find(m_diagramsOrder.begin(), m_diagramsOrder.end(), previousHarmonyName) - m_diagramsOrder.begin() + 1;
}

m_diagramsOrder.insert(m_diagramsOrder.begin() + index, harmonyName);
}

previousHarmonyName = harmonyName;
StringList result;
for (EngravingItem* item : m_el) {
result.push_back(toFretDiagram(item)->harmonyText().toLower());
}
}

void FBox::updateInvisibleDiagrams(const StringList& currentDiagrams)
{
m_invisibleDiagrams.erase(std::remove_if(m_invisibleDiagrams.begin(), m_invisibleDiagrams.end(),
[&](const String& harmonyName) { return !muse::contains(currentDiagrams, harmonyName); }),
m_invisibleDiagrams.end());
return result;
}

//---------------------------------------------------------
Expand Down
12 changes: 3 additions & 9 deletions src/engraving/dom/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,19 +208,14 @@ class FBox : public VBox
std::vector<PointF> gripsPositions(const EditData&) const override;

void undoReorderElements(const StringList& newOrder);
const StringList& diagramsOrder() const { return m_diagramsOrder; }

void undoSetInvisibleDiagrams(const StringList& invisibleDiagrams);
const StringList& invisibleDiagrams() const { return m_invisibleDiagrams; }

ElementList orderedElements(bool includeInvisible = false) const;
void reorderElements(const StringList& newOrder);
StringList diagramsOrder() const;

bool needsRebuild() const { return m_needsRebuild; }
void setNeedsRebuild(bool v) { m_needsRebuild = v; }

private:

void updateDiagramsOrder(const StringList& currentDiagrams);
void updateInvisibleDiagrams(const StringList& currentDiagrams);
size_t computeInsertionIdx(const String& nameOfDiagramBeforeThis);

Expand All @@ -234,8 +229,7 @@ class FBox : public VBox

AlignH m_contentAlignmentH = AlignH::HCENTER;

StringList /*harmonyNames*/ m_diagramsOrder;
StringList /*harmonyNames*/ m_invisibleDiagrams;
StringList m_diagramsOrderInScore;
};

//---------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/engraving/dom/chordlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,6 @@ const std::list<RenderActionPtr >& ParsedChord::renderList(const ChordList* cl,
// Jazz superscript
if (superScriptModifier) {
// Set scale
LOGI() << "SCALE: " << cl->stackedModifierMag();
m_renderList.emplace_back(new RenderActionScale(cl->stackedModifierMag()));
// Move to x-height
m_renderList.emplace_back(new RenderActionPush());
Expand Down
Loading
Loading