diff options
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 5 | ||||
-rw-r--r-- | muse2/muse/track.cpp | 11 | ||||
-rw-r--r-- | muse2/muse/undo.cpp | 32 | ||||
-rw-r--r-- | muse2/muse/undo.h | 9 | ||||
-rw-r--r-- | muse2/muse/wavetrack.cpp | 11 |
5 files changed, 57 insertions, 11 deletions
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index 57645a97..8cd5957c 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -376,6 +376,9 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& if(t == MOVE_MOVE) { + if (dtrack!=track) + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::MovePartToTrack,spart,dtrack,track)); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyPartTick,spart,spart->tick(),dtick)); new_partend=(spart->lenTick() + dtick); @@ -392,11 +395,11 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& dpart = spart->duplicate(); dpart->setTick(dtick); + dpart->setTrack(dtrack); operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddPart,dpart)); new_partend=(dpart->lenTick() + dpart->tick()); - } if (MusEGlobal::song->len() < new_partend) // FIXME this is buggy anyway. diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp index 06bc34e1..98935315 100644 --- a/muse2/muse/track.cpp +++ b/muse2/muse/track.cpp @@ -787,7 +787,16 @@ void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask) Part* MidiTrack::newPart(Part*p, bool clone) { - MidiPart* part = clone ? (MidiPart*)p->createNewClone() : new MidiPart(this); + MidiPart* part; + if (clone) + { + part = (MidiPart*)p->createNewClone(); + part->setTrack(this); + } + else + part= new MidiPart(this); + + if (p) { part->setName(p->name()); part->setColorIndex(p->colorIndex()); diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index e7ef611b..37a0f7c1 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -53,6 +53,7 @@ const char* UndoOp::typeName() static const char* name[] = { "AddTrack", "DeleteTrack", "AddPart", "DeletePart", "ModifyPartTick", "ModifyPartLength", "ModifyPartLengthFrames", "ModifyPartName", "SelectPart", + "MovePartToTrack", "AddEvent", "DeleteEvent", "ModifyEvent", "SelectEvent", "AddTempo", "DeleteTempo", "AddSig", "DeleteSig", @@ -83,6 +84,7 @@ void UndoOp::dump() case ModifyPartLength: case ModifyPartLengthFrames: case ModifyPartName: + case MovePartToTrack: break; case AddEvent: case DeleteEvent: @@ -405,18 +407,21 @@ void Song::revertOperationGroup2(Undo& operations) } break; case UndoOp::AddPart: - { - Part* part = editable_part; - removePart(part); + removePart(editable_part); updateFlags |= SC_PART_REMOVED; editable_part->unchainClone(); - } break; case UndoOp::DeletePart: addPart(editable_part); updateFlags |= SC_PART_INSERTED; editable_part->rechainClone(); break; + case UndoOp::MovePartToTrack: + removePart(editable_part); // remove it from the track it currently lives on. (does not touch the clone chain) + editable_part->setTrack(const_cast<Track*>(i->oldTrack)); + addPart(editable_part); // add it to the track we just set. + updateFlags |= SC_PART_INSERTED | SC_PART_REMOVED; + break; case UndoOp::ModifyPartName: editable_part->setName(i->_oldName); updateFlags |= SC_PART_MODIFIED; @@ -534,6 +539,12 @@ void Song::executeOperationGroup2(Undo& operations) updateFlags |= SC_PART_REMOVED; editable_part->unchainClone(); break; + case UndoOp::MovePartToTrack: + removePart(editable_part); // remove it from the track it currently lives on. (does not touch the clone chain) + editable_part->setTrack(editable_track); + addPart(editable_part); // add it to the track we just set. + updateFlags |= SC_PART_INSERTED | SC_PART_REMOVED; + break; case UndoOp::ModifyPartName: editable_part->setName(i->_newName); updateFlags |= SC_PART_MODIFIED; @@ -659,6 +670,19 @@ UndoOp::UndoOp(UndoType type_, const Part* part_, bool selected_, bool sel_old_) selected_old=sel_old_; } +UndoOp::UndoOp(UndoType type_, const Part* part_, const Track* nTrack, const Track* oTrack) +{ + assert(type_==MovePartToTrack); + assert(part_); + assert(nTrack); + assert(oTrack); + + type=type_; + part = part_; + track=nTrack; + oldTrack=oTrack; +} + UndoOp::UndoOp(UndoType type_, const Event& nev, const Event& oev, const Part* part_, bool doCtrls_, bool doClones_) { assert(type_==ModifyEvent); diff --git a/muse2/muse/undo.h b/muse2/muse/undo.h index f27dbcc3..4619f797 100644 --- a/muse2/muse/undo.h +++ b/muse2/muse/undo.h @@ -47,6 +47,7 @@ struct UndoOp { enum UndoType { AddTrack, DeleteTrack, AddPart, DeletePart, ModifyPartTick, ModifyPartLength, ModifyPartLengthFrames, /* FINDMICH FIXME frames are to be deprecated */ ModifyPartName, SelectPart, + MovePartToTrack, AddEvent, DeleteEvent, ModifyEvent, SelectEvent, AddTempo, DeleteTempo, AddSig, DeleteSig, @@ -67,10 +68,6 @@ struct UndoOp { int c; }; struct { - const Track* track; - int trackno; - }; - struct { const Part* part; unsigned old_partlen_or_tick; // FIXME FINDMICHJETZT XTicks!! unsigned new_partlen_or_tick; @@ -106,6 +103,9 @@ struct UndoOp { bool selected_old; bool doCtrls; bool doClones; + const Track* track; + const Track* oldTrack; + int trackno; const char* typeName(); void dump(); @@ -116,6 +116,7 @@ struct UndoOp { UndoOp(UndoType type, const Part* part, unsigned old_len_or_tick=-1, unsigned new_len_or_tick=-1, bool doCtrls=false, bool doClones=false); // FIXME these bools are UNUSED!!. XTICKS! UndoOp(UndoType type, const Part* part, const char* old_name, const char* new_name); UndoOp(UndoType type, const Part* part, bool selected, bool selected_old); + UndoOp(UndoType type, const Part* part, const Track* nTrack, const Track* oTrack); UndoOp(UndoType type, const Event& nev, const Event& oev, const Part* part, bool doCtrls, bool doClones); UndoOp(UndoType type, const Event& nev, const Part* part, bool doCtrls, bool doClones); UndoOp(UndoType type, const Event& nev, bool selected, bool selected_old); diff --git a/muse2/muse/wavetrack.cpp b/muse2/muse/wavetrack.cpp index ce11b222..41beeb97 100644 --- a/muse2/muse/wavetrack.cpp +++ b/muse2/muse/wavetrack.cpp @@ -214,7 +214,16 @@ void WaveTrack::read(Xml& xml) Part* WaveTrack::newPart(Part*p, bool clone) { - WavePart* part = clone ? (WavePart*)p->createNewClone() : new WavePart(this); + WavePart* part; + if (clone) + { + part = (WavePart*)p->createNewClone(); + part->setTrack(this); + } + else + part = new WavePart(this); + + if (p) { part->setName(p->name()); part->setColorIndex(p->colorIndex()); |