Skip to content

Commit

Permalink
Merge pull request #20298 from RomanPudashkin/420_porting_fixes
Browse files Browse the repository at this point in the history
420_porting_fixes
  • Loading branch information
RomanPudashkin committed Dec 4, 2023
2 parents 19a2163 + ea9533b commit a5eb785
Show file tree
Hide file tree
Showing 59 changed files with 1,382 additions and 290 deletions.
30 changes: 21 additions & 9 deletions share/instruments/string_tunings_presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,40 @@
"presets": [
{
"name": "Standard",
"value": [40, 45, 50, 55, 59, 64]
"value": [40, 45, 50, 55, 59, 64],
"useFlats": true
},{
"name": "Tune down 1/2 step",
"value": [39, 44, 49, 54, 58, 63]
"value": [39, 44, 49, 54, 58, 63],
"useFlats": true
},{
"name": "Tune down 1 step",
"value": [38, 43, 48, 53, 57, 62]
"value": [38, 43, 48, 53, 57, 62],
"useFlats": true
},{
"name": "Tune down 2 step",
"value": [36, 41, 46, 51, 55, 60]
"value": [36, 41, 46, 51, 55, 60],
"useFlats": true
},{
"name": "Dropped D",
"value": [38, 45, 50, 55, 59, 64],
"useFlats": true
},{
"name": "Dropped D tune down 1/2 step",
"value": [37, 44, 49, 54, 58, 63]
"value": [37, 44, 49, 54, 58, 63],
"useFlats": true
},{
"name": "Dropped D Variant",
"value": [38, 45, 50, 55, 57, 64]
"value": [38, 45, 50, 55, 57, 64],
"useFlats": true
},{
"name": "Double Dropped D",
"value": [38, 45, 50, 55, 59, 62]
"value": [38, 45, 50, 55, 59, 62],
"useFlats": true
},{
"name": "Dropped C",
"value": [36, 43, 48, 53, 57, 62]
"value": [36, 43, 48, 53, 57, 62],
"useFlats": true
},{
"name": "Dropped E",
"value": [40, 47, 52, 57, 61, 66]
Expand Down Expand Up @@ -305,4 +317,4 @@
}
]
}
]
]
4 changes: 3 additions & 1 deletion src/app/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
#include "commandlineparser.h"

#include <QDir>

#include "global/io/dir.h"
#include "global/muversion.h"

