From 74eee30216408dde248cf5efa07a0cf548ecfa52 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 18 Feb 2008 21:15:50 +0000 Subject: [PATCH] renamed SyncEditData to SyncDocument, since that's essentially what it is ;) --- editor/editor.vcproj | 4 + editor/syncdocument.h | 260 +++++++++++++++++++++++++++++++++++++++++++++++ editor/synceditdata.h | 262 ------------------------------------------------ editor/synctracker2.cpp | 19 +++- editor/trackview.cpp | 77 +++++++------- editor/trackview.h | 10 +- 6 files changed, 321 insertions(+), 311 deletions(-) create mode 100644 editor/syncdocument.h delete mode 100644 editor/synceditdata.h diff --git a/editor/editor.vcproj b/editor/editor.vcproj index 6280c2f..dee7738 100644 --- a/editor/editor.vcproj +++ b/editor/editor.vcproj @@ -226,6 +226,10 @@ > + + diff --git a/editor/syncdocument.h b/editor/syncdocument.h new file mode 100644 index 0000000..771d226 --- /dev/null +++ b/editor/syncdocument.h @@ -0,0 +1,260 @@ +/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink + * For conditions of distribution and use, see copyright notice in LICENSE.TXT + */ + +#pragma once + +#include "../sync/network.h" +#include "../sync/data.h" +#include +#include + +class SyncDocument : public sync::Data +{ +public: + SyncDocument() : sync::Data(), clientPaused(true) {} + + void sendSetKeyCommand(int track, int row, const sync::Track::KeyFrame &key) + { + if (INVALID_SOCKET == clientSocket) return; + if (clientRemap.count(track) == 0) return; + track = int(clientRemap[track]); + + unsigned char cmd = SET_KEY; + send(clientSocket, (char*)&cmd, 1, 0); + send(clientSocket, (char*)&track, sizeof(int), 0); + send(clientSocket, (char*)&row, sizeof(int), 0); + send(clientSocket, (char*)&key.value, sizeof(float), 0); + send(clientSocket, (char*)&key.interpolationType, 1, 0); + } + + void sendDeleteKeyCommand(int track, int row) + { + if (INVALID_SOCKET == clientSocket) return; + + unsigned char cmd = DELETE_KEY; + send(clientSocket, (char*)&cmd, 1, 0); + send(clientSocket, (char*)&track, sizeof(int), 0); + send(clientSocket, (char*)&row, sizeof(int), 0); + } + + void sendSetRowCommand(int row) + { + if (INVALID_SOCKET == clientSocket) return; + unsigned char cmd = SET_ROW; + send(clientSocket, (char*)&cmd, 1, 0); + send(clientSocket, (char*)&row, sizeof(int), 0); + } + + void sendPauseCommand(bool pause) + { + unsigned char cmd = PAUSE; + send(clientSocket, (char*)&cmd, 1, 0); + unsigned char flag = pause; + send(clientSocket, (char*)&flag, 1, 0); + clientPaused = pause; + } + + void sendSaveCommand() + { + unsigned char cmd = SAVE_TRACKS; + send(clientSocket, (char*)&cmd, 1, 0); + } + + class Command + { + public: + virtual ~Command() {} + virtual void exec(SyncDocument *data) = 0; + virtual void undo(SyncDocument *data) = 0; + }; + + class InsertCommand : public Command + { + public: + InsertCommand(int track, int row, const sync::Track::KeyFrame &key) : track(track), row(row), key(key) {} + ~InsertCommand() {} + + virtual void exec(SyncDocument *data) + { + sync::Track &t = data->getTrack(this->track); + assert(!t.isKeyFrame(row)); + t.setKeyFrame(row, key); + + data->sendSetKeyCommand(track, row, key); // update clients + } + + virtual void undo(SyncDocument *data) + { + sync::Track &t = data->getTrack(this->track); + assert(t.isKeyFrame(row)); + t.deleteKeyFrame(row); + + data->sendDeleteKeyCommand(track, row); // update clients + } + + private: + int track, row; + sync::Track::KeyFrame key; + }; + + class DeleteCommand : public Command + { + public: + DeleteCommand(int track, int row) : track(track), row(row) {} + ~DeleteCommand() {} + + virtual void exec(SyncDocument *data) + { + sync::Track &t = data->getTrack(this->track); + assert(t.isKeyFrame(row)); + oldKey = *t.getKeyFrame(row); + t.deleteKeyFrame(row); + + data->sendDeleteKeyCommand(track, row); // update clients + } + + virtual void undo(SyncDocument *data) + { + sync::Track &t = data->getTrack(this->track); + assert(!t.isKeyFrame(row)); + t.setKeyFrame(row, oldKey); + + data->sendSetKeyCommand(track, row, oldKey); // update clients + } + + private: + int track, row; + sync::Track::KeyFrame oldKey; + }; + + + class EditCommand : public Command + { + public: + EditCommand(int track, int row, const sync::Track::KeyFrame &key) : track(track), row(row), key(key) {} + ~EditCommand() {} + + virtual void exec(SyncDocument *data) + { + sync::Track &t = data->getTrack(this->track); + + // store old key + assert(t.isKeyFrame(row)); + oldKey = *t.getKeyFrame(row); + + // update + t.setKeyFrame(row, key); + + data->sendSetKeyCommand(track, row, key); // update clients + } + + virtual void undo(SyncDocument *data) + { + sync::Track &t = data->getTrack(this->track); + + assert(t.isKeyFrame(row)); + t.setKeyFrame(row, oldKey); + + data->sendSetKeyCommand(track, row, oldKey); // update clients + } + + private: + int track, row; + sync::Track::KeyFrame oldKey, key; + }; + + class MultiCommand : public Command + { + public: + ~MultiCommand() + { + std::list::iterator it; + for (it = commands.begin(); it != commands.end(); ++it) + { + delete *it; + } + commands.clear(); + } + + void addCommand(Command *cmd) + { + commands.push_back(cmd); + } + + size_t getSize() const { return commands.size(); } + + virtual void exec(SyncDocument *data) + { + std::list::iterator it; + for (it = commands.begin(); it != commands.end(); ++it) (*it)->exec(data); + } + + virtual void undo(SyncDocument *data) + { + std::list::iterator it; + for (it = commands.begin(); it != commands.end(); ++it) (*it)->undo(data); + } + + private: + std::list commands; + }; + + void exec(Command *cmd) + { + undoStack.push(cmd); + cmd->exec(this); + clearRedoStack(); + } + + bool undo() + { + if (undoStack.size() == 0) return false; + + Command *cmd = undoStack.top(); + undoStack.pop(); + + redoStack.push(cmd); + cmd->undo(this); + return true; + } + + bool redo() + { + if (redoStack.size() == 0) return false; + + Command *cmd = redoStack.top(); + redoStack.pop(); + + undoStack.push(cmd); + cmd->exec(this); + return true; + } + + void clearRedoStack() + { + while (!redoStack.empty()) + { + Command *cmd = redoStack.top(); + redoStack.pop(); + delete cmd; + } + } + + Command *getSetKeyFrameCommand(int track, int row, const sync::Track::KeyFrame &key) + { + sync::Track &t = getTrack(track); + SyncDocument::Command *cmd; + if (t.isKeyFrame(row)) cmd = new EditCommand(track, row, key); + else cmd = new InsertCommand(track, row, key); + return cmd; + } + + SOCKET clientSocket; + std::map clientRemap; + bool clientPaused; + +private: + std::stack undoStack; + std::stack redoStack; +}; diff --git a/editor/synceditdata.h b/editor/synceditdata.h deleted file mode 100644 index 7e1e150..0000000 --- a/editor/synceditdata.h +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright (C) 2007-2008 Erik Faye-Lund and Egbert Teeselink - * For conditions of distribution and use, see copyright notice in LICENSE.TXT - */ - -#pragma once - -#include "../sync/network.h" -#include "../sync/data.h" -#include -#include - -class SyncEditData : public sync::Data -{ -public: - SyncEditData() : sync::Data(), clientPaused(true) {} - - void sendSetKeyCommand(int track, int row, const sync::Track::KeyFrame &key) - { - if (INVALID_SOCKET == clientSocket) return; - if (clientRemap.count(track) == 0) return; - track = int(clientRemap[track]); - - unsigned char cmd = SET_KEY; - send(clientSocket, (char*)&cmd, 1, 0); - send(clientSocket, (char*)&track, sizeof(int), 0); - send(clientSocket, (char*)&row, sizeof(int), 0); - send(clientSocket, (char*)&key.value, sizeof(float), 0); - send(clientSocket, (char*)&key.interpolationType, 1, 0); - } - - void sendDeleteKeyCommand(int track, int row) - { - if (INVALID_SOCKET == clientSocket) return; - - unsigned char cmd = DELETE_KEY; - send(clientSocket, (char*)&cmd, 1, 0); - send(clientSocket, (char*)&track, sizeof(int), 0); - send(clientSocket, (char*)&row, sizeof(int), 0); - } - - void sendSetRowCommand(int row) - { - if (INVALID_SOCKET == clientSocket) return; - printf("sending row pos\n"); - - unsigned char cmd = SET_ROW; - send(clientSocket, (char*)&cmd, 1, 0); - send(clientSocket, (char*)&row, sizeof(int), 0); - } - - void sendPauseCommand(bool pause) - { - unsigned char cmd = PAUSE; - send(clientSocket, (char*)&cmd, 1, 0); - unsigned char flag = pause; - send(clientSocket, (char*)&flag, 1, 0); - clientPaused = pause; - } - - void sendSaveCommand() - { - unsigned char cmd = SAVE_TRACKS; - send(clientSocket, (char*)&cmd, 1, 0); - } - - class Command - { - public: - virtual ~Command() {} - virtual void exec(SyncEditData *data) = 0; - virtual void undo(SyncEditData *data) = 0; - }; - - class InsertCommand : public Command - { - public: - InsertCommand(int track, int row, const sync::Track::KeyFrame &key) : track(track), row(row), key(key) {} - ~InsertCommand() {} - - virtual void exec(SyncEditData *data) - { - sync::Track &t = data->getTrack(this->track); - assert(!t.isKeyFrame(row)); - t.setKeyFrame(row, key); - - data->sendSetKeyCommand(track, row, key); // update clients - } - - virtual void undo(SyncEditData *data) - { - sync::Track &t = data->getTrack(this->track); - assert(t.isKeyFrame(row)); - t.deleteKeyFrame(row); - - data->sendDeleteKeyCommand(track, row); // update clients - } - - private: - int track, row; - sync::Track::KeyFrame key; - }; - - class DeleteCommand : public Command - { - public: - DeleteCommand(int track, int row) : track(track), row(row) {} - ~DeleteCommand() {} - - virtual void exec(SyncEditData *data) - { - sync::Track &t = data->getTrack(this->track); - assert(t.isKeyFrame(row)); - oldKey = *t.getKeyFrame(row); - t.deleteKeyFrame(row); - - data->sendDeleteKeyCommand(track, row); // update clients - } - - virtual void undo(SyncEditData *data) - { - sync::Track &t = data->getTrack(this->track); - assert(!t.isKeyFrame(row)); - t.setKeyFrame(row, oldKey); - - data->sendSetKeyCommand(track, row, oldKey); // update clients - } - - private: - int track, row; - sync::Track::KeyFrame oldKey; - }; - - - class EditCommand : public Command - { - public: - EditCommand(int track, int row, const sync::Track::KeyFrame &key) : track(track), row(row), key(key) {} - ~EditCommand() {} - - virtual void exec(SyncEditData *data) - { - sync::Track &t = data->getTrack(this->track); - - // store old key - assert(t.isKeyFrame(row)); - oldKey = *t.getKeyFrame(row); - - // update - t.setKeyFrame(row, key); - - data->sendSetKeyCommand(track, row, key); // update clients - } - - virtual void undo(SyncEditData *data) - { - sync::Track &t = data->getTrack(this->track); - - assert(t.isKeyFrame(row)); - t.setKeyFrame(row, oldKey); - - data->sendSetKeyCommand(track, row, oldKey); // update clients - } - - private: - int track, row; - sync::Track::KeyFrame oldKey, key; - }; - - class MultiCommand : public Command - { - public: - ~MultiCommand() - { - std::list::iterator it; - for (it = commands.begin(); it != commands.end(); ++it) - { - delete *it; - } - commands.clear(); - } - - void addCommand(Command *cmd) - { - commands.push_back(cmd); - } - - size_t getSize() const { return commands.size(); } - - virtual void exec(SyncEditData *data) - { - std::list::iterator it; - for (it = commands.begin(); it != commands.end(); ++it) (*it)->exec(data); - } - - virtual void undo(SyncEditData *data) - { - std::list::iterator it; - for (it = commands.begin(); it != commands.end(); ++it) (*it)->undo(data); - } - - private: - std::list commands; - }; - - void exec(Command *cmd) - { - undoStack.push(cmd); - cmd->exec(this); - clearRedoStack(); - } - - bool undo() - { - if (undoStack.size() == 0) return false; - - Command *cmd = undoStack.top(); - undoStack.pop(); - - redoStack.push(cmd); - cmd->undo(this); - return true; - } - - bool redo() - { - if (redoStack.size() == 0) return false; - - Command *cmd = redoStack.top(); - redoStack.pop(); - - undoStack.push(cmd); - cmd->exec(this); - return true; - } - - void clearRedoStack() - { - while (!redoStack.empty()) - { - Command *cmd = redoStack.top(); - redoStack.pop(); - delete cmd; - } - } - - Command *getSetKeyFrameCommand(int track, int row, const sync::Track::KeyFrame &key) - { - sync::Track &t = getTrack(track); - SyncEditData::Command *cmd; - if (t.isKeyFrame(row)) cmd = new EditCommand(track, row, key); - else cmd = new InsertCommand(track, row, key); - return cmd; - } - - SOCKET clientSocket; -// private: - std::map clientRemap; - bool clientPaused; - - std::stack undoStack; - std::stack redoStack; -}; diff --git a/editor/synctracker2.cpp b/editor/synctracker2.cpp index 101bc12..5511925 100644 --- a/editor/synctracker2.cpp +++ b/editor/synctracker2.cpp @@ -234,6 +234,19 @@ static ATOM registerMainWindowClass(HINSTANCE hInstance) return RegisterClassEx(&wc); } +SyncDocument loadDocument() +{ + SyncDocument document; + for (int i = 0; i < 10; ++i) + { + std::string trackName = "balle"; + + // find track + const sync::Track &track = document.getTrack(trackName); + } + return document; +} + int _tmain(int argc, _TCHAR* argv[]) { #ifdef _DEBUG @@ -281,7 +294,7 @@ int _tmain(int argc, _TCHAR* argv[]) } */ #endif - SyncEditData syncData; + SyncDocument syncData; syncData.clientSocket = INVALID_SOCKET; ATOM mainClass = registerMainWindowClass(hInstance); @@ -293,7 +306,7 @@ int _tmain(int argc, _TCHAR* argv[]) } trackView = new TrackView(); - trackView->setSyncData(&syncData); + trackView->setDocument(&syncData); HWND hwnd = CreateWindowEx( 0, @@ -377,7 +390,6 @@ int _tmain(int argc, _TCHAR* argv[]) { size_t clientIndex = 0; int ret = recv(clientSocket, (char*)&clientIndex, sizeof(int), 0); - printf("client index: %d\n", clientIndex); // get len int str_len = 0; @@ -393,7 +405,6 @@ int _tmain(int argc, _TCHAR* argv[]) // find track size_t serverIndex = syncData.getTrackIndex(trackName.c_str()); - printf("name: \"%s\"\n", trackName.c_str()); // setup remap syncData.clientRemap[serverIndex] = clientIndex; diff --git a/editor/trackview.cpp b/editor/trackview.cpp index 3fed9e2..ccfccbe 100644 --- a/editor/trackview.cpp +++ b/editor/trackview.cpp @@ -110,15 +110,15 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks) int firstTrack = min(max(scrollPosX / trackWidth, 0), getTrackCount() - 1); int lastTrack = min(max(firstTrack + windowTracks + 1, 0), getTrackCount() - 1); - sync::Data *syncData = getSyncData(); - if (NULL == syncData) return; + SyncDocument *document = getDocument(); + if (NULL == document) return; SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); - sync::Data::TrackContainer::iterator trackIter = syncData->tracks.begin(); + sync::Data::TrackContainer::iterator trackIter = document->tracks.begin(); for (int track = 0; track <= lastTrack; ++track, ++trackIter) { - assert(trackIter != syncData->tracks.end()); + assert(trackIter != document->tracks.end()); if (track < firstTrack) continue; RECT topMargin; @@ -141,7 +141,7 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks) const std::basic_string &trackName = trackIter->first; - if (this->syncData->clientRemap.count(track) == 0) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); + if (this->document->clientRemap.count(track) == 0) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT)); else SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); TextOut(hdc, fillRect.left, 0, @@ -210,20 +210,17 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks) SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); - sync::Data *syncData = getSyncData(); - if (NULL == syncData) return; - int selectLeft = min(selectStartTrack, selectStopTrack); int selectRight = max(selectStartTrack, selectStopTrack); int selectTop = min(selectStartRow, selectStopRow); int selectBottom = max(selectStartRow, selectStopRow); - sync::Data::TrackContainer::iterator trackIter = syncData->tracks.begin(); + sync::Data::TrackContainer::iterator trackIter = document->tracks.begin(); for (int track = 0; track <= lastTrack; ++track, ++trackIter) { - assert(trackIter != syncData->tracks.end()); + assert(trackIter != document->tracks.end()); size_t trackIndex = trackIter->second; - const sync::Track &t = *syncData->actualTracks[trackIndex]; + const sync::Track &t = *document->actualTracks[trackIndex]; if (track < firstTrack) continue; for (int row = firstRow; row <= lastRow; ++row) @@ -377,7 +374,7 @@ void TrackView::editCopy() for (int track = selectLeft; track <= selectRight; ++track) { int localTrack = track - selectLeft; - const sync::Track &t = syncData->getTrack(track); + const sync::Track &t = document->getTrack(track); for (int row = selectTop; row <= selectBottom; ++row) { int localRow = row - selectTop; @@ -448,17 +445,17 @@ void TrackView::editPaste() { char *src = clipbuf + 2 * sizeof(int) + sizeof(size_t); - SyncEditData::MultiCommand *multiCmd = new SyncEditData::MultiCommand(); + SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand(); for (int i = 0; i < buffer_size; ++i) { struct CopyEntry ce; memcpy(&ce, src, sizeof(CopyEntry)); - SyncEditData::Command *cmd = syncData->getSetKeyFrameCommand(editTrack + ce.track, editRow + ce.row, ce.keyFrame); + SyncDocument::Command *cmd = document->getSetKeyFrameCommand(editTrack + ce.track, editRow + ce.row, ce.keyFrame); multiCmd->addCommand(cmd); src += sizeof(CopyEntry); } - syncData->exec(multiCmd); + document->exec(multiCmd); } GlobalUnlock(hmem); @@ -548,9 +545,9 @@ void TrackView::setEditRow(int newEditRow) selectStartRow = selectStopRow = editRow; selectStartTrack = selectStopTrack = editTrack; } - if (getSyncData()->clientPaused) + if (document->clientPaused) { - getSyncData()->sendSetRowCommand(editRow); + document->sendSetRowCommand(editRow); } } @@ -683,16 +680,16 @@ LRESULT TrackView::onHScroll(UINT sbCode, int /*newPos*/) void TrackView::editEnterValue() { - if (int(editString.size()) > 0 && editTrack < int(syncData->getTrackCount())) + if (int(editString.size()) > 0 && editTrack < int(document->getTrackCount())) { - sync::Track &t = syncData->getTrack(editTrack); + sync::Track &t = document->getTrack(editTrack); sync::Track::KeyFrame newKey; if (t.isKeyFrame(editRow)) newKey = *t.getKeyFrame(editRow); // copy old key newKey.value = float(_tstof(editString.c_str())); // modify value - SyncEditData::Command *cmd = syncData->getSetKeyFrameCommand(editTrack, editRow, newKey); - syncData->exec(cmd); + SyncDocument::Command *cmd = document->getSetKeyFrameCommand(editTrack, editRow, newKey); + document->exec(cmd); editString.clear(); // invalidatePos(editTrack, editRow); @@ -703,9 +700,9 @@ void TrackView::editEnterValue() void TrackView::editToggleInterpolationType() { - if (editTrack < int(syncData->getTrackCount())) + if (editTrack < int(document->getTrackCount())) { - sync::Track &t = syncData->getTrack(editTrack); + sync::Track &t = document->getTrack(editTrack); // find key to modify sync::Track::KeyFrameContainer::const_iterator upper = t.keyFrames.upper_bound(editRow); @@ -731,8 +728,8 @@ void TrackView::editToggleInterpolationType() (int(newKey.interpolationType) + 1) % sync::Track::KeyFrame::IT_COUNT ); - SyncEditData::Command *cmd = syncData->getSetKeyFrameCommand(editTrack, int(lower->first), newKey); - syncData->exec(cmd); + SyncDocument::Command *cmd = document->getSetKeyFrameCommand(editTrack, int(lower->first), newKey); + document->exec(cmd); invalidateRange(editTrack, editTrack, int(lower->first), int(upper->first)); } @@ -746,21 +743,21 @@ void TrackView::editDelete() int selectTop = min(selectStartRow, selectStopRow); int selectBottom = max(selectStartRow, selectStopRow); - if (selectRight >= int(syncData->getTrackCount())) + if (selectRight >= int(document->getTrackCount())) { MessageBeep(0); return; } - SyncEditData::MultiCommand *multiCmd = new SyncEditData::MultiCommand(); + SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand(); for (int track = selectLeft; track <= selectRight; ++track) { - sync::Track &t = syncData->getTrack(track); + sync::Track &t = document->getTrack(track); for (int row = selectTop; row <= selectBottom; ++row) { if (t.isKeyFrame(row)) { - SyncEditData::Command *cmd = new SyncEditData::DeleteCommand(track, row); + SyncDocument::Command *cmd = new SyncDocument::DeleteCommand(track, row); multiCmd->addCommand(cmd); } } @@ -773,7 +770,7 @@ void TrackView::editDelete() } else { - syncData->exec(multiCmd); + document->exec(multiCmd); InvalidateRect(getWin(), NULL, FALSE); // invalidateRange(selectLeft, selectRight, selectTop, selectBottom); } @@ -786,10 +783,10 @@ void TrackView::editBiasValue(float amount) int selectTop = min(selectStartRow, selectStopRow); int selectBottom = max(selectStartRow, selectStopRow); - SyncEditData::MultiCommand *multiCmd = new SyncEditData::MultiCommand(); + SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand(); for (int track = selectLeft; track <= selectRight; ++track) { - sync::Track &t = syncData->getTrack(track); + sync::Track &t = document->getTrack(track); for (int row = selectTop; row <= selectBottom; ++row) { if (t.isKeyFrame(row)) @@ -798,7 +795,7 @@ void TrackView::editBiasValue(float amount) newKey.value += amount; // modify value // add sub-command - SyncEditData::Command *cmd = syncData->getSetKeyFrameCommand(track, row, newKey); + SyncDocument::Command *cmd = document->getSetKeyFrameCommand(track, row, newKey); multiCmd->addCommand(cmd); } } @@ -811,14 +808,14 @@ void TrackView::editBiasValue(float amount) } else { - syncData->exec(multiCmd); + document->exec(multiCmd); invalidateRange(selectLeft, selectRight, selectTop, selectBottom); } } LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/) { - if (editString.empty() && getSyncData()->clientPaused) + if (editString.empty() && document->clientPaused) { switch (keyCode) { @@ -898,7 +895,7 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/) invalidatePos(editTrack, editRow); MessageBeep(0); } - getSyncData()->sendPauseCommand( !getSyncData()->clientPaused ); + document->sendPauseCommand( !document->clientPaused ); break; } return FALSE; @@ -932,7 +929,7 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags) case '7': case '8': case '9': - if (editTrack < int(syncData->getTrackCount())) + if (editTrack < int(document->getTrackCount())) { editString.push_back(char(keyCode)); invalidatePos(editTrack, editRow); @@ -945,7 +942,7 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags) break; case 's': - syncData->sendSaveCommand(); + document->sendSaveCommand(); break; } return FALSE; @@ -995,13 +992,13 @@ LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_UNDO: - if (!syncData->undo()) MessageBeep(0); + if (!document->undo()) MessageBeep(0); // unfortunately, we don't know how much to invalidate... so we'll just invalidate it all. InvalidateRect(hwnd, NULL, FALSE); break; case WM_REDO: - if (!syncData->redo()) MessageBeep(0); + if (!document->redo()) MessageBeep(0); // unfortunately, we don't know how much to invalidate... so we'll just invalidate it all. InvalidateRect(hwnd, NULL, FALSE); break; diff --git a/editor/trackview.h b/editor/trackview.h index fb8f847..d2e5cf7 100644 --- a/editor/trackview.h +++ b/editor/trackview.h @@ -4,7 +4,7 @@ #pragma once -#include "synceditdata.h" +#include "syncdocument.h" #include #include @@ -22,8 +22,8 @@ public: HWND create(HINSTANCE hInstance, HWND hwndParent); HWND getWin(){ return hwnd; } - void setSyncData(SyncEditData *syncData) { this->syncData = syncData; } - SyncEditData *getSyncData() { return syncData; } + void setDocument(SyncDocument *document) { this->document = document; } + SyncDocument *getDocument() { return document; } void setRows(int rows); int getRows() const { return rows; } @@ -115,7 +115,7 @@ private: int getTrackCount() { - sync::Data *syncData = getSyncData(); + sync::Data *syncData = getDocument(); if (NULL == syncData) return 0; return int(syncData->getTrackCount()); }; @@ -136,7 +136,7 @@ private: int windowWidth, windowHeight; int windowRows, windowTracks; - SyncEditData *syncData; + SyncDocument *document; std::basic_string editString;