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 fbd62d7
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 37 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
4 changes: 2 additions & 2 deletions src/instrumentsscene/internal/selectinstrumentscenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RetVal<Instrument> SelectInstrumentsScenario::selectInstrument(const InstrumentK
return selectedInstruments.ret;
}

const InstrumentTemplate& templ = selectedInstruments.val.instruments.first().instrumentTemplate;
const InstrumentTemplate& templ = selectedInstruments.val.instruments.front().instrumentTemplate;

return RetVal<Instrument>::make_ok(Instrument::fromTemplate(&templ));
}
Expand Down Expand Up @@ -82,7 +82,7 @@ RetVal<PartInstrumentListScoreOrder> SelectInstrumentsScenario::selectInstrument
String instrumentId = String::fromStdString(map["instrumentId"].toString());
pi.instrumentTemplate = instrumentsRepository()->instrumentTemplate(instrumentId);

result.instruments << pi;
result.instruments.push_back(pi);
}

ValMap order = content["scoreOrder"].toMap();
Expand Down
2 changes: 1 addition & 1 deletion src/instrumentsscene/view/staffsettingsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ QVariantList StaffSettingsModel::allStaffTypes() const
if (isTypeAllowed(type)) {
QVariantMap obj;

obj["text"] = staffTypeToString(type.type());
obj["text"] = staffTypeToString(type.type()).toQString();
obj["value"] = static_cast<int>(type.type());

result << obj;
Expand Down
2 changes: 1 addition & 1 deletion src/notation/internal/masternotationparts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void MasterNotationParts::setParts(const PartInstrumentList& partList, const Sco
PartInstrument pi;
pi.isExistingPart = true;
pi.partId = part->id();
excerptPartList << pi;
excerptPartList.push_back(pi);
}

impl->sortParts(excerptPartList);
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
4 changes: 2 additions & 2 deletions src/notation/internal/notationparts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ void NotationParts::removeParts(const IDList& partsIds)
PartInstrument pi;
pi.isExistingPart = true;
pi.partId = part->id();
parts << pi;
parts.push_back(pi);
}

sortParts(parts);
Expand Down Expand Up @@ -869,7 +869,7 @@ void NotationParts::moveParts(const IDList& sourcePartsIds, const ID& destinatio
PartInstrument pi;
pi.isExistingPart = true;
pi.partId = partId;
parts << pi;
parts.push_back(pi);
}

endInteractionWithScore();
Expand Down
4 changes: 2 additions & 2 deletions src/notation/internal/searchcommandsparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ static const std::string PAGE_CODE("p");
SearchCommands SearchCommandsParser::availableCommands()
{
SearchCommands commands;
commands << SearchCommand(ElementType::REHEARSAL_MARK, REHEARSAL_MARK_CODE, muse::trc("notation", "Rehearsal marks"))
<< SearchCommand(ElementType::PAGE, PAGE_CODE, muse::trc("notation", "Pages"));
commands.push_back(SearchCommand(ElementType::REHEARSAL_MARK, REHEARSAL_MARK_CODE, muse::trc("notation", "Rehearsal marks")));
commands.push_back(SearchCommand(ElementType::PAGE, PAGE_CODE, muse::trc("notation", "Pages")));

return commands;
}
Expand Down
40 changes: 19 additions & 21 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 Expand Up @@ -150,7 +148,7 @@ using engraving::LoopBoundaryType;
using Pid = mu::engraving::Pid;
using VoiceAssignment = mu::engraving::VoiceAssignment;

static const muse::String COMMON_GENRE_ID("common");
static const muse::String COMMON_GENRE_ID(u"common");

