Skip to content

Commit

Permalink
Change moveAlt() to take a MoveDirection
Browse files Browse the repository at this point in the history
  • Loading branch information
Jojo-Schmitz committed Sep 3, 2024
1 parent 9f3422f commit 9d7462c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/engraving/dom/navigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "staff.h"
#include "soundflag.h"
#include "guitarbend.h"
#include "notation/notationtypes.h"

using namespace mu;

Expand Down Expand Up @@ -392,12 +393,12 @@ Note* Score::downAltCtrl(Note* note) const
// or top/bottom of next/previous track's chord if at wit's end
//---------------------------------------------------------

EngravingItem* Score::moveAlt(EngravingItem* element, DirectionV direction)
EngravingItem* Score::moveAlt(EngravingItem* element, notation::MoveDirection direction)
{
EngravingItem* result = nullptr;
ChordRest* cr = nullptr;
auto originalTrack = element->track();
bool moveUp = (direction == DirectionV::UP);
bool moveUp = (direction == notation::MoveDirection::Up);
bool isNote = element->isNote();
bool isRest = element->isRest();

Expand Down
6 changes: 5 additions & 1 deletion src/engraving/dom/score.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ namespace mu::engraving::compat {
class WriteScoreHook;
}

namespace mu::notation {
enum class MoveDirection;
}

namespace mu::engraving {
class Articulation;
class Audio;
Expand Down Expand Up @@ -934,7 +938,7 @@ class Score : public EngravingObject, public muse::Injectable
Note* upAltCtrl(Note*) const;
EngravingItem* downAlt(EngravingItem*);
Note* downAltCtrl(Note*) const;
EngravingItem* moveAlt(EngravingItem*, DirectionV);
EngravingItem* moveAlt(EngravingItem*, notation::MoveDirection);

EngravingItem* firstElement(bool frame = true);
EngravingItem* lastElement(bool frame = true);
Expand Down
7 changes: 3 additions & 4 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,16 +701,15 @@ void NotationInteraction::moveChordNoteSelection(MoveDirection d)
EngravingItem* oldSingle = currentSingle;
bool isRange = selection.isRange();
std::vector<EngravingItem*> notes;
DirectionV dir = d == MoveDirection::Up ? DirectionV::UP : DirectionV::DOWN;

// Single traverse:
if (currentSingle && (currentSingle->isNote() || currentSingle->isRest())) {
EngravingItem* newSingle = _score.moveAlt(currentSingle, dir);
EngravingItem* newSingle = _score.moveAlt(currentSingle, d);
if (newSingle == currentSingle) {
return;
}
while (newSingle && newSingle->isRest() && toRest(newSingle)->isGap()) {
newSingle = _score.moveAlt(newSingle, dir);
newSingle = _score.moveAlt(newSingle, d);
if (newSingle == oldSingle) {
break;
}
Expand All @@ -729,7 +728,7 @@ void NotationInteraction::moveChordNoteSelection(MoveDirection d)
: selectedNote->chord()->upNote();
notes.emplace_back(newSelection);
} else { // List
auto newSelection = _score.moveAlt(selectedNote, dir);
auto newSelection = _score.moveAlt(selectedNote, d);
bool keepSelection = !newSelection;
if (newSelection) {
if (newSelection->isNote()) {
Expand Down
2 changes: 0 additions & 2 deletions src/notation/notationtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#ifndef MU_NOTATION_NOTATIONTYPES_H
#define MU_NOTATION_NOTATIONTYPES_H

#include <QPixmap>
#include <QDate>
#include <unordered_set>

#include "translation.h"
Expand Down

0 comments on commit 9d7462c

Please sign in to comment.