Expand Down Expand Up @@ -471,7 +473,7 @@ void CommandLineParser::parse(int argc, char** argv)
// Startup
if (m_runMode == IApplication::RunMode::GuiApp) {
if (!scorefiles.isEmpty()) {
m_options.startup.scoreUrl = QUrl::fromUserInput(scorefiles[0]);
m_options.startup.scoreUrl = QUrl::fromUserInput(scorefiles[0], QDir::currentPath(), QUrl::AssumeLocalFile);
}

if (m_parser.isSet("score-display-name-override")) {
Expand Down
15 changes: 11 additions & 4 deletions src/engraving/dom/arpeggio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Arpeggio::~Arpeggio()
{
// Remove reference to this arpeggio in any chords it may have spanned
Chord* _chord = chord();
if (!_chord) {
if (!_chord || !_chord->segment()) {
return;
}
for (track_idx_t _track = track(); _track <= track() + m_span; _track++) {
Expand All @@ -83,13 +83,20 @@ void Arpeggio::findAndAttachToChords()
Chord* _chord = chord();
track_idx_t strack = track();
track_idx_t etrack = track() + (m_span - 1);
track_idx_t lastTrack = strack;

for (track_idx_t track = strack; track <= etrack; track++) {
EngravingItem* e = _chord->segment()->element(track);
if (e && e->isChord()) {
toChord(e)->undoChangeSpanArpeggio(this);
lastTrack = track;
}
}

if (lastTrack != etrack) {
int newSpan = lastTrack - track() + 1;
undoChangeProperty(Pid::ARPEGGIO_SPAN, newSpan);
}
}

void Arpeggio::detachFromChords(track_idx_t strack, track_idx_t etrack)
Expand Down Expand Up @@ -121,7 +128,7 @@ void Arpeggio::rebaseStartAnchor(AnchorRebaseDirection direction)
track_idx_t newSpan = m_span + track() - curTrack;
if (newSpan != 0) {
undoChangeProperty(Pid::ARPEGGIO_SPAN, newSpan);
score()->undo(new ChangeParent(this, e, e->staffIdx()));
score()->undoChangeParent(this, e, e->staffIdx());
break;
}
}
Expand All @@ -136,7 +143,7 @@ void Arpeggio::rebaseStartAnchor(AnchorRebaseDirection direction)
if (newSpan != 0) {
chord()->undoChangeSpanArpeggio(nullptr);
undoChangeProperty(Pid::ARPEGGIO_SPAN, newSpan);
score()->undo(new ChangeParent(this, e, e->staffIdx()));
score()->undoChangeParent(this, e, e->staffIdx());
break;
}
}
Expand Down Expand Up @@ -217,7 +224,7 @@ void Arpeggio::editDrag(EditData& ed)
detachFromChords(track(), c->track() - 1);
}
undoChangeProperty(Pid::ARPEGGIO_SPAN, newSpan);
score()->undo(new ChangeParent(this, c, c->staffIdx()));
score()->undoChangeParent(this, c, c->staffIdx());
m_userLen1 = 0.0;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/engraving/dom/chord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,10 @@ void Chord::remove(EngravingItem* e)
break;

case ElementType::ARPEGGIO:
m_arpeggio = 0;
if (m_spanArpeggio == m_arpeggio) {
m_spanArpeggio = nullptr;
}
m_arpeggio = nullptr;
break;
case ElementType::TREMOLO:
setTremolo(nullptr);
Expand Down Expand Up @@ -1817,7 +1820,7 @@ void Chord::undoChangeSpanArpeggio(Arpeggio* a)
}
Chord* chord = toChord(linkedObject);
Score* score = chord->score();
EngravingItem* linkedArp = a->findLinkedInScore(score);
EngravingItem* linkedArp = chord->spanArpeggio();
if (score && linkedArp) {
score->undo(new ChangeSpanArpeggio(chord, toArpeggio(linkedArp)));
}
Expand Down
6 changes: 1 addition & 5 deletions src/engraving/dom/chordrest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ EngravingItem* ChordRest::drop(EditData& data)
case ElementType::FRET_DIAGRAM:
case ElementType::TREMOLOBAR:
case ElementType::SYMBOL:
case ElementType::IMAGE:
e->setTrack(track());
e->setParent(segment());
score()->undoAddElement(e);
Expand Down Expand Up @@ -356,11 +357,6 @@ EngravingItem* ChordRest::drop(EditData& data)
return e;
}

case ElementType::IMAGE:
e->setParent(segment());
score()->undoAddElement(e);
return e;

case ElementType::ACTION_ICON:
{
switch (toActionIcon(e)->actionType()) {
Expand Down
16 changes: 12 additions & 4 deletions src/engraving/dom/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ static UndoMacro::ChangesInfo changesInfo(const UndoStack* stack)
return actualMacro->changesInfo();
}

static std::pair<int, int> changedTicksRange(const CmdState& cmdState, const std::vector<const EngravingItem*>& changedItems)
static std::pair<int, int> changedTicksRange(const CmdState& cmdState, const std::set<const EngravingItem*>& changedItems)
{
int startTick = cmdState.startTick().ticks();
int endTick = cmdState.endTick().ticks();
Expand Down Expand Up @@ -318,6 +318,10 @@ void Score::undoRedo(bool undo, EditData* ed)

ScoreChangesRange range = changesRange();

if (range.changedItems.empty()) {
range.changedItems = std::move(changes.changedItems);
}

if (range.changedTypes.empty()) {
range.changedTypes = std::move(changes.changedObjectTypes);
}
Expand Down Expand Up @@ -387,7 +391,10 @@ ScoreChangesRange Score::changesRange() const

return { ticksRange.first, ticksRange.second,
cmdState.startStaff(), cmdState.endStaff(),
changes.changedObjectTypes, changes.changedPropertyIdSet, changes.changedStyleIdSet };
std::move(changes.changedItems),
std::move(changes.changedObjectTypes),
std::move(changes.changedPropertyIdSet),
std::move(changes.changedStyleIdSet) };
}

