Improved encapsulation and const-correctness.
This commit is contained in:
parent
0e0b99e5d0
commit
cef4af984d
@ -26,11 +26,7 @@ bool SyncDocument::load(const std::string &fileName)
|
|||||||
|
|
||||||
// look up track-name, create it if it doesn't exist
|
// look up track-name, create it if it doesn't exist
|
||||||
int trackIndex = getTrackIndex(name);
|
int trackIndex = getTrackIndex(name);
|
||||||
if (0 > trackIndex)
|
if (0 > trackIndex) trackIndex = int(createTrack(name));
|
||||||
{
|
|
||||||
trackIndex = int(createTrack(name));
|
|
||||||
trackOrder.push_back(trackIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
MSXML2::IXMLDOMNodeListPtr rowNodes = trackNode->GetchildNodes();
|
MSXML2::IXMLDOMNodeListPtr rowNodes = trackNode->GetchildNodes();
|
||||||
for (int i = 0; i < rowNodes->Getlength(); ++i)
|
for (int i = 0; i < rowNodes->Getlength(); ++i)
|
||||||
|
|||||||
@ -17,6 +17,13 @@ class SyncDocument : public sync::Data
|
|||||||
public:
|
public:
|
||||||
SyncDocument() : sync::Data(), clientPaused(true) {}
|
SyncDocument() : sync::Data(), clientPaused(true) {}
|
||||||
~SyncDocument();
|
~SyncDocument();
|
||||||
|
|
||||||
|
size_t createTrack(const std::basic_string<TCHAR> &name)
|
||||||
|
{
|
||||||
|
size_t index = sync::Data::createTrack(name);
|
||||||
|
trackOrder.push_back(index);
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
void sendSetKeyCommand(int track, int row, const sync::Track::KeyFrame &key)
|
void sendSetKeyCommand(int track, int row, const sync::Track::KeyFrame &key)
|
||||||
{
|
{
|
||||||
@ -266,12 +273,24 @@ public:
|
|||||||
else cmd = new InsertCommand(track, row, key);
|
else cmd = new InsertCommand(track, row, key);
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t getTrackOrderCount() const
|
||||||
|
{
|
||||||
|
return trackOrder.size();
|
||||||
|
}
|
||||||
|
|
||||||
size_t getTrackIndexFromPos(size_t track) const
|
size_t getTrackIndexFromPos(size_t track) const
|
||||||
{
|
{
|
||||||
assert(track < trackOrder.size());
|
assert(track < trackOrder.size());
|
||||||
return trackOrder[track];
|
return trackOrder[track];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swapTrackOrder(size_t t1, size_t t2)
|
||||||
|
{
|
||||||
|
assert(t1 < trackOrder.size());
|
||||||
|
assert(t2 < trackOrder.size());
|
||||||
|
std::swap(trackOrder[t1], trackOrder[t2]);
|
||||||
|
}
|
||||||
|
|
||||||
bool load(const std::string &fileName);
|
bool load(const std::string &fileName);
|
||||||
bool save(const std::string &fileName);
|
bool save(const std::string &fileName);
|
||||||
@ -280,9 +299,8 @@ public:
|
|||||||
std::map<size_t, size_t> clientRemap;
|
std::map<size_t, size_t> clientRemap;
|
||||||
bool clientPaused;
|
bool clientPaused;
|
||||||
|
|
||||||
std::vector<size_t> trackOrder;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::vector<size_t> trackOrder;
|
||||||
std::stack<Command*> undoStack;
|
std::stack<Command*> undoStack;
|
||||||
std::stack<Command*> redoStack;
|
std::stack<Command*> redoStack;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -533,7 +533,6 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
#if 0
|
#if 0
|
||||||
{
|
{
|
||||||
DWORD test = 0xdeadbeef;
|
DWORD test = 0xdeadbeef;
|
||||||
setRegString(key, "test", "hallaballa!");
|
|
||||||
RegSetValueEx(key, "test2", 0, REG_DWORD, (BYTE *)&test, sizeof(DWORD));
|
RegSetValueEx(key, "test2", 0, REG_DWORD, (BYTE *)&test, sizeof(DWORD));
|
||||||
|
|
||||||
DWORD type = 0;
|
DWORD type = 0;
|
||||||
@ -542,10 +541,6 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
RegQueryValueEx(key, "test2", 0, &type, (LPBYTE)&test2, &size);
|
RegQueryValueEx(key, "test2", 0, &type, (LPBYTE)&test2, &size);
|
||||||
assert(REG_DWORD == type);
|
assert(REG_DWORD == type);
|
||||||
printf("%x\n", test2);
|
printf("%x\n", test2);
|
||||||
|
|
||||||
std::string string;
|
|
||||||
if (getRegString(key, "test", string))
|
|
||||||
printf("\"%s\"\n", string.c_str());
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -673,11 +668,7 @@ int _tmain(int argc, _TCHAR* argv[])
|
|||||||
|
|
||||||
// find track
|
// find track
|
||||||
int serverIndex = document.getTrackIndex(trackName);
|
int serverIndex = document.getTrackIndex(trackName);
|
||||||
if (0 > serverIndex)
|
if (0 > serverIndex) serverIndex = int(document.createTrack(trackName));
|
||||||
{
|
|
||||||
serverIndex = int(document.createTrack(trackName));
|
|
||||||
document.trackOrder.push_back(serverIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup remap
|
// setup remap
|
||||||
document.clientRemap[serverIndex] = clientIndex;
|
document.clientRemap[serverIndex] = clientIndex;
|
||||||
|
|||||||
@ -112,6 +112,9 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
{
|
{
|
||||||
RECT fillRect;
|
RECT fillRect;
|
||||||
RECT topLeftMargin;
|
RECT topLeftMargin;
|
||||||
|
const SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
topLeftMargin.top = 0;
|
topLeftMargin.top = 0;
|
||||||
topLeftMargin.bottom = topMarginHeight;
|
topLeftMargin.bottom = topMarginHeight;
|
||||||
topLeftMargin.left = 0;
|
topLeftMargin.left = 0;
|
||||||
@ -121,13 +124,14 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
FillRect(hdc, &fillRect, GetSysColorBrush(COLOR_3DFACE));
|
FillRect(hdc, &fillRect, GetSysColorBrush(COLOR_3DFACE));
|
||||||
|
|
||||||
int startTrack = scrollPosX / trackWidth;
|
int startTrack = scrollPosX / trackWidth;
|
||||||
int endTrack = min(startTrack + windowTracks + 1, getTrackCount());
|
int endTrack = min(startTrack + windowTracks + 1, int(getTrackCount()));
|
||||||
|
|
||||||
SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
||||||
|
|
||||||
for (int track = startTrack; track < endTrack; ++track)
|
for (int track = startTrack; track < endTrack; ++track)
|
||||||
{
|
{
|
||||||
sync::Track &t = document->getTrack(document->getTrackIndexFromPos(track));
|
size_t index = doc->getTrackIndexFromPos(track);
|
||||||
|
const sync::Track &t = doc->getTrack(index);
|
||||||
|
|
||||||
RECT topMargin;
|
RECT topMargin;
|
||||||
|
|
||||||
@ -149,7 +153,7 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
|
|
||||||
const std::basic_string<TCHAR> &trackName = t.getName();
|
const std::basic_string<TCHAR> &trackName = t.getName();
|
||||||
|
|
||||||
if (this->document->clientRemap.count(document->getTrackIndexFromPos(track)) == 0) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
|
if (doc->clientRemap.count(doc->getTrackIndexFromPos(track)) == 0) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
|
||||||
else SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
else SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
|
||||||
TextOut(hdc,
|
TextOut(hdc,
|
||||||
fillRect.left, 0,
|
fillRect.left, 0,
|
||||||
@ -172,6 +176,9 @@ void TrackView::paintTopMargin(HDC hdc, RECT rcTracks)
|
|||||||
|
|
||||||
void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
||||||
{
|
{
|
||||||
|
const SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
TCHAR temp[256];
|
TCHAR temp[256];
|
||||||
|
|
||||||
int firstRow = editRow - windowRows / 2 - 1;
|
int firstRow = editRow - windowRows / 2 - 1;
|
||||||
@ -221,11 +228,11 @@ void TrackView::paintTracks(HDC hdc, RECT rcTracks)
|
|||||||
int selectBottom = max(selectStartRow, selectStopRow);
|
int selectBottom = max(selectStartRow, selectStopRow);
|
||||||
|
|
||||||
int startTrack = scrollPosX / trackWidth;
|
int startTrack = scrollPosX / trackWidth;
|
||||||
int endTrack = min(startTrack + windowTracks + 1, getTrackCount());
|
int endTrack = min(startTrack + windowTracks + 1, int(getTrackCount()));
|
||||||
|
|
||||||
for (int track = startTrack; track < endTrack; ++track)
|
for (int track = startTrack; track < endTrack; ++track)
|
||||||
{
|
{
|
||||||
const sync::Track &t = document->getTrack(document->getTrackIndexFromPos(track));
|
const sync::Track &t = doc->getTrack(doc->getTrackIndexFromPos(track));
|
||||||
|
|
||||||
for (int row = firstRow; row <= lastRow; ++row)
|
for (int row = firstRow; row <= lastRow; ++row)
|
||||||
{
|
{
|
||||||
@ -357,7 +364,10 @@ struct CopyEntry
|
|||||||
|
|
||||||
void TrackView::editCopy()
|
void TrackView::editCopy()
|
||||||
{
|
{
|
||||||
if (0 == document->getTrackCount())
|
const SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
|
if (0 == getTrackCount())
|
||||||
{
|
{
|
||||||
MessageBeep(-1);
|
MessageBeep(-1);
|
||||||
return;
|
return;
|
||||||
@ -382,8 +392,8 @@ void TrackView::editCopy()
|
|||||||
std::vector<struct CopyEntry> copyEntries;
|
std::vector<struct CopyEntry> copyEntries;
|
||||||
for (int track = selectLeft; track <= selectRight; ++track)
|
for (int track = selectLeft; track <= selectRight; ++track)
|
||||||
{
|
{
|
||||||
const size_t trackIndex = document->getTrackIndexFromPos(track);
|
const size_t trackIndex = doc->getTrackIndexFromPos(track);
|
||||||
const sync::Track &t = document->getTrack(trackIndex);
|
const sync::Track &t = doc->getTrack(trackIndex);
|
||||||
|
|
||||||
for (int row = selectTop; row <= selectBottom; ++row)
|
for (int row = selectTop; row <= selectBottom; ++row)
|
||||||
{
|
{
|
||||||
@ -427,7 +437,7 @@ void TrackView::editCopy()
|
|||||||
|
|
||||||
void TrackView::editCut()
|
void TrackView::editCut()
|
||||||
{
|
{
|
||||||
if (0 == document->getTrackCount())
|
if (0 == getTrackCount())
|
||||||
{
|
{
|
||||||
MessageBeep(-1);
|
MessageBeep(-1);
|
||||||
return;
|
return;
|
||||||
@ -439,7 +449,10 @@ void TrackView::editCut()
|
|||||||
|
|
||||||
void TrackView::editPaste()
|
void TrackView::editPaste()
|
||||||
{
|
{
|
||||||
if (0 == document->getTrackCount())
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
|
if (0 == getTrackCount())
|
||||||
{
|
{
|
||||||
MessageBeep(-1);
|
MessageBeep(-1);
|
||||||
return;
|
return;
|
||||||
@ -474,14 +487,14 @@ void TrackView::editPaste()
|
|||||||
src += sizeof(CopyEntry);
|
src += sizeof(CopyEntry);
|
||||||
|
|
||||||
size_t trackPos = editTrack + ce.track;
|
size_t trackPos = editTrack + ce.track;
|
||||||
if (trackPos < document->getTrackCount())
|
if (trackPos < getTrackCount())
|
||||||
{
|
{
|
||||||
size_t trackIndex = document->getTrackIndexFromPos(trackPos);
|
size_t trackIndex = doc->getTrackIndexFromPos(trackPos);
|
||||||
SyncDocument::Command *cmd = document->getSetKeyFrameCommand(int(trackIndex), editRow + ce.row, ce.keyFrame);
|
SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), editRow + ce.row, ce.keyFrame);
|
||||||
multiCmd->addCommand(cmd);
|
multiCmd->addCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document->exec(multiCmd);
|
doc->exec(multiCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalUnlock(hmem);
|
GlobalUnlock(hmem);
|
||||||
@ -551,6 +564,9 @@ void TrackView::setScrollPos(int newScrollPosX, int newScrollPosY)
|
|||||||
|
|
||||||
void TrackView::setEditRow(int newEditRow)
|
void TrackView::setEditRow(int newEditRow)
|
||||||
{
|
{
|
||||||
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
int oldEditRow = editRow;
|
int oldEditRow = editRow;
|
||||||
editRow = newEditRow;
|
editRow = newEditRow;
|
||||||
|
|
||||||
@ -570,9 +586,9 @@ void TrackView::setEditRow(int newEditRow)
|
|||||||
selectStartRow = selectStopRow = editRow;
|
selectStartRow = selectStopRow = editRow;
|
||||||
selectStartTrack = selectStopTrack = editTrack;
|
selectStartTrack = selectStopTrack = editTrack;
|
||||||
}
|
}
|
||||||
if (document->clientPaused)
|
if (doc->clientPaused)
|
||||||
{
|
{
|
||||||
document->sendSetRowCommand(editRow);
|
doc->sendSetRowCommand(editRow);
|
||||||
}
|
}
|
||||||
SendMessage(GetParent(getWin()), WM_ROWCHANGED, 0, editRow);
|
SendMessage(GetParent(getWin()), WM_ROWCHANGED, 0, editRow);
|
||||||
SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
|
SendMessage(GetParent(getWin()), WM_CURRVALDIRTY, 0, 0);
|
||||||
@ -586,14 +602,14 @@ void TrackView::setEditRow(int newEditRow)
|
|||||||
|
|
||||||
void TrackView::setEditTrack(int newEditTrack)
|
void TrackView::setEditTrack(int newEditTrack)
|
||||||
{
|
{
|
||||||
assert(size_t(newEditTrack) < document->getTrackCount());
|
assert(size_t(newEditTrack) < getTrackCount());
|
||||||
|
|
||||||
int oldEditTrack = editTrack;
|
int oldEditTrack = editTrack;
|
||||||
editTrack = newEditTrack;
|
editTrack = newEditTrack;
|
||||||
|
|
||||||
// clamp to document
|
// clamp to document
|
||||||
editTrack = max(editTrack, 0);
|
editTrack = max(editTrack, 0);
|
||||||
editTrack = min(editTrack, getTrackCount() - 1);
|
editTrack = min(editTrack, int(getTrackCount()) - 1);
|
||||||
|
|
||||||
if (oldEditTrack != editTrack)
|
if (oldEditTrack != editTrack)
|
||||||
{
|
{
|
||||||
@ -711,17 +727,20 @@ LRESULT TrackView::onHScroll(UINT sbCode, int /*newPos*/)
|
|||||||
|
|
||||||
void TrackView::editEnterValue()
|
void TrackView::editEnterValue()
|
||||||
{
|
{
|
||||||
if (int(editString.size()) > 0 && editTrack < int(document->getTrackCount()))
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
|
if (int(editString.size()) > 0 && editTrack < int(getTrackCount()))
|
||||||
{
|
{
|
||||||
size_t trackIndex = document->getTrackIndexFromPos(editTrack);
|
size_t trackIndex = doc->getTrackIndexFromPos(editTrack);
|
||||||
sync::Track &t = document->getTrack(trackIndex);
|
sync::Track &t = doc->getTrack(trackIndex);
|
||||||
|
|
||||||
sync::Track::KeyFrame newKey;
|
sync::Track::KeyFrame newKey;
|
||||||
if (t.isKeyFrame(editRow)) newKey = *t.getKeyFrame(editRow); // copy old key
|
if (t.isKeyFrame(editRow)) newKey = *t.getKeyFrame(editRow); // copy old key
|
||||||
newKey.value = float(_tstof(editString.c_str())); // modify value
|
newKey.value = float(_tstof(editString.c_str())); // modify value
|
||||||
|
|
||||||
SyncDocument::Command *cmd = document->getSetKeyFrameCommand(int(trackIndex), editRow, newKey);
|
SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), editRow, newKey);
|
||||||
document->exec(cmd);
|
doc->exec(cmd);
|
||||||
|
|
||||||
editString.clear();
|
editString.clear();
|
||||||
// invalidatePos(editTrack, editRow);
|
// invalidatePos(editTrack, editRow);
|
||||||
@ -732,10 +751,13 @@ void TrackView::editEnterValue()
|
|||||||
|
|
||||||
void TrackView::editToggleInterpolationType()
|
void TrackView::editToggleInterpolationType()
|
||||||
{
|
{
|
||||||
if (editTrack < int(document->getTrackCount()))
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
|
if (editTrack < int(getTrackCount()))
|
||||||
{
|
{
|
||||||
size_t trackIndex = document->getTrackIndexFromPos(editTrack);
|
size_t trackIndex = doc->getTrackIndexFromPos(editTrack);
|
||||||
sync::Track &t = document->getTrack(trackIndex);
|
sync::Track &t = doc->getTrack(trackIndex);
|
||||||
|
|
||||||
// find key to modify
|
// find key to modify
|
||||||
sync::Track::KeyFrameContainer::const_iterator upper = t.keyFrames.upper_bound(editRow);
|
sync::Track::KeyFrameContainer::const_iterator upper = t.keyFrames.upper_bound(editRow);
|
||||||
@ -761,8 +783,8 @@ void TrackView::editToggleInterpolationType()
|
|||||||
(int(newKey.interpolationType) + 1) % sync::Track::KeyFrame::IT_COUNT
|
(int(newKey.interpolationType) + 1) % sync::Track::KeyFrame::IT_COUNT
|
||||||
);
|
);
|
||||||
|
|
||||||
SyncDocument::Command *cmd = document->getSetKeyFrameCommand(int(trackIndex), int(lower->first), newKey);
|
SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), int(lower->first), newKey);
|
||||||
document->exec(cmd);
|
doc->exec(cmd);
|
||||||
|
|
||||||
invalidateRange(editTrack, editTrack, int(lower->first), int(upper->first));
|
invalidateRange(editTrack, editTrack, int(lower->first), int(upper->first));
|
||||||
}
|
}
|
||||||
@ -771,19 +793,22 @@ void TrackView::editToggleInterpolationType()
|
|||||||
|
|
||||||
void TrackView::editDelete()
|
void TrackView::editDelete()
|
||||||
{
|
{
|
||||||
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
int selectLeft = min(selectStartTrack, selectStopTrack);
|
int selectLeft = min(selectStartTrack, selectStopTrack);
|
||||||
int selectRight = max(selectStartTrack, selectStopTrack);
|
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||||
int selectTop = min(selectStartRow, selectStopRow);
|
int selectTop = min(selectStartRow, selectStopRow);
|
||||||
int selectBottom = max(selectStartRow, selectStopRow);
|
int selectBottom = max(selectStartRow, selectStopRow);
|
||||||
|
|
||||||
if (0 == document->getTrackCount()) return;
|
if (0 == getTrackCount()) return;
|
||||||
assert(selectRight < int(document->getTrackCount()));
|
assert(selectRight < int(getTrackCount()));
|
||||||
|
|
||||||
SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
|
SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
|
||||||
for (int track = selectLeft; track <= selectRight; ++track)
|
for (int track = selectLeft; track <= selectRight; ++track)
|
||||||
{
|
{
|
||||||
size_t trackIndex = document->getTrackIndexFromPos(track);
|
size_t trackIndex = doc->getTrackIndexFromPos(track);
|
||||||
sync::Track &t = document->getTrack(trackIndex);
|
sync::Track &t = doc->getTrack(trackIndex);
|
||||||
|
|
||||||
for (int row = selectTop; row <= selectBottom; ++row)
|
for (int row = selectTop; row <= selectBottom; ++row)
|
||||||
{
|
{
|
||||||
@ -802,7 +827,7 @@ void TrackView::editDelete()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document->exec(multiCmd);
|
doc->exec(multiCmd);
|
||||||
InvalidateRect(getWin(), NULL, FALSE);
|
InvalidateRect(getWin(), NULL, FALSE);
|
||||||
// invalidateRange(selectLeft, selectRight, selectTop, selectBottom);
|
// invalidateRange(selectLeft, selectRight, selectTop, selectBottom);
|
||||||
}
|
}
|
||||||
@ -810,12 +835,15 @@ void TrackView::editDelete()
|
|||||||
|
|
||||||
void TrackView::editBiasValue(float amount)
|
void TrackView::editBiasValue(float amount)
|
||||||
{
|
{
|
||||||
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return;
|
||||||
|
|
||||||
int selectLeft = min(selectStartTrack, selectStopTrack);
|
int selectLeft = min(selectStartTrack, selectStopTrack);
|
||||||
int selectRight = max(selectStartTrack, selectStopTrack);
|
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||||
int selectTop = min(selectStartRow, selectStopRow);
|
int selectTop = min(selectStartRow, selectStopRow);
|
||||||
int selectBottom = max(selectStartRow, selectStopRow);
|
int selectBottom = max(selectStartRow, selectStopRow);
|
||||||
|
|
||||||
if (0 == document->getTrackCount())
|
if (0 == getTrackCount())
|
||||||
{
|
{
|
||||||
MessageBeep(-1);
|
MessageBeep(-1);
|
||||||
return;
|
return;
|
||||||
@ -824,9 +852,9 @@ void TrackView::editBiasValue(float amount)
|
|||||||
SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
|
SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
|
||||||
for (int track = selectLeft; track <= selectRight; ++track)
|
for (int track = selectLeft; track <= selectRight; ++track)
|
||||||
{
|
{
|
||||||
assert(track < int(document->getTrackCount()));
|
assert(track < int(getTrackCount()));
|
||||||
size_t trackIndex = document->getTrackIndexFromPos(track);
|
size_t trackIndex = doc->getTrackIndexFromPos(track);
|
||||||
sync::Track &t = document->getTrack(trackIndex);
|
sync::Track &t = doc->getTrack(trackIndex);
|
||||||
|
|
||||||
for (int row = selectTop; row <= selectBottom; ++row)
|
for (int row = selectTop; row <= selectBottom; ++row)
|
||||||
{
|
{
|
||||||
@ -836,7 +864,7 @@ void TrackView::editBiasValue(float amount)
|
|||||||
newKey.value += amount; // modify value
|
newKey.value += amount; // modify value
|
||||||
|
|
||||||
// add sub-command
|
// add sub-command
|
||||||
SyncDocument::Command *cmd = document->getSetKeyFrameCommand(int(trackIndex), row, newKey);
|
SyncDocument::Command *cmd = doc->getSetKeyFrameCommand(int(trackIndex), row, newKey);
|
||||||
multiCmd->addCommand(cmd);
|
multiCmd->addCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -849,13 +877,16 @@ void TrackView::editBiasValue(float amount)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
document->exec(multiCmd);
|
doc->exec(multiCmd);
|
||||||
invalidateRange(selectLeft, selectRight, selectTop, selectBottom);
|
invalidateRange(selectLeft, selectRight, selectTop, selectBottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
||||||
{
|
{
|
||||||
|
SyncDocument *doc = getDocument();
|
||||||
|
if (NULL == doc) return FALSE;
|
||||||
|
|
||||||
if (!editString.empty())
|
if (!editString.empty())
|
||||||
{
|
{
|
||||||
switch(keyCode)
|
switch(keyCode)
|
||||||
@ -871,7 +902,8 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
|||||||
editEnterValue();
|
editEnterValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (editString.empty() && document->clientPaused)
|
|
||||||
|
if (editString.empty() && doc->clientPaused)
|
||||||
{
|
{
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
@ -880,7 +912,7 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
|||||||
{
|
{
|
||||||
float bias = 1.0f;
|
float bias = 1.0f;
|
||||||
if (GetKeyState(VK_SHIFT) < 0) bias = 0.1f;
|
if (GetKeyState(VK_SHIFT) < 0) bias = 0.1f;
|
||||||
if (int(document->trackOrder.size()) > editTrack) editBiasValue(bias);
|
if (int(getTrackCount()) > editTrack) editBiasValue(bias);
|
||||||
else MessageBeep(-1);
|
else MessageBeep(-1);
|
||||||
}
|
}
|
||||||
else setEditRow(editRow - 1);
|
else setEditRow(editRow - 1);
|
||||||
@ -891,7 +923,7 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
|||||||
{
|
{
|
||||||
float bias = 1.0f;
|
float bias = 1.0f;
|
||||||
if (GetKeyState(VK_SHIFT) < 0) bias = 0.1f;
|
if (GetKeyState(VK_SHIFT) < 0) bias = 0.1f;
|
||||||
if (int(document->trackOrder.size()) > editTrack) editBiasValue(-bias);
|
if (int(getTrackCount()) > editTrack) editBiasValue(-bias);
|
||||||
else MessageBeep(-1);
|
else MessageBeep(-1);
|
||||||
}
|
}
|
||||||
else setEditRow(editRow + 1);
|
else setEditRow(editRow + 1);
|
||||||
@ -900,20 +932,20 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
|||||||
case VK_LEFT:
|
case VK_LEFT:
|
||||||
if (GetKeyState(VK_CONTROL) < 0)
|
if (GetKeyState(VK_CONTROL) < 0)
|
||||||
{
|
{
|
||||||
if (0 < editTrack) std::swap(document->trackOrder[editTrack], document->trackOrder[editTrack - 1]);
|
if (0 < editTrack) doc->swapTrackOrder(editTrack, editTrack - 1);
|
||||||
else MessageBeep(-1);
|
else MessageBeep(-1);
|
||||||
}
|
}
|
||||||
if (0 != document->getTrackCount()) setEditTrack(editTrack - 1);
|
if (0 != getTrackCount()) setEditTrack(editTrack - 1);
|
||||||
else MessageBeep(-1);
|
else MessageBeep(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VK_RIGHT:
|
case VK_RIGHT:
|
||||||
if (GetKeyState(VK_CONTROL) < 0)
|
if (GetKeyState(VK_CONTROL) < 0)
|
||||||
{
|
{
|
||||||
if (int(document->trackOrder.size()) > editTrack + 1) std::swap(document->trackOrder[editTrack], document->trackOrder[editTrack + 1]);
|
if (int(getTrackCount()) > editTrack + 1) doc->swapTrackOrder(editTrack, editTrack + 1);
|
||||||
else MessageBeep(-1);
|
else MessageBeep(-1);
|
||||||
}
|
}
|
||||||
if (0 != document->getTrackCount()) setEditTrack(editTrack + 1);
|
if (0 != getTrackCount()) setEditTrack(editTrack + 1);
|
||||||
else MessageBeep(-1);
|
else MessageBeep(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1008,7 +1040,7 @@ LRESULT TrackView::onKeyDown(UINT keyCode, UINT /*flags*/)
|
|||||||
invalidatePos(editTrack, editRow);
|
invalidatePos(editTrack, editRow);
|
||||||
MessageBeep(-1);
|
MessageBeep(-1);
|
||||||
}
|
}
|
||||||
document->sendPauseCommand( !document->clientPaused );
|
doc->sendPauseCommand( !doc->clientPaused );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1042,7 +1074,7 @@ LRESULT TrackView::onChar(UINT keyCode, UINT flags)
|
|||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
if (editTrack < int(document->getTrackCount()))
|
if (editTrack < int(getTrackCount()))
|
||||||
{
|
{
|
||||||
editString.push_back(char(keyCode));
|
editString.push_back(char(keyCode));
|
||||||
invalidatePos(editTrack, editRow);
|
invalidatePos(editTrack, editRow);
|
||||||
@ -1101,13 +1133,15 @@ LRESULT TrackView::windowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_UNDO:
|
case WM_UNDO:
|
||||||
if (!document->undo()) MessageBeep(-1);
|
if (NULL == getDocument()) return FALSE;
|
||||||
|
if (!getDocument()->undo()) MessageBeep(-1);
|
||||||
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
InvalidateRect(hwnd, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_REDO:
|
case WM_REDO:
|
||||||
if (!document->redo()) MessageBeep(-1);
|
if (NULL == getDocument()) return FALSE;
|
||||||
|
if (!getDocument()->redo()) MessageBeep(-1);
|
||||||
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
// unfortunately, we don't know how much to invalidate... so we'll just invalidate it all.
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
InvalidateRect(hwnd, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ public:
|
|||||||
HWND getWin(){ return hwnd; }
|
HWND getWin(){ return hwnd; }
|
||||||
|
|
||||||
void setDocument(SyncDocument *document) { this->document = document; }
|
void setDocument(SyncDocument *document) { this->document = document; }
|
||||||
|
const SyncDocument *getDocument() const { return document; }
|
||||||
SyncDocument *getDocument() { return document; }
|
SyncDocument *getDocument() { return document; }
|
||||||
|
|
||||||
void setRows(int rows);
|
void setRows(int rows);
|
||||||
@ -134,11 +135,11 @@ private:
|
|||||||
int getScreenY(int row);
|
int getScreenY(int row);
|
||||||
int getScreenX(int track);
|
int getScreenX(int track);
|
||||||
|
|
||||||
int getTrackCount()
|
size_t getTrackCount() const
|
||||||
{
|
{
|
||||||
sync::Data *syncData = getDocument();
|
const SyncDocument *doc = getDocument();
|
||||||
if (NULL == syncData) return 0;
|
if (NULL == doc) return 0;
|
||||||
return int(syncData->getTrackCount());
|
return int(doc->getTrackOrderCount());
|
||||||
};
|
};
|
||||||
|
|
||||||
int selectStartTrack, selectStopTrack;
|
int selectStartTrack, selectStopTrack;
|
||||||
|
|||||||
10
sync/data.h
10
sync/data.h
@ -40,7 +40,15 @@ namespace sync
|
|||||||
assert(NULL != tracks[track]);
|
assert(NULL != tracks[track]);
|
||||||
return *tracks[track];
|
return *tracks[track];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Track &
|
||||||
|
getTrack(size_t track) const
|
||||||
|
{
|
||||||
|
assert(track < tracks.size());
|
||||||
|
assert(NULL != tracks[track]);
|
||||||
|
return *tracks[track];
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
getTrackCount() const
|
getTrackCount() const
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user