enum class DragMode
{
Expand Down Expand Up @@ -305,57 +303,57 @@ inline bool isMainInstrumentForPart(const InstrumentKey& instrumentKey, const Pa
return instrumentKey.instrumentId == part->instrumentId() && instrumentKey.tick == Part::MAIN_INSTRUMENT_TICK;
}

inline QString formatInstrumentTitle(const QString& instrumentName, const InstrumentTrait& trait)
inline muse::String formatInstrumentTitle(const muse::String& instrumentName, const InstrumentTrait& trait)
{
// Comments for translators start with //:
switch (trait.type) {
case TraitType::Tuning:
//: %1=tuning ("D"), %2=name ("Tin Whistle"). Example: "D Tin Whistle"
return muse::qtrc("notation", "%1 %2", "Tuned instrument displayed in the UI")
return muse::mtrc("notation", "%1 %2", "Tuned instrument displayed in the UI")
.arg(trait.name, instrumentName);
case TraitType::Transposition:
//: %1=name ("Horn"), %2=transposition ("C alto"). Example: "Horn in C alto"
return muse::qtrc("notation", "%1 in %2", "Transposing instrument displayed in the UI")
return muse::mtrc("notation", "%1 in %2", "Transposing instrument displayed in the UI")
.arg(instrumentName, trait.name);
case TraitType::Course:
//: %1=name ("Tenor Lute"), %2=course/strings ("7-course"). Example: "Tenor Lute (7-course)"
return muse::qtrc("notation", "%1 (%2)", "String instrument displayed in the UI")
return muse::mtrc("notation", "%1 (%2)", "String instrument displayed in the UI")
.arg(instrumentName, trait.name);
case TraitType::Unknown:
return instrumentName; // Example: "Flute"
}
Q_UNREACHABLE();
UNREACHABLE;
}

inline QString formatInstrumentTitle(const QString& instrumentName, const InstrumentTrait& trait, int instrumentNumber)
inline muse::String formatInstrumentTitle(const muse::String& instrumentName, const InstrumentTrait& trait, int instrumentNumber)
{
if (instrumentNumber == 0) {
// Only one instance of this instrument in the score
return formatInstrumentTitle(instrumentName, trait);
}

QString number = QString::number(instrumentNumber);
muse::String number = muse::String::number(instrumentNumber);

// Comments for translators start with //:
switch (trait.type) {
case TraitType::Tuning:
//: %1=tuning ("D"), %2=name ("Tin Whistle"), %3=number ("2"). Example: "D Tin Whistle 2"
return muse::qtrc("notation", "%1 %2 %3", "One of several tuned instruments displayed in the UI")
return muse::mtrc("notation", "%1 %2 %3", "One of several tuned instruments displayed in the UI")
.arg(trait.name, instrumentName, number);
case TraitType::Transposition:
//: %1=name ("Horn"), %2=transposition ("C alto"), %3=number ("2"). Example: "Horn in C alto 2"
return muse::qtrc("notation", "%1 in %2 %3", "One of several transposing instruments displayed in the UI")
return muse::mtrc("notation", "%1 in %2 %3", "One of several transposing instruments displayed in the UI")
.arg(instrumentName, trait.name, number);
case TraitType::Course:
//: %1=name ("Tenor Lute"), %2=course/strings ("7-course"), %3=number ("2"). Example: "Tenor Lute (7-course) 2"
return muse::qtrc("notation", "%1 (%2) %3", "One of several string instruments displayed in the UI")
return muse::mtrc("notation", "%1 (%2) %3", "One of several string instruments displayed in the UI")
.arg(instrumentName, trait.name, number);
case TraitType::Unknown:
//: %1=name ("Flute"), %2=number ("2"). Example: "Flute 2"
return muse::qtrc("notation", "%1 %2", "One of several instruments displayed in the UI")
return muse::mtrc("notation", "%1 %2", "One of several instruments displayed in the UI")
.arg(instrumentName, number);
}
Q_UNREACHABLE();
UNREACHABLE;
}

struct PartInstrument
Expand All @@ -367,7 +365,7 @@ struct PartInstrument
bool isSoloist = false;
};

using PartInstrumentList = QList<PartInstrument>;
using PartInstrumentList = std::list<PartInstrument>;

struct PartInstrumentListScoreOrder
{
Expand All @@ -384,7 +382,7 @@ struct SearchCommand
SearchCommand(const ElementType& searchElementType, const std::string& code, const std::string& description)
: searchElementType(searchElementType), code(code), description(description) {}
};
using SearchCommands = QList<SearchCommand>;
using SearchCommands = std::list<SearchCommand>;

struct FilterElementsOptions
{
Expand Down Expand Up @@ -421,7 +419,7 @@ struct FilterNotesOptions : FilterElementsOptions
struct StaffConfig
{
bool visible = false;
qreal userDistance = 0.0;
double userDistance = 0.0;
bool cutaway = false;
bool showIfEmpty = false;
bool hideSystemBarline = false;
Expand Down Expand Up @@ -527,10 +525,10 @@ struct ScoreConfig
}
};

inline QString staffTypeToString(StaffTypeId type)
inline muse::String staffTypeToString(StaffTypeId type)
{
const StaffType* preset = StaffType::preset(type);
return preset ? preset->name().toQString() : QString();
return preset ? preset->name() : muse::String();
}

struct MeasureBeat
Expand Down Expand Up @@ -571,7 +569,7 @@ struct ScoreCreateOptions
inline const ScoreOrder& customOrder()
{
static ScoreOrder order;
order.id = "custom";
order.id = u"custom";
order.name = muse::TranslatableString("engraving/scoreorder", "Custom");

return order;
Expand Down
2 changes: 1 addition & 1 deletion src/project/view/newscoremodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ProjectCreateOptions NewScoreModel::parseOptions(const QVariantMap& info) const
pi.isExistingPart = objMap["isExistingPart"].toBool();
pi.isSoloist = objMap["isSoloist"].toBool();

scoreOptions.parts << pi;
scoreOptions.parts.push_back(pi);
}

QVariantMap orderMap = info["scoreOrder"].toMap();
Expand Down

0 comments on commit fbd62d7

Please sign in to comment.