diff options
author | rj <rj@rj> | 2013-10-09 19:45:37 +0200 |
---|---|---|
committer | rj <rj@rj> | 2013-10-09 19:45:37 +0200 |
commit | 8825155b467098cb14a0f23af079bda62da4f5d2 (patch) | |
tree | cc6387fdab06e771dd4db6b69a214cca358a05f8 /muse2 | |
parent | 60e9415153a33eb6545ecf560e4b3b73864d1d2c (diff) |
changed track drag to move instead of swap
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/muse/seqmsg.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/song.cpp | 29 | ||||
-rw-r--r-- | muse2/muse/song.h | 2 | ||||
-rw-r--r-- | muse2/muse/undo.cpp | 29 | ||||
-rw-r--r-- | muse2/muse/undo.h | 2 |
5 files changed, 41 insertions, 23 deletions
diff --git a/muse2/muse/seqmsg.cpp b/muse2/muse/seqmsg.cpp index 669aff9d..0a4e6160 100644 --- a/muse2/muse/seqmsg.cpp +++ b/muse2/muse/seqmsg.cpp @@ -739,7 +739,7 @@ void Audio::msgMoveTrack(int idx1, int idx2, bool doUndoFlag) int n = MusEGlobal::song->tracks()->size(); if (idx1 >= n || idx2 >= n) // sanity check return; - MusEGlobal::song->applyOperation(UndoOp(UndoOp::SwapTrack, idx1, idx2), doUndoFlag); + MusEGlobal::song->applyOperation(UndoOp(UndoOp::MoveTrack, idx1, idx2), doUndoFlag); } //--------------------------------------------------------- diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index 3c5b8fa7..5d821301 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -1062,16 +1062,29 @@ void Song::setStopPlay(bool f) } //--------------------------------------------------------- -// swapTracks +// moveTrack +// //--------------------------------------------------------- -void Song::swapTracks(int i1, int i2) - { - addUndo(UndoOp(UndoOp::SwapTrack, i1, i2)); - Track* track = _tracks[i1]; - _tracks[i1] = _tracks[i2]; - _tracks[i2] = track; - } +void Song::moveTrack(int fromI, int toI) +{ + //addUndo(UndoOp(UndoOp::MoveTrack, fromI, toI)); + Track* toTrack = _tracks[toI]; + Track* fromTrack = _tracks[fromI]; + for(TrackList::iterator toIt = _tracks.begin(); toIt != _tracks.end(); ++toIt) + { + if ((*toIt) == toTrack) { + for(TrackList::iterator fromIt = _tracks.begin(); fromIt != _tracks.end(); ++fromIt) + { + if ((*fromIt) == fromTrack) { + _tracks.erase(fromIt); + _tracks.insert(toIt,fromTrack); + } + } + + } + } +} //--------------------------------------------------------- // seekTo diff --git a/muse2/muse/song.h b/muse2/muse/song.h index a25f1d55..59f2e9d1 100644 --- a/muse2/muse/song.h +++ b/muse2/muse/song.h @@ -325,7 +325,7 @@ class Song : public QObject { void removeTrack3(Track* track); MidiTrack* findTrack(const Part* part) const; Track* findTrack(const QString& name) const; - void swapTracks(int i1, int i2); + void moveTrack(int i1, int i2); void setRecordFlag(Track*, bool); void insertTrack0(Track*, int idx); void insertTrack1(Track*, int idx); diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index 103b47ac..197c1f2a 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -59,7 +59,7 @@ const char* UndoOp::typeName() "AddSig", "DeleteSig", "AddKey", "DeleteKey", "ModifyTrackName", "ModifyTrackChannel", - "SwapTrack", + "MoveTrack", "ModifyClip", "ModifyMarker", "ModifySongLen", "DoNothing" }; @@ -106,7 +106,7 @@ void UndoOp::dump() case AddTempo: case DeleteTempo: case AddSig: - case SwapTrack: + case MoveTrack: case DeleteSig: case ModifyClip: case ModifyMarker: @@ -469,12 +469,14 @@ void Song::revertOperationGroup2(Undo& operations) updateFlags |= SC_TRACK_INSERTED; break; - case UndoOp::SwapTrack: + case UndoOp::MoveTrack: { - updateFlags |= SC_TRACK_MODIFIED; - Track* track = _tracks[i->a]; - _tracks[i->a] = _tracks[i->b]; - _tracks[i->b] = track; + moveTrack(i->b, i->a); + if (i->b > i->a) + i->a++; + else + i->b--; + updateFlags |= SC_TRACK_MODIFIED; } break; @@ -593,11 +595,14 @@ void Song::executeOperationGroup2(Undo& operations) break; - case UndoOp::SwapTrack: + case UndoOp::MoveTrack: { - Track* track = _tracks[i->a]; - _tracks[i->a] = _tracks[i->b]; - _tracks[i->b] = track; + moveTrack(i->a, i->b); + if (i->a > i->b){ + i->b++; + } + else + i->a--; updateFlags |= SC_TRACK_MODIFIED; } break; @@ -701,7 +706,7 @@ UndoOp::UndoOp(UndoType type_, int a_, int b_, int c_) assert(type_==AddKey || type_==DeleteKey || type_==AddTempo || type_==DeleteTempo || type_==AddSig || type_==DeleteSig || - type_==ModifySongLen || type_==SwapTrack); + type_==ModifySongLen || type_==MoveTrack); type = type_; a = a_; diff --git a/muse2/muse/undo.h b/muse2/muse/undo.h index f83ce491..2696de39 100644 --- a/muse2/muse/undo.h +++ b/muse2/muse/undo.h @@ -53,7 +53,7 @@ struct UndoOp { AddSig, DeleteSig, AddKey, DeleteKey, ModifyTrackName, ModifyTrackChannel, - SwapTrack, + MoveTrack, ModifyClip, ModifyMarker, ModifySongLen, // a = new len, b = old len |