diff options
author | Florian Jung <flo@windfisch.org> | 2013-09-18 23:54:35 +0200 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2013-09-18 23:54:35 +0200 |
commit | b3fc353a09496ee0aea7099d72e6963f4c2fc774 (patch) | |
tree | 83ab91e988c59076d81ebddc09e8ff274dee8af5 /muse2/muse/structure.cpp | |
parent | 48a93993cfce160fb7d4cf0b67b4b77e22db19e5 (diff) | |
parent | 85a51421d44f3893a1010f77e0418caf6be70235 (diff) |
Merge branch 'audiomsg_overhaul' (nonshared eventlists and more)
This introduces the following changes:
- Clone Parts no more share their eventlist. Instead, all changes
made to one clone are replicated to the other clones' eventlists
- audio/song->msg{Add,Delete,Change}{Part,Event,Track} have been
replaced by the corresponding UndoOp operations.
- Enforcing of const-correctness: No GUI code may ever gain
writable access to audio/midi/song data structures. Access
must *always* go through applyOperationGroup. This is now
enforced.
- Removed a bunch of DELETETHIS or REMOVE or otherwise commented
out code
- Removed dead code
- Removed unused Audio Messages (that should go through applyOpGroup
anyway.)
Diffstat (limited to 'muse2/muse/structure.cpp')
-rw-r--r-- | muse2/muse/structure.cpp | 84 |
1 files changed, 31 insertions, 53 deletions
diff --git a/muse2/muse/structure.cpp b/muse2/muse/structure.cpp index 65489cac..0c1d673d 100644 --- a/muse2/muse/structure.cpp +++ b/muse2/muse/structure.cpp @@ -5,6 +5,7 @@ // // (C) Copyright 1999-2004 Werner Schweer (ws@seh.de) // (C) Copyright 2011 Robert Jonsson (rj@spamatica.se) +// (C) Copyright 2013 Florian Jung (flo93@sourceforge.net) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -161,19 +162,15 @@ void globalCut(bool onlySelectedTracks) else if ((t < lpos) && ((t+l) > lpos) && ((t+l) <= rpos)) { // remove part tail int len = lpos - t; - Part *nPart; - if (track->isMidiTrack()) - nPart = new MidiPart(*(MidiPart*)part); - else - nPart = new WavePart(*(WavePart*)part); - - nPart->setLenTick(len); - // cut Events in nPart - EventList* el = nPart->events(); - for (iEvent ie = el->lower_bound(len); ie != el->end(); ++ie) - operations.push_back(UndoOp(UndoOp::DeleteEvent,ie->second, nPart, false, false)); - - operations.push_back(UndoOp(UndoOp::ModifyPart,part, nPart, true, true)); + + if (part->nextClone()==part) // no clones + { + // cut Events + const EventList& el = part->events(); + for (ciEvent ie = el.lower_bound(len); ie != el.end(); ++ie) + operations.push_back(UndoOp(UndoOp::DeleteEvent,ie->second, part, false, false)); + } + operations.push_back(UndoOp(UndoOp::ModifyPartLength, part, part->lenTick(), len, true, true)); } else if ((t < lpos) && ((t+l) > lpos) && ((t+l) > rpos)) { //---------------------- @@ -182,16 +179,15 @@ void globalCut(bool onlySelectedTracks) Part* p1; Part* p2; Part* p3; - track->splitPart(part, lpos, p1, p2); + part->splitPart(lpos, p1, p2); delete p2; - track->splitPart(part, rpos, p2, p3); + part->splitPart(rpos, p2, p3); delete p2; p3->setTick(lpos); - p1->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it so we must decrement it first :/ - p3->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it so we must decrement it first :/ - // Indicate no undo, and do port controller values and clone parts. - operations.push_back(UndoOp(UndoOp::ModifyPart,part, p1, true, true)); + MusEGlobal::song->informAboutNewParts(part,p1,p3); + operations.push_back(UndoOp(UndoOp::DeletePart,part)); + operations.push_back(UndoOp(UndoOp::AddPart,p1)); operations.push_back(UndoOp(UndoOp::AddPart,p3)); } else if ((t >= lpos) && (t < rpos) && (t+l) > rpos) { @@ -199,23 +195,18 @@ void globalCut(bool onlySelectedTracks) Part* p1; Part* p2; - track->splitPart(part, rpos, p1, p2); + part->splitPart(rpos, p1, p2); delete p1; p2->setTick(lpos); - p2->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it so we must decrement it first :/ - operations.push_back(UndoOp(UndoOp::ModifyPart,part, p2, true, true)); + + MusEGlobal::song->informAboutNewParts(part,p2); + operations.push_back(UndoOp(UndoOp::DeletePart,part)); + operations.push_back(UndoOp(UndoOp::AddPart,p2)); } else if (t >= rpos) { // move part to the left - Part *nPart; - if (track->isMidiTrack()) - nPart = new MidiPart(*(MidiPart*)part); - else - nPart = new WavePart(*(WavePart*)part); int nt = part->tick(); - nPart->setTick(nt - (rpos -lpos)); - // Indicate no undo, and do port controller values but not clone parts. - operations.push_back(UndoOp(UndoOp::ModifyPart,part, nPart, true, false)); + operations.push_back(UndoOp(UndoOp::ModifyPartTick,part,part->tick(), nt - (rpos -lpos) )); } } } @@ -263,22 +254,16 @@ Undo movePartsTotheRight(unsigned int startTicks, int moveTicks, bool only_selec // split part to insert new space Part* p1; Part* p2; - track->splitPart(part, startTicks, p1, p2); + part->splitPart(startTicks, p1, p2); p2->setTick(startTicks+moveTicks); - p2->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it so we must decrement it first :/ - p1->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it so we must decrement it first :/ - operations.push_back(UndoOp(UndoOp::ModifyPart, part, p1, true, true)); + MusEGlobal::song->informAboutNewParts(part,p1,p2); + operations.push_back(UndoOp(UndoOp::DeletePart, part)); + operations.push_back(UndoOp(UndoOp::AddPart, p1)); operations.push_back(UndoOp(UndoOp::AddPart, p2)); } else if (t >= startTicks) { - Part *nPart; - if (track->isMidiTrack()) - nPart = new MidiPart(*(MidiPart*)part); - else - nPart = new WavePart(*(WavePart*)part); - nPart->setTick(t + moveTicks); - operations.push_back(UndoOp(UndoOp::ModifyPart, part, nPart, true, false)); + operations.push_back(UndoOp(UndoOp::ModifyPartTick, part, part->tick(), t + moveTicks)); } } } @@ -318,24 +303,17 @@ Undo partSplitter(unsigned int pos, bool onlySelectedTracks) if (pos > p1 && pos < (p1+l0)) { Part* p1; Part* p2; - track->splitPart(part, pos, p1, p2); + part->splitPart(pos, p1, p2); - p1->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it - p2->events()->incARef(-1); // so we must decrement it first :/ - - //MusEGlobal::song->informAboutNewParts(part, p1); // is unneccessary because of ModifyPart + MusEGlobal::song->informAboutNewParts(part, p1); MusEGlobal::song->informAboutNewParts(part, p2); - operations.push_back(UndoOp(UndoOp::ModifyPart,part, p1, true, false)); + operations.push_back(UndoOp(UndoOp::DeletePart,part)); + operations.push_back(UndoOp(UndoOp::AddPart,p1)); operations.push_back(UndoOp(UndoOp::AddPart,p2)); - if (MusEGlobal::debugMsg) - { - printf("in partSplitter: part1 %d\n",p1->events()->refCount()); - printf("in partSplitter: part2 %d\n",p2->events()->refCount()); - } break; - } } } + } return operations; } |