summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-11-16 16:24:39 +0000
committerWerner Schweer <ws.seh.de>2006-11-16 16:24:39 +0000
commit891efd553e27346e3c2c3b9d3f849a810b78de3d (patch)
tree05173fcef83268f22af675bae0914294a713dac7
parent4c7739dc6a763f0c1ce367eb28c5dc09cf726d32 (diff)
more updates
-rw-r--r--muse/doc/dimpl/dimpl.tex2
-rw-r--r--muse/muse/arranger/canvas.cpp9
-rw-r--r--muse/muse/audio.h5
-rw-r--r--muse/muse/muse.cpp12
-rw-r--r--muse/muse/seqmsg.cpp13
-rw-r--r--muse/muse/song.cpp8
-rw-r--r--muse/muse/song.h10
-rw-r--r--muse/muse/songpart.cpp56
-rw-r--r--muse/muse/undo.cpp16
9 files changed, 68 insertions, 63 deletions
diff --git a/muse/doc/dimpl/dimpl.tex b/muse/doc/dimpl/dimpl.tex
index d8c91743..8a30feb4 100644
--- a/muse/doc/dimpl/dimpl.tex
+++ b/muse/doc/dimpl/dimpl.tex
@@ -215,7 +215,7 @@
\subsection{User Transaction}
A user transaction is a sequence of actions manipulating the
- main {\Song()} structure. Each action involves sending a
+ main {\tt Song()} structure. Each action involves sending a
message to the realtime thread. This means that every action
stops the GUI thread for at most one JACK cycle.
diff --git a/muse/muse/arranger/canvas.cpp b/muse/muse/arranger/canvas.cpp
index 4ee07a65..3df1f708 100644
--- a/muse/muse/arranger/canvas.cpp
+++ b/muse/muse/arranger/canvas.cpp
@@ -883,7 +883,7 @@ void PartCanvas::declonePart(Part* spart)
Event ev = oldEvent.clone();
de->add(ev);
}
- audio->msgChangePart(spart, dpart, true);
+ song->cmdChangePart(spart, dpart);
track->partListChanged();
}
@@ -916,7 +916,6 @@ void PartCanvas::renamePart(Part* part)
Part* newPart = new Part(*part);
newPart->setName(s);
song->cmdChangePart(part, newPart);
- song->endUndo(SC_PART_MODIFIED);
widget()->update();
}
}
@@ -1076,15 +1075,15 @@ void PartCanvas::drop(QDropEvent* event)
Qt::KeyboardModifiers keyState = event->keyboardModifiers();
if (keyState & Qt::ShiftModifier) {
- song->copyPart(srcPart, tick, track);
+ song->cmdCopyPart(srcPart, tick, track);
event->setDropAction(Qt::CopyAction);
}
else if (keyState & Qt::ControlModifier) {
- song->linkPart(srcPart, tick, track);
+ song->cmdLinkPart(srcPart, tick, track);
event->setDropAction(Qt::LinkAction);
}
else {
- song->movePart(srcPart, tick, track);
+ song->cmdMovePart(srcPart, tick, track);
event->setDropAction(Qt::MoveAction);
}
}
diff --git a/muse/muse/audio.h b/muse/muse/audio.h
index 050757fd..395adac1 100644
--- a/muse/muse/audio.h
+++ b/muse/muse/audio.h
@@ -215,12 +215,11 @@ class Audio {
void msgRemoveTrack(Track*);
void msgRemoveTracks();
void msgMoveTrack(Track*, Track*);
-// void msgAddPart(Part*, bool u = true);
-// void msgRemovePart(Part*, bool u = true);
- void msgChangePart(Part* oldPart, Part* newPart, bool u = true);
+
void msgAddEvent(const Event&, Part*, bool u = true);
void msgDeleteEvent(const Event&, Part*, bool u = true);
void msgChangeEvent(const Event&, const Event&, Part*, bool u = true);
+
void msgAddTempo(int tick, int tempo, bool doUndoFlag = true);
void msgSetTempo(int tick, int tempo, bool doUndoFlag = true);
void msgSetGlobalTempo(int val);
diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp
index f22e654b..3883621a 100644
--- a/muse/muse/muse.cpp
+++ b/muse/muse/muse.cpp
@@ -2213,7 +2213,7 @@ void MusE::globalCut()
++ie;
audio->msgDeleteEvent(i->second, nPart, false);
}
- audio->msgChangePart(part, nPart, false);
+ song->changePart(part, nPart);
}
else if ((t < lpos) && ((t+l) > lpos) && ((t+l) > rpos)) {
//----------------------
@@ -2240,7 +2240,7 @@ void MusE::globalCut()
audio->msgChangeEvent(event, nEvent, nPart, false);
}
nPart->setLenTick(l - (rpos-lpos));
- audio->msgChangePart(part, nPart, false);
+ song->changePart(part, nPart);
}
else if ((t >= lpos) && (t < rpos) && (t+l) > rpos) {
// TODO: remove part head
@@ -2249,7 +2249,7 @@ void MusE::globalCut()
Part* nPart = new Part(*part);
int nt = part->tick();
nPart->setTick(nt - (rpos -lpos));
- audio->msgChangePart(part, nPart, false);
+ song->changePart(part, nPart);
}
}
}
@@ -2304,12 +2304,12 @@ void MusE::globalInsert()
nEvent.setTick(nEvent.tick() + (rpos-lpos));
audio->msgChangeEvent(event, nEvent, nPart, false);
}
- audio->msgChangePart(part, nPart, false);
+ song->changePart(part, nPart);
}
else if (t > lpos) {
Part* nPart = new Part(*part);
nPart->setTick(t + (rpos -lpos));
- audio->msgChangePart(part, nPart, false);
+ song->changePart(part, nPart);
}
}
}
@@ -2340,7 +2340,7 @@ void MusE::globalSplit()
Part* p1;
Part* p2;
track->splitPart(part, pos, p1, p2);
- audio->msgChangePart(part, p1, false);
+ song->changePart(part, p1);
song->addPart(p2);
break;
}
diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp
index 28dfe043..836d2dde 100644
--- a/muse/muse/seqmsg.cpp
+++ b/muse/muse/seqmsg.cpp
@@ -376,19 +376,6 @@ void Audio::msgMoveTrack(Track* src, Track* dst)
}
//---------------------------------------------------------
-// msgChangePart
-//---------------------------------------------------------
-
-void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag)
- {
- AudioMsg msg;
- msg.id = SEQM_CHANGE_PART;
- msg.p1 = oldPart;
- msg.p2 = newPart;
- sendMessage(&msg, doUndoFlag);
- }
-
-//---------------------------------------------------------
// msgAddEvent
//---------------------------------------------------------
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index 244b3a72..70906a54 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -1016,7 +1016,13 @@ void Song::processMsg(AudioMsg* msg)
break;
case SEQM_CHANGE_PART:
- cmdChangePart((Part*)msg->p1, (Part*)msg->p2);
+ {
+ Part* newPart = (Part*)msg->p2;
+ Part* oldPart = (Part*)msg->p1;
+ Part part = *newPart;
+ *newPart = *oldPart;
+ *oldPart = part;
+ }
break;
case SEQM_MOVE_TRACK:
diff --git a/muse/muse/song.h b/muse/muse/song.h
index 8e011fb9..1813dab8 100644
--- a/muse/muse/song.h
+++ b/muse/muse/song.h
@@ -157,8 +157,8 @@ class Song : public QObject {
void seqSignal(int fd);
Track* addTrack(QAction*);
void setMeasureLen(int l);
- void changePart(Part*, unsigned, unsigned);
- void createLRPart(Track* track);
+ void cmdChangePart(Part*, unsigned, unsigned);
+ void cmdCreateLRPart(Track* track);
void setPos(int, const AL::Pos&);
void setPos(int, const AL::Pos&, bool sig, bool isSeek = true,
bool adjustScrollbar = false);
@@ -290,9 +290,9 @@ class Song : public QObject {
PartList* getSelectedMidiParts() const;
PartList* getSelectedWaveParts() const;
- void movePart(Part*, unsigned, Track*);
- void linkPart(Part*, unsigned, Track*);
- void copyPart(Part*, unsigned, Track*);
+ void cmdMovePart(Part*, unsigned, Track*);
+ void cmdLinkPart(Part*, unsigned, Track*);
+ void cmdCopyPart(Part*, unsigned, Track*);
void selectPart(Part*, bool add=false);
//-----------------------------------------
diff --git a/muse/muse/songpart.cpp b/muse/muse/songpart.cpp
index 7b49cdfa..d8177a69 100644
--- a/muse/muse/songpart.cpp
+++ b/muse/muse/songpart.cpp
@@ -126,10 +126,9 @@ void Song::cmdRemoveParts()
void Song::cmdChangePart(Part* oldPart, Part* newPart)
{
+ startUndo();
changePart(oldPart, newPart);
- undoOp(UndoOp::ModifyPart, oldPart, newPart);
- oldPart->events()->incARef(-1);
- updateFlags = SC_PART_MODIFIED;
+ endUndo(0);
}
//---------------------------------------------------------
@@ -138,17 +137,24 @@ void Song::cmdChangePart(Part* oldPart, Part* newPart)
void Song::changePart(Part* oldPart, Part* newPart)
{
- Part part = *newPart;
- *newPart = *oldPart;
- *oldPart = part;
+ AudioMsg msg;
+ msg.id = SEQM_CHANGE_PART;
+ msg.p1 = oldPart;
+ msg.p2 = newPart;
+ audio->sendMessage(&msg, false);
+ undoOp(UndoOp::ModifyPart, oldPart, newPart);
+ oldPart->events()->incARef(-1);
+ updateFlags = SC_PART_MODIFIED;
+ if (len() < newPart->endTick())
+ setLen(newPart->endTick());
}
//---------------------------------------------------------
-// changePart
+// cmdChangePart
// extend/shrink part in front or at end
//---------------------------------------------------------
-void Song::changePart(Part* oPart, unsigned pos, unsigned len)
+void Song::cmdChangePart(Part* oPart, unsigned pos, unsigned len)
{
startUndo();
//
@@ -184,18 +190,16 @@ void Song::changePart(Part* oPart, unsigned pos, unsigned len)
Part* nPart = new Part(*oPart, d);
nPart->setLenTick(len);
nPart->setTick(pos);
- audio->msgChangePart(oPart, nPart, false);
- endUndo(SC_PART_MODIFIED);
+ changePart(oPart, nPart);
+ endUndo(0);
oPart->track()->partListChanged();
- if (unsigned(_len) < oPart->endTick()) // update song len
- setLen(oPart->endTick());
}
//---------------------------------------------------------
-// movePart
+// cmdMovePart
//---------------------------------------------------------
-void Song::movePart(Part* oPart, unsigned pos, Track* track)
+void Song::cmdMovePart(Part* oPart, unsigned pos, Track* track)
{
Track* oTrack = oPart->track();
Part* nPart = new Part(*oPart);
@@ -207,19 +211,17 @@ void Song::movePart(Part* oPart, unsigned pos, Track* track)
addPart(nPart);
}
else {
- audio->msgChangePart(oPart, nPart, false);
+ changePart(oPart, nPart);
}
endUndo(0);
oTrack->partListChanged();
- if (len() < nPart->endTick())
- setLen(nPart->endTick());
}
//---------------------------------------------------------
-// linkPart
+// cmdLinkPart
//---------------------------------------------------------
-void Song::linkPart(Part* sPart, unsigned pos, Track* track)
+void Song::cmdLinkPart(Part* sPart, unsigned pos, Track* track)
{
Part* dPart = track->newPart(sPart, true);
dPart->setTick(pos);
@@ -229,10 +231,10 @@ void Song::linkPart(Part* sPart, unsigned pos, Track* track)
}
//---------------------------------------------------------
-// copyPart
+// cmdCopyPart
//---------------------------------------------------------
-void Song::copyPart(Part* sPart, unsigned pos, Track* track)
+void Song::cmdCopyPart(Part* sPart, unsigned pos, Track* track)
{
bool clone = sPart->events()->arefCount() > 1;
Part* dPart = track->newPart(sPart, clone);
@@ -255,10 +257,10 @@ void Song::copyPart(Part* sPart, unsigned pos, Track* track)
}
//---------------------------------------------------------
-// createLRPart
+// cmdCreateLRPart
//---------------------------------------------------------
-void Song::createLRPart(Track* track)
+void Song::cmdCreateLRPart(Track* track)
{
Part* part = track->newPart();
if (part) {
@@ -311,9 +313,9 @@ void Song::cmdSplitPart(Part* part, const Pos& pos)
part->track()->splitPart(part, tick, p1, p2);
startUndo();
- audio->msgChangePart(part, p1, false);
+ changePart(part, p1);
addPart(p2);
- endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED);
+ endUndo(0);
part->track()->partListChanged();
}
@@ -358,8 +360,8 @@ void Song::cmdGluePart(Part* oPart)
}
startUndo();
removePart(nextPart);
- audio->msgChangePart(oPart, nPart, false);
- endUndo(SC_PART_MODIFIED | SC_PART_REMOVED);
+ changePart(oPart, nPart);
+ endUndo(0);
track->partListChanged();
}
diff --git a/muse/muse/undo.cpp b/muse/muse/undo.cpp
index 1303ed79..66315a78 100644
--- a/muse/muse/undo.cpp
+++ b/muse/muse/undo.cpp
@@ -160,8 +160,14 @@ void Song::doUndo2()
i->oPart->events()->incARef(1);
break;
case UndoOp::ModifyPart:
- changePart(i->oPart, i->nPart);
+ {
+ Part* oldPart = i->oPart;
+ Part* newPart = i->nPart;
+ Part part = *newPart;
+ *newPart = *oldPart;
+ *oldPart = part;
updateFlags |= SC_PART_MODIFIED;
+ }
break;
case UndoOp::AddEvent:
deleteEvent(i->nEvent, i->part);
@@ -250,8 +256,14 @@ void Song::doRedo2()
}
break;
case UndoOp::ModifyPart:
- changePart(i->nPart, i->oPart);
+ {
+ Part* oldPart = i->oPart;
+ Part* newPart = i->nPart;
+ Part part = *newPart;
+ *newPart = *oldPart;
+ *oldPart = part;
updateFlags |= SC_PART_MODIFIED;
+ }
break;
case UndoOp::AddEvent:
addEvent(i->nEvent, i->part);