diff options
author | Tim E. Real <termtech@rogers.com> | 2012-08-04 22:14:50 +0000 |
---|---|---|
committer | Tim E. Real <termtech@rogers.com> | 2012-08-04 22:14:50 +0000 |
commit | 345fb0cc41b94b08134dc1f40020b4bf26e1d46b (patch) | |
tree | 78f6da3cf9cd64a84ead190e615a175a6a82242d /muse2/muse/song.cpp | |
parent | 8ee7ac503d93d7a0b6cf3b49c3255d389ba59c17 (diff) |
REWRITE: Introducing: More bits for Song Changed SC_* flags.
Added MusECore::SongChangedFlags_t (in new type_defs.h file). Declared as int64 type.
All Song Changed parameters, handlers, connections, calls, colateral operations etc. now use
this new SongChangedFlags_t.
All the handlers are now ready for the code bodies to accept any extra flags, devs need not
do anything more than define new SC_* flags and write support inside the handlers.
Please beware these possible extra flags when writing songChanged handlers and setting updateFlags.
Diffstat (limited to 'muse2/muse/song.cpp')
-rw-r--r-- | muse2/muse/song.cpp | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index b738c795..9781116f 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -524,7 +524,7 @@ void Song::duplicateTracks() --trackno; } - int update_flags = SC_TRACK_INSERTED; + MusECore::SongChangedFlags_t update_flags = SC_TRACK_INSERTED; if(flags & (Track::ASSIGN_ROUTES | Track::ASSIGN_DEFAULT_ROUTES)) update_flags |= SC_ROUTE; MusEGlobal::song->endUndo(update_flags); @@ -1370,22 +1370,17 @@ void Song::rewindStart() // update //--------------------------------------------------------- -void Song::update(int flags, int flags2, bool allowRecursion) +void Song::update(MusECore::SongChangedFlags_t flags, bool allowRecursion) { - // HACK: If flags is -1, it is very highly likely the caller wanted flags2 = -1 as well. - // Highly improbable someone only wanted all 32 flags set and not flags2. - if(flags == -1) - flags2 = -1; - static int level = 0; // DEBUG if (level && !allowRecursion) { - printf("THIS SHOULD NEVER HAPPEN: unallowed recursion in Song::update(%08x %08x), level %d!\n" + printf("THIS SHOULD NEVER HAPPEN: unallowed recursion in Song::update(%08x), level %d!\n" " the songChanged() signal is NOT emitted. this will\n" - " probably cause windows being not up-to-date.\n", flags, flags2, level); + " probably cause windows being not up-to-date.\n", flags, level); return; } ++level; - emit songChanged(flags, flags2); + emit songChanged(flags); --level; } @@ -1779,11 +1774,11 @@ void Song::rescanAlsaPorts() void Song::endMsgCmd() { - if (updateFlags || updateFlags2) { + if (updateFlags) { redoList->clearDelete(); MusEGlobal::undoAction->setEnabled(true); MusEGlobal::redoAction->setEnabled(false); - emit songChanged(updateFlags, updateFlags2); + emit songChanged(updateFlags); } } @@ -1794,7 +1789,6 @@ void Song::endMsgCmd() void Song::undo() { updateFlags = 0; - updateFlags2 = 0; if (doUndo1()) return; MusEGlobal::audio->msgUndo(); @@ -1805,7 +1799,7 @@ void Song::undo() if(updateFlags && (SC_TRACK_REMOVED | SC_TRACK_INSERTED)) MusEGlobal::audio->msgUpdateSoloStates(); - emit songChanged(updateFlags, updateFlags2); + emit songChanged(updateFlags); } //--------------------------------------------------------- @@ -1815,7 +1809,6 @@ void Song::undo() void Song::redo() { updateFlags = 0; - updateFlags2 = 0; if (doRedo1()) return; MusEGlobal::audio->msgRedo(); @@ -1826,7 +1819,7 @@ void Song::redo() if(updateFlags && (SC_TRACK_REMOVED | SC_TRACK_INSERTED)) MusEGlobal::audio->msgUpdateSoloStates(); - emit songChanged(updateFlags, updateFlags2); + emit songChanged(updateFlags); } //--------------------------------------------------------- @@ -1858,20 +1851,15 @@ void Song::processMsg(AudioMsg* msg) } } updateFlags = SC_TRACK_MODIFIED; - updateFlags2 = 0; break; case SEQM_ADD_EVENT: updateFlags = SC_EVENT_INSERTED; - updateFlags2 = 0; if (addEvent(msg->ev1, (MidiPart*)msg->p2)) { Event ev; addUndo(UndoOp(UndoOp::AddEvent, ev, msg->ev1, (Part*)msg->p2, msg->a, msg->b)); } else - { updateFlags = 0; - updateFlags2 = 0; - } if(msg->a) addPortCtrlEvents(msg->ev1, (Part*)msg->p2, msg->b); break; @@ -1885,7 +1873,6 @@ void Song::processMsg(AudioMsg* msg) addUndo(UndoOp(UndoOp::DeleteEvent, e, event, (Part*)part, msg->a, msg->b)); deleteEvent(event, part); updateFlags = SC_EVENT_REMOVED; - updateFlags2 = 0; } break; case SEQM_CHANGE_EVENT: @@ -1896,7 +1883,6 @@ void Song::processMsg(AudioMsg* msg) addPortCtrlEvents(msg->ev2, (Part*)msg->p3, msg->b); addUndo(UndoOp(UndoOp::ModifyEvent, msg->ev2, msg->ev1, (Part*)msg->p3, msg->a, msg->b)); updateFlags = SC_EVENT_MODIFIED; - updateFlags2 = 0; break; // Moved here from MidiSeq::processMsg p4.0.34 @@ -1923,14 +1909,12 @@ void Song::processMsg(AudioMsg* msg) addUndo(UndoOp(UndoOp::AddTempo, msg->a, msg->b)); MusEGlobal::tempomap.addTempo(msg->a, msg->b); updateFlags = SC_TEMPO; - updateFlags2 = 0; break; case SEQM_SET_TEMPO: addUndo(UndoOp(UndoOp::AddTempo, msg->a, msg->b)); MusEGlobal::tempomap.setTempo(msg->a, msg->b); updateFlags = SC_TEMPO; - updateFlags2 = 0; break; case SEQM_SET_GLOBAL_TEMPO: @@ -1941,35 +1925,30 @@ void Song::processMsg(AudioMsg* msg) addUndo(UndoOp(UndoOp::DeleteTempo, msg->a, msg->b)); MusEGlobal::tempomap.delTempo(msg->a); updateFlags = SC_TEMPO; - updateFlags2 = 0; break; case SEQM_ADD_SIG: addUndo(UndoOp(UndoOp::AddSig, msg->a, msg->b, msg->c)); AL::sigmap.add(msg->a, AL::TimeSignature(msg->b, msg->c)); updateFlags = SC_SIG; - updateFlags2 = 0; break; case SEQM_REMOVE_SIG: addUndo(UndoOp(UndoOp::DeleteSig, msg->a, msg->b, msg->c)); AL::sigmap.del(msg->a); updateFlags = SC_SIG; - updateFlags2 = 0; break; case SEQM_ADD_KEY: addUndo(UndoOp(UndoOp::AddKey, msg->a, msg->b)); MusEGlobal::keymap.addKey(msg->a, (key_enum) msg->b); updateFlags = SC_KEY; - updateFlags2 = 0; break; case SEQM_REMOVE_KEY: addUndo(UndoOp(UndoOp::DeleteKey, msg->a, msg->b)); MusEGlobal::keymap.delKey(msg->a); updateFlags = SC_KEY; - updateFlags2 = 0; break; default: @@ -1987,7 +1966,6 @@ void Song::cmdAddPart(Part* part) addPart(part); addUndo(UndoOp(UndoOp::AddPart, part)); updateFlags = SC_PART_INSERTED; - updateFlags2 = 0; } //--------------------------------------------------------- @@ -2001,7 +1979,6 @@ void Song::cmdRemovePart(Part* part) part->events()->incARef(-1); unchainClone(part); updateFlags = SC_PART_REMOVED; - updateFlags2 = 0; } //--------------------------------------------------------- @@ -2028,7 +2005,6 @@ void Song::cmdChangePart(Part* oldPart, Part* newPart, bool doCtrls, bool doClon addPortCtrlEvents(newPart, doClones); updateFlags = SC_PART_MODIFIED; - updateFlags2 = 0; } //--------------------------------------------------------- @@ -2163,7 +2139,7 @@ void Song::clear(bool signal, bool clear_all) if (signal) { emit loopChanged(false); recordChanged(false); - emit songChanged(-1, -1); + emit songChanged(-1); } } |