diff options
author | Florian Jung <flo@windfisch.org> | 2011-04-21 10:40:02 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-04-21 10:40:02 +0000 |
commit | ba3b8723b9672bd42888da2e9f1f644393a46c39 (patch) | |
tree | 71ea9c0704549784a3f0ffb597bbf03ae240f1d9 /muse2 | |
parent | 79f53afff1d249fb568bcf266bdb4ac8fe9b6521 (diff) | |
parent | 0b8e29363db66ddbd0dac925bb57b75310a93eba (diff) |
merged in keymap-undo and -songChanged support from trunk
Diffstat (limited to 'muse2')
-rw-r--r-- | muse2/ChangeLog | 4 | ||||
-rw-r--r-- | muse2/awl/sigedit.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/audio.h | 3 | ||||
-rw-r--r-- | muse2/muse/master/lmaster.cpp | 52 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 5 | ||||
-rw-r--r-- | muse2/muse/seqmsg.cpp | 27 | ||||
-rw-r--r-- | muse2/muse/song.cpp | 12 | ||||
-rw-r--r-- | muse2/muse/song.h | 59 | ||||
-rw-r--r-- | muse2/muse/undo.cpp | 21 | ||||
-rw-r--r-- | muse2/muse/undo.h | 1 |
10 files changed, 124 insertions, 62 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog index 002b8bf6..0a3f6c74 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -1,3 +1,7 @@ +19.04.2011: + - Added undo/redo to master list editor for key editing, should implicitly + mean that SC_KEY is emitted to detect song change (not tested) (rj) + - fixed bug with undo not working for first signature event (rj) 16.04.2011: - Added KeyList for keeping key change events and ability to edit it in master list editor (rj) diff --git a/muse2/awl/sigedit.cpp b/muse2/awl/sigedit.cpp index 460aafe4..984a209b 100644 --- a/muse2/awl/sigedit.cpp +++ b/muse2/awl/sigedit.cpp @@ -161,7 +161,7 @@ QAbstractSpinBox::StepEnabled SigEdit::stepEnabled() const void SigEdit::fixup(QString& input) const { - printf("fixup <%s>\n", input.toLatin1().constData()); +// printf("fixup <%s>\n", input.toLatin1().constData()); } //--------------------------------------------------------- diff --git a/muse2/muse/audio.h b/muse2/muse/audio.h index 58f399e3..1eb03bbc 100644 --- a/muse2/muse/audio.h +++ b/muse2/muse/audio.h @@ -42,6 +42,7 @@ enum { SEQM_ADD_PART, SEQM_REMOVE_PART, SEQM_CHANGE_PART, SEQM_ADD_EVENT, SEQM_REMOVE_EVENT, SEQM_CHANGE_EVENT, SEQM_ADD_TEMPO, SEQM_SET_TEMPO, SEQM_REMOVE_TEMPO, SEQM_ADD_SIG, SEQM_REMOVE_SIG, + SEQM_ADD_KEY, SEQM_REMOVE_KEY, SEQM_SET_GLOBAL_TEMPO, SEQM_UNDO, SEQM_REDO, SEQM_RESET_DEVICES, SEQM_INIT_DEVICES, SEQM_PANIC, @@ -218,6 +219,8 @@ class Audio { void msgDeleteTempo(int tick, int tempo, bool doUndoFlag = true); void msgAddSig(int tick, int z, int n, bool doUndoFlag = true); void msgRemoveSig(int tick, int z, int n, bool doUndoFlag = true); + void msgAddKey(int tick, int key, bool doUndoFlag = true); + void msgRemoveKey(int tick, int key, bool doUndoFlag = true); void msgShowInstrumentGui(MidiInstrument*, bool); void msgShowInstrumentNativeGui(MidiInstrument*, bool); void msgPanic(); diff --git a/muse2/muse/master/lmaster.cpp b/muse2/muse/master/lmaster.cpp index 412360e3..295dfb52 100644 --- a/muse2/muse/master/lmaster.cpp +++ b/muse2/muse/master/lmaster.cpp @@ -56,7 +56,7 @@ key_enum stringToKey(QString input) //flo //don't change this function (except when renaming stuff) QString keyToString(key_enum key) //flo { - int index; + int index=0; switch(key) { case KEY_C: index= 0; break; @@ -103,7 +103,7 @@ void LMaster::closeEvent(QCloseEvent* e) void LMaster::songChanged(int type) { - if (type & (SC_SIG | SC_TEMPO)) + if (type & (SC_SIG | SC_TEMPO | SC_KEY )) updateList(); } @@ -292,19 +292,19 @@ void LMaster::updateList() ++it; } - else if (ik != k->rend() && (is == s->rend() && (ik->second.tick >= it->second->tick) - || (it == t->rend() && ik->second.tick >= is->second->tick ))) {// ik biggest + else if ((ik != k->rend()) && (is == s->rend()) && (ik->second.tick >= it->second->tick) + || (it == t->rend()) && (ik->second.tick >= is->second->tick )) {// ik biggest insertKey(ik->second); ++ik; } - else if (is != s->rend() && (ik == k->rend() && (is->second->tick >= it->second->tick) - || (it == t->rend() && is->second->tick >= ik->second.tick ))) {// is biggest + else if ((is != s->rend()) && (ik == k->rend()) && (is->second->tick >= it->second->tick) + || (it == t->rend()) && (is->second->tick >= ik->second.tick )) {// is biggest insertSig(is->second); ++is; } - else if (it != t->rend() && (ik == k->rend() && (it->second->tick >= is->second->tick) - || (is == s->rend() && it->second->tick >= ik->second.tick ))) {// it biggest + else if ((it != t->rend()) && (ik == k->rend()) && (it->second->tick >= is->second->tick) + || (is == s->rend()) && (it->second->tick >= ik->second.tick )) {// it biggest insertTempo(it->second); ++it; } @@ -416,9 +416,9 @@ void LMaster::cmd(int cmd) } case LMASTER_KEYEVENT: { - //LMasterKeyEventItem* k = (LMasterKeyEventItem*) l; - keymap.delKey(l->tick()); - //audio->msgRemoveSig(k->tick(), k->z(), k->n()); + LMasterKeyEventItem* k = (LMasterKeyEventItem*) l; + //keymap.delKey(l->tick()); + audio->msgRemoveKey(k->tick(), k->key()); break; } default: @@ -647,12 +647,11 @@ void LMaster::returnPressed() else if (editedItem->getType() == LMASTER_KEYEVENT) { LMasterKeyEventItem* k = (LMasterKeyEventItem*) editedItem; key_enum key = k->key(); -// song->startUndo(); -// audio->msgDeleteTempo(oldtick, tempo, false); -// audio->msgAddTempo(newtick, tempo, false); -// song->endUndo(SC_TEMPO); - keymap.delKey(oldtick); - keymap.addKey(newtick, key); + song->startUndo(); + audio->msgRemoveKey(oldtick, key, false); + audio->msgAddKey(newtick, key, false); + song->endUndo(SC_KEY); + // Select the item: QTreeWidgetItem* newSelected = (QTreeWidgetItem*) getItemAtPos(newtick, LMASTER_KEYEVENT); if (newSelected) { @@ -673,7 +672,6 @@ void LMaster::returnPressed() // else if (editedItem->getType() == LMASTER_SIGEVENT && editorColumn == LMASTER_VAL_COL) { - printf("SIGEVENT return\n"); ///Sig newSig = sig_editor->sig(); AL::TimeSignature newSig = sig_editor->sig(); @@ -683,12 +681,11 @@ void LMaster::returnPressed() if(newSig.isValid()) { LMasterSigEventItem* e = (LMasterSigEventItem*) editedItem; - printf("adding sig %d %d\n", e->z(),e->n()); + //printf("adding sig %d %d\n", e->z(),e->n()); int tick = e->tick(); if (!editingNewItem) { song->startUndo(); - if (tick > 0) - audio->msgRemoveSig(tick, e->z(), e->n(), false); + audio->msgRemoveSig(tick, e->z(), e->n(), false); audio->msgAddSig(tick, newSig.z, newSig.n, false); song->endUndo(SC_SIG); } @@ -701,7 +698,6 @@ void LMaster::returnPressed() } else if (editedItem->getType() == LMASTER_KEYEVENT && editorColumn == LMASTER_VAL_COL) { - printf("KEYEVENT return\n"); QString input = key_editor->currentText(); key_editor->hide(); repaint(); @@ -711,18 +707,16 @@ void LMaster::returnPressed() key_enum key = stringToKey(input); if (!editingNewItem) { -// song->startUndo(); -// audio->msgDeleteTempo(tick, e->tempo(), false); -// audio->msgAddTempo(tick, tempo, false); -// song->endUndo(SC_TEMPO); - keymap.addKey(tick,key); + song->startUndo(); + audio->msgRemoveKey(tick, e->key(), false); + audio->msgAddKey(tick, key, false); + song->endUndo(SC_KEY); } // // New item edited: // else { - //audio->msgAddTempo(tick, tempo, true); - keymap.addKey(tick,key); + audio->msgAddKey(tick, key, true); } } updateList(); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index 6d6b1879..e904ce46 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -659,10 +659,10 @@ void ScoreCanvas::song_changed(int flags) { if (flags & (SC_PART_INSERTED | SC_PART_MODIFIED | SC_PART_REMOVED | SC_EVENT_INSERTED | SC_EVENT_MODIFIED | SC_EVENT_REMOVED | - SC_SIG) ) + SC_SIG | SC_KEY) ) { cout << "song changed!" << endl; - + calc_pos_add_list(); for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++) @@ -3236,7 +3236,6 @@ void ScoreCanvas::set_quant(int val) /* BUGS and potential bugs * o when color=black, then the tie has a wrong color, because * partColors[BLACK_INDEX] is out of bounds - * o updating the keymap doesn't emit a songChanged() signal! * o when the keymap is not used, this will probably lead to a bug * o when adding a note, it's added to the first stave * the problem is: there's always the first part selected diff --git a/muse2/muse/seqmsg.cpp b/muse2/muse/seqmsg.cpp index 564cce42..950015b2 100644 --- a/muse2/muse/seqmsg.cpp +++ b/muse2/muse/seqmsg.cpp @@ -1067,6 +1067,33 @@ void Audio::msgRemoveSig(int tick, int z, int n, bool doUndoFlag) } //--------------------------------------------------------- +// msgAddKey +//--------------------------------------------------------- + +void Audio::msgAddKey(int tick, int key, bool doUndoFlag) + { + AudioMsg msg; + msg.id = SEQM_ADD_KEY; + msg.a = tick; + msg.b = key; + sendMessage(&msg, doUndoFlag); + } + +//--------------------------------------------------------- +// msgRemoveKey +//! sends remove key message +//--------------------------------------------------------- + +void Audio::msgRemoveKey(int tick, int key, bool doUndoFlag) + { + AudioMsg msg; + msg.id = SEQM_REMOVE_KEY; + msg.a = tick; + msg.b = key; + sendMessage(&msg, doUndoFlag); + } + +//--------------------------------------------------------- // msgScanAlsaMidiPorts //--------------------------------------------------------- diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp index a7cff79d..ad6de83d 100644 --- a/muse2/muse/song.cpp +++ b/muse2/muse/song.cpp @@ -1954,6 +1954,18 @@ void Song::processMsg(AudioMsg* msg) updateFlags = SC_SIG; break; + case SEQM_ADD_KEY: + undoOp(UndoOp::AddKey, msg->a, msg->b); + keymap.addKey(msg->a, (key_enum) msg->b); + updateFlags = SC_KEY; + break; + + case SEQM_REMOVE_KEY: + undoOp(UndoOp::DeleteKey, msg->a, msg->b); + keymap.delKey(msg->a); + updateFlags = SC_KEY; + break; + default: printf("unknown seq message %d\n", msg->id); break; diff --git a/muse2/muse/song.h b/muse2/muse/song.h index e4695728..b097a5ee 100644 --- a/muse2/muse/song.h +++ b/muse2/muse/song.h @@ -45,36 +45,37 @@ class MidiDevice; class AudioPort; class AudioDevice; -#define SC_TRACK_INSERTED 1 -#define SC_TRACK_REMOVED 2 -#define SC_TRACK_MODIFIED 4 -#define SC_PART_INSERTED 8 -#define SC_PART_REMOVED 0x10 -#define SC_PART_MODIFIED 0x20 -#define SC_EVENT_INSERTED 0x40 -#define SC_EVENT_REMOVED 0x80 -#define SC_EVENT_MODIFIED 0x100 -#define SC_SIG 0x200 // timing signature -#define SC_TEMPO 0x400 // tempo map changed -#define SC_MASTER 0x800 // master flag changed -#define SC_SELECTION 0x1000 -#define SC_MIDI_CONTROLLER 0x2000 // must update midi mixer -#define SC_MUTE 0x4000 -#define SC_SOLO 0x8000 -#define SC_RECFLAG 0x10000 -#define SC_ROUTE 0x20000 -#define SC_CHANNELS 0x40000 -#define SC_CONFIG 0x80000 // midiPort-midiDevice -#define SC_DRUMMAP 0x100000 // must update drumeditor -#define SC_MIXER_VOLUME 0x200000 -#define SC_MIXER_PAN 0x400000 -#define SC_AUTOMATION 0x800000 -#define SC_AUX 0x1000000 // mixer aux changed -#define SC_RACK 0x2000000 // mixer rack changed -#define SC_CLIP_MODIFIED 0x4000000 +#define SC_TRACK_INSERTED 1 +#define SC_TRACK_REMOVED 2 +#define SC_TRACK_MODIFIED 4 +#define SC_PART_INSERTED 8 +#define SC_PART_REMOVED 0x10 +#define SC_PART_MODIFIED 0x20 +#define SC_EVENT_INSERTED 0x40 +#define SC_EVENT_REMOVED 0x80 +#define SC_EVENT_MODIFIED 0x100 +#define SC_SIG 0x200 // timing signature +#define SC_TEMPO 0x400 // tempo map changed +#define SC_MASTER 0x800 // master flag changed +#define SC_SELECTION 0x1000 +#define SC_MIDI_CONTROLLER 0x2000 // must update midi mixer +#define SC_MUTE 0x4000 +#define SC_SOLO 0x8000 +#define SC_RECFLAG 0x10000 +#define SC_ROUTE 0x20000 +#define SC_CHANNELS 0x40000 +#define SC_CONFIG 0x80000 // midiPort-midiDevice +#define SC_DRUMMAP 0x100000 // must update drumeditor +#define SC_MIXER_VOLUME 0x200000 +#define SC_MIXER_PAN 0x400000 +#define SC_AUTOMATION 0x800000 +#define SC_AUX 0x1000000 // mixer aux changed +#define SC_RACK 0x2000000 // mixer rack changed +#define SC_CLIP_MODIFIED 0x4000000 #define SC_MIDI_CONTROLLER_ADD 0x8000000 // a hardware midi controller was added or deleted -#define SC_MIDI_TRACK_PROP 0x10000000 // a midi track's properties changed (channel, compression etc) -#define SC_SONG_TYPE 0x20000000 // the midi song type (mtype) changed +#define SC_MIDI_TRACK_PROP 0x10000000 // a midi track's properties changed (channel, compression etc) +#define SC_SONG_TYPE 0x20000000 // the midi song type (mtype) changed +#define SC_KEY 0x40000000 // key map changed #define REC_NOTE_FIFO_SIZE 16 diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp index 8d218b0f..44d37591 100644 --- a/muse2/muse/undo.cpp +++ b/muse2/muse/undo.cpp @@ -8,6 +8,7 @@ ///#include "sig.h" #include "al/sig.h" // Tim. +#include "keyevent.h" #include "undo.h" #include "song.h" @@ -72,6 +73,8 @@ void UndoOp::dump() case DeleteSig: case ModifyClip: case ModifyMarker: + case AddKey: + case DeleteKey: break; } } @@ -432,6 +435,16 @@ void Song::doUndo2() AL::sigmap.add(i->a, AL::TimeSignature(i->b, i->c)); updateFlags |= SC_SIG; break; + case UndoOp::AddKey: + ///sigmap.del(i->a); + keymap.delKey(i->a); + updateFlags |= SC_KEY; + break; + case UndoOp::DeleteKey: + ///sigmap.add(i->a, i->b, i->c); + keymap.addKey(i->a, (key_enum)i->b); + updateFlags |= SC_KEY; + break; case UndoOp::ModifyClip: case UndoOp::ModifyMarker: break; @@ -660,6 +673,14 @@ void Song::doRedo2() AL::sigmap.del(i->a); updateFlags |= SC_SIG; break; + case UndoOp::AddKey: + keymap.addKey(i->a, (key_enum)i->b); + updateFlags |= SC_KEY; + break; + case UndoOp::DeleteKey: + keymap.delKey(i->a); + updateFlags |= SC_KEY; + break; case UndoOp::ModifyClip: case UndoOp::ModifyMarker: break; diff --git a/muse2/muse/undo.h b/muse2/muse/undo.h index b17e8e21..eb5600ef 100644 --- a/muse2/muse/undo.h +++ b/muse2/muse/undo.h @@ -33,6 +33,7 @@ struct UndoOp { AddEvent, DeleteEvent, ModifyEvent, AddTempo, DeleteTempo, AddSig, DeleteSig, + AddKey, DeleteKey, SwapTrack, ModifyClip, ModifyMarker |