Partial fix for bug 1896587. Added a fileNew()-function, and made it do some of what it's supposed to do. However, it only clears the part of the document that is within the max-row range. To fix properly, a separate function to clear a track should be added, and all tracks should be iterated through and truncated to 0. Another issue, is that there's no real purgeUnused()-method in SyncDocument yet, and it's a bit tricky to implement (needs to remap properly). But, at least some of this seems to work-ish now.
Also added a menu-hook for fileNew.
This commit is contained in:
parent
24417212ce
commit
eb180b4d15
@ -72,7 +72,7 @@ IDR_MENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "New\tCtrl+N", ID_FILE_NEW40015
|
||||
MENUITEM "New\tCtrl+N", ID_FILE_NEW
|
||||
MENUITEM "&Open\tCtrl+O", ID_FILE_OPEN
|
||||
MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE
|
||||
MENUITEM "Save &As", ID_FILE_SAVE_AS
|
||||
|
||||
@ -17,6 +17,9 @@ size_t SyncDocument::getTrackIndexFromPos(size_t track) const
|
||||
return trackIter->second;
|
||||
}
|
||||
|
||||
/* void SyncDocument::purgeUnused()
|
||||
{
|
||||
} */
|
||||
|
||||
#import <msxml4.dll> named_guids
|
||||
|
||||
|
||||
@ -264,6 +264,8 @@ public:
|
||||
|
||||
size_t getTrackIndexFromPos(size_t track) const;
|
||||
|
||||
/* void purgeUnused(); */
|
||||
|
||||
bool load(const std::string &fileName);
|
||||
bool save(const std::string &fileName);
|
||||
|
||||
|
||||
@ -126,8 +126,14 @@ bool fileNameValid = false;
|
||||
|
||||
void fileNew()
|
||||
{
|
||||
/* document.purgeUnused(); */
|
||||
trackView->selectAll();
|
||||
trackView->editDelete();
|
||||
trackView->selectNone();
|
||||
fileNameValid = false;
|
||||
|
||||
// fileNameValid = false;
|
||||
document.clearUndoStack();
|
||||
document.clearRedoStack();
|
||||
}
|
||||
|
||||
void fileOpen()
|
||||
@ -144,10 +150,13 @@ void fileOpen()
|
||||
ofn.Flags = OFN_SHOWHELP;
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
fileNew();
|
||||
if (document.load(fileName))
|
||||
{
|
||||
document.clearUndoStack();
|
||||
document.clearRedoStack();
|
||||
|
||||
fileNameValid = true;
|
||||
InvalidateRect(trackViewWin, NULL, FALSE);
|
||||
}
|
||||
else MessageBox(trackViewWin, _T("failed to open file"), NULL, MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
|
||||
}
|
||||
@ -239,8 +248,14 @@ static LRESULT CALLBACK mainWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case ID_FILE_NEW:
|
||||
fileNew();
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
break;
|
||||
|
||||
case ID_FILE_OPEN:
|
||||
fileOpen();
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
break;
|
||||
|
||||
case ID_FILE_SAVE_AS:
|
||||
|
||||
@ -747,12 +747,9 @@ void TrackView::editDelete()
|
||||
int selectRight = max(selectStartTrack, selectStopTrack);
|
||||
int selectTop = min(selectStartRow, selectStopRow);
|
||||
int selectBottom = max(selectStartRow, selectStopRow);
|
||||
|
||||
if (selectRight >= int(document->getTrackCount()))
|
||||
{
|
||||
MessageBeep(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == document->getTrackCount()) return;
|
||||
assert(selectRight < int(document->getTrackCount()));
|
||||
|
||||
SyncDocument::MultiCommand *multiCmd = new SyncDocument::MultiCommand();
|
||||
for (int track = selectLeft; track <= selectRight; ++track)
|
||||
|
||||
@ -27,11 +27,38 @@ public:
|
||||
|
||||
void setRows(int rows);
|
||||
int getRows() const { return rows; }
|
||||
|
||||
void editEnterValue();
|
||||
void editDelete();
|
||||
void editCopy();
|
||||
void editCut();
|
||||
void editPaste();
|
||||
void editBiasValue(float amount);
|
||||
void editToggleInterpolationType();
|
||||
|
||||
void setEditRow(int newEditRow);
|
||||
int getEditRow() { return editRow; }
|
||||
|
||||
void selectAll()
|
||||
{
|
||||
selectStartTrack = 0;
|
||||
selectStopTrack = this->getTrackCount() - 1;
|
||||
selectStartRow = 0;
|
||||
selectStopRow = this->getRows() - 1;
|
||||
|
||||
editTrack = 0;
|
||||
editRow = 0;
|
||||
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
void selectNone()
|
||||
{
|
||||
selectStartTrack = selectStopTrack = editTrack;
|
||||
selectStartRow = selectStopRow = editRow;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
private:
|
||||
// some nasty hackery to forward the window messages
|
||||
friend static LRESULT CALLBACK trackViewWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
@ -46,13 +73,6 @@ private:
|
||||
LRESULT onKeyDown(UINT keyCode, UINT flags);
|
||||
LRESULT onChar(UINT keyCode, UINT flags);
|
||||
|
||||
void editEnterValue();
|
||||
void editDelete();
|
||||
void editCopy();
|
||||
void editCut();
|
||||
void editPaste();
|
||||
void editToggleInterpolationType();
|
||||
|
||||
void paintTracks(HDC hdc, RECT rcTracks);
|
||||
void paintTopMargin(HDC hdc, RECT rcTracks);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ namespace sync
|
||||
|
||||
typedef std::map<const std::basic_string<TCHAR>, size_t> TrackContainer;
|
||||
TrackContainer tracks;
|
||||
// protected:
|
||||
protected:
|
||||
std::vector<Track*> actualTracks;
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,31 +40,21 @@ ClientDevice::~ClientDevice()
|
||||
|
||||
Track &ClientDevice::getTrack(const std::string &trackName)
|
||||
{
|
||||
/* const size_t oldCount = syncData.getTrackCount();
|
||||
Track &track = syncData.getTrack(trackName);
|
||||
if (oldCount == syncData.getTrackCount()) return track; */
|
||||
|
||||
sync::Data::TrackContainer::iterator iter = syncData.tracks.find(trackName);
|
||||
if (iter != syncData.tracks.end()) return syncData.getTrack(iter->second);
|
||||
|
||||
// send request data
|
||||
unsigned char cmd = GET_TRACK;
|
||||
send(serverSocket, (char*)&cmd, 1, 0);
|
||||
|
||||
size_t clientIndex = syncData.getTrackCount();
|
||||
send(serverSocket, (char*)&clientIndex, sizeof(size_t), 0);
|
||||
|
||||
// send request data
|
||||
size_t name_len = trackName.size();
|
||||
send(serverSocket, (char*)&name_len, sizeof(size_t), 0);
|
||||
|
||||
const char *name_str = trackName.c_str();
|
||||
send(serverSocket, name_str, int(name_len), 0);
|
||||
|
||||
sync::Track *track = new sync::Track();
|
||||
syncData.actualTracks.push_back(track);
|
||||
syncData.tracks[trackName] = clientIndex;
|
||||
return *track;
|
||||
// return track;
|
||||
// insert new track
|
||||
return syncData.getTrack(trackName);
|
||||
}
|
||||
|
||||
bool ClientDevice::update(float row)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user