void TrackView::editBiasValue(float amount) { SyncDocument *doc = getDocument(); if (NULL == doc) return; int selectLeft = min(selectStartTrack, selectStopTrack); int selectRight = max(selectStartTrack, selectStopTrack); int selectTop = min(selectStartRow, selectStopRow); int selectBottom = max(selectStartRow, selectStopRow); if (0 == getTrackCount()) { MessageBeep(~0U); return; } SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand(); for (int track = selectLeft; track <= selectRight; ++track) { assert(track < int(getTrackCount())); size_t trackIndex = doc->getTrackIndexFromPos(track); const sync_track *t = doc->tracks[trackIndex]; for (int row = selectTop; row <= selectBottom; ++row) { int idx = sync_find_key(t, row); if (idx >= 0) { struct track_key k = t->keys[idx]; // copy old key k.value += amount; // modify value // add sub-command SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), k); multiCmd->addCommand(cmd); } } } if (0 == multiCmd->getSize()) { MessageBeep(~0U); delete multiCmd; } else { doc->exec(multiCmd); SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0); invalidateRange(selectLeft, selectRight, selectTop, selectBottom); } }
void TrackView::editDelete() { SyncDocument *doc = getDocument(); if (NULL == doc) return; int selectLeft = min(selectStartTrack, selectStopTrack); int selectRight = max(selectStartTrack, selectStopTrack); int selectTop = min(selectStartRow, selectStopRow); int selectBottom = max(selectStartRow, selectStopRow); if (0 == getTrackCount()) return; assert(selectRight < int(getTrackCount())); SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand(); for (int track = selectLeft; track <= selectRight; ++track) { size_t trackIndex = doc->getTrackIndexFromPos(track); const sync_track *t = doc->tracks[trackIndex]; for (int row = selectTop; row <= selectBottom; ++row) { if (is_key_frame(t, row)) { SyncDocument::Command *cmd = new SyncDocument::DeleteCommand(int(trackIndex), row); multiCmd->addCommand(cmd); } } } if (0 == multiCmd->getSize()) { MessageBeep(~0U); delete multiCmd; } else { doc->exec(multiCmd); SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0); InvalidateRect(getWin(), NULL, FALSE); } }