#ifndef NDEBUG
Expand Down Expand Up @@ -1840,6 +1847,7 @@ void Score::upDown(bool up, UpDownMode mode)
int tpc1 = oNote->tpc1();
int tpc2 = oNote->tpc2();
int pitch = oNote->pitch();
int pitchOffset = staff->pitchOffset(tick);
int newTpc1 = tpc1; // default to unchanged
int newTpc2 = tpc2; // default to unchanged
int newPitch = pitch; // default to unchanged
Expand Down Expand Up @@ -1876,7 +1884,7 @@ void Score::upDown(bool up, UpDownMode mode)
return; // no next string to move to
}
string = stt->visualStringToPhys(string);
fret = stringData->fret(pitch, string, staff);
fret = stringData->fret(pitch + pitchOffset, string, staff);
if (fret == -1) { // can't have that note on that string
return;
}
Expand All @@ -1903,7 +1911,7 @@ void Score::upDown(bool up, UpDownMode mode)
}
// update pitch and tpc's and check it matches stringData
upDownChromatic(up, pitch, oNote, key, tpc1, tpc2, newPitch, newTpc1, newTpc2);
if (newPitch != stringData->getPitch(string, fret, staff)) {
if (newPitch + pitchOffset != stringData->getPitch(string, fret, staff) && !oNote->bendBack()) {
// oh-oh: something went very wrong!
LOGD("upDown tab in-string: pitch mismatch");
return;
Expand Down
8 changes: 7 additions & 1 deletion src/engraving/dom/durationelement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ float DurationElement::timeStretchFactor() const
// actualTicks
//---------------------------------------------------------

Fraction DurationElement::actualTicksAt(const Fraction& tick) const
{
// Use when tick() is unreliable, for example when pasting
return globalTicks() / staff()->timeStretch(tick);
}

Fraction DurationElement::actualTicks() const
{
return globalTicks() / staff()->timeStretch(tick());
return actualTicksAt(tick());
}

//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/engraving/dom/durationelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class DurationElement : public EngravingItem
Tuplet* topTuplet() const;
virtual Beam* beam() const { return nullptr; }

Fraction actualTicksAt(const Fraction& tick) const;
Fraction actualTicks() const;

// Length expressed as a fraction of a whole note
Expand Down
6 changes: 6 additions & 0 deletions src/engraving/dom/excerpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,9 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star
if (bendBack && newStartNote) {
GuitarBend* newBend = toGuitarBend(bendBack->linkedClone());
newBend->setScore(score);
newBend->setParent(newStartNote);
newBend->setTrack(newStartNote->track());
newBend->setTrack2(nn->track());
newBend->setStartElement(newStartNote);
newBend->setEndElement(nn);
newStartNote->addSpannerFor(newBend);
Expand All @@ -1532,6 +1535,9 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star
// Because slight bends aren't detected as "bendBack"
GuitarBend* newBend = toGuitarBend(bendFor->linkedClone());
newBend->setScore(score);
newBend->setParent(nn);
newBend->setTrack(nn->track());
newBend->setTrack2(nn->track());
newBend->setStartElement(nn);
newBend->setEndElement(nn);
nn->addSpannerFor(newBend);
Expand Down
18 changes: 10 additions & 8 deletions src/engraving/dom/paste.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "sig.h"
#include "staff.h"
#include "tie.h"
#include "timesig.h"
#include "tremolo.h"
#include "tuplet.h"
#include "undo.h"
Expand Down Expand Up @@ -124,7 +125,7 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t)
transposeChord(toChord(cr), tick);
if (toChord(cr)->tremolo() && toChord(cr)->tremolo()->twoNotes()) {
twoNoteTremoloFactor = 2;
} else if (cr->durationTypeTicks() == (cr->actualTicks() * 2)) {
} else if (cr->durationTypeTicks() == (cr->actualTicksAt(tick) * 2)) {
// this could be the 2nd note of a two-note tremolo
// check previous CR on same track, if it has a two-note tremolo, then set twoNoteTremoloFactor to 2
Segment* seg = measure->undoGetSegment(SegmentType::ChordRest, tick);
Expand Down Expand Up @@ -167,19 +168,19 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t)
if (cr->isMeasureRepeat()) {
partialCopy = toMeasureRepeat(cr)->actualTicks() != measure->ticks();
} else if (!isGrace && !cr->tuplet()) {
partialCopy = cr->durationTypeTicks() != (cr->actualTicks() * twoNoteTremoloFactor);
partialCopy = cr->durationTypeTicks() != (cr->actualTicksAt(tick) * twoNoteTremoloFactor);
}

// if note is too long to fit in measure, split it up with a tie across the barline
// exclude tuplets from consideration
// we have already disallowed a tuplet from crossing the barline, so there is no problem here
// but due to rounding, it might appear from actualTicks() that the last note is too long by a couple of ticks

if (!isGrace && !cr->tuplet() && (tick + cr->actualTicks() > measureEnd || partialCopy || convertMeasureRest)) {
if (!isGrace && !cr->tuplet() && (tick + cr->actualTicksAt(tick) > measureEnd || partialCopy || convertMeasureRest)) {
if (cr->isChord()) {
// split Chord
Chord* c = toChord(cr);
Fraction rest = c->actualTicks();
Fraction rest = c->actualTicksAt(tick);
bool firstpart = true;
while (rest.isNotZero()) {
measure = tick2measure(tick);
Expand All @@ -192,9 +193,10 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t)
std::vector<TDuration> dl = toRhythmicDurationList(len, false, tick - measure->tick(), sigmap()->timesig(
tick).nominal(), measure, MAX_DOTS);
TDuration d = dl[0];
Fraction c2Tick(tick + c->tick());
c2->setDurationType(d);
c2->setTicks(d.fraction());
rest -= c2->actualTicks();
rest -= c2->actualTicksAt(c2Tick);
undoAddCR(c2, measure, tick);

std::vector<Note*> nl1 = c->notes();
Expand All @@ -219,7 +221,7 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t)
}
c = c2;
firstpart = false;
tick += c->actualTicks();
tick += c->actualTicksAt(c2Tick);
}
} else if (cr->isRest()) {
// split Rest
Expand All @@ -239,7 +241,7 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t)
r2->setTicks(d.isMeasure() ? measure->ticks() : d.fraction());
undoAddCR(r2, measure, tick);
rest -= r2->ticks();
tick += r2->actualTicks();
tick += r2->actualTicksAt(tick);
firstpart = false;
}
} else if (cr->isMeasureRepeat()) {
Expand All @@ -260,7 +262,7 @@ void Score::pasteChordRest(ChordRest* cr, const Fraction& t)
r2->setDurationType(d);
undoAddCR(r2, measure, tick);
rest -= d.fraction();
tick += r2->actualTicks();
tick += r2->actualTicksAt(tick);
}
delete r;
}
Expand Down
12 changes: 0 additions & 12 deletions src/engraving/dom/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ EngravingItem* Rest::drop(EditData& data)
}
break;
}
case ElementType::SYMBOL:
case ElementType::IMAGE:
e->setParent(this);
score()->undoAddElement(e);
return e;

case ElementType::STRING_TUNINGS:
return measure()->drop(data);

Expand Down Expand Up @@ -790,12 +784,6 @@ void Rest::add(EngravingItem* e)
break;
case ElementType::DEAD_SLAPPED:
m_deadSlapped = toDeadSlapped(e);
// fallthrough
case ElementType::SYMBOL:
case ElementType::IMAGE:
addEl(e);
e->added();
break;
default:
ChordRest::add(e);
break;
Expand Down
Loading

0 comments on commit a5eb785

Please sign in to comment.