parent
a327186b89
commit
29296761a8
@ -1,6 +1,7 @@
|
|||||||
#include "Commands.h"
|
#include "Commands.h"
|
||||||
#include "RemoteConnection.h"
|
#include "RemoteConnection.h"
|
||||||
#include "TrackData.h"
|
#include "TrackData.h"
|
||||||
|
#include "TrackView.h"
|
||||||
#include "../../sync/sync.h"
|
#include "../../sync/sync.h"
|
||||||
#include "../../sync/track.h"
|
#include "../../sync/track.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -282,6 +283,69 @@ void Commands_updateKey(int track, struct track_key* key)
|
|||||||
execCommand(command);
|
execCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
struct ChangeSelectionData
|
||||||
|
{
|
||||||
|
struct TrackViewInfo* viewInfo;
|
||||||
|
struct TrackViewInfo oldViewInfo;
|
||||||
|
|
||||||
|
int selectStartTrack;
|
||||||
|
int selectStopTrack;
|
||||||
|
int selectStartRow;
|
||||||
|
int selectStopRow;
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static void execChangeSelection(void* userData)
|
||||||
|
{
|
||||||
|
struct ChangeSelectionData* data = (struct ChangeSelectionData*)userData;
|
||||||
|
|
||||||
|
data->viewInfo->selectStartTrack = data->selectStartTrack;
|
||||||
|
data->viewInfo->selectStopTrack = data->selectStopTrack;
|
||||||
|
data->viewInfo->selectStartRow = data->selectStartRow;
|
||||||
|
data->viewInfo->selectStopRow = data->selectStopRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static void execUndoSelection(void* userData)
|
||||||
|
{
|
||||||
|
struct ChangeSelectionData* data = (struct ChangeSelectionData*)userData;
|
||||||
|
|
||||||
|
data->viewInfo->selectStartTrack = data->oldViewInfo.selectStartTrack;
|
||||||
|
data->viewInfo->selectStopTrack = data->oldViewInfo.selectStopTrack;
|
||||||
|
data->viewInfo->selectStartRow = data->oldViewInfo.selectStartRow;
|
||||||
|
data->viewInfo->selectStopRow = data->oldViewInfo.selectStopRow;
|
||||||
|
data->viewInfo->rowPos = data->oldViewInfo.rowPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void Commands_setSelection(struct TrackViewInfo* viewInfo, int startTrack, int endTrack, int startRow, int endRow)
|
||||||
|
{
|
||||||
|
struct ChangeSelectionData* data;
|
||||||
|
Command* command;
|
||||||
|
|
||||||
|
command = malloc(sizeof(Command));
|
||||||
|
memset(command, 0, sizeof(Command));
|
||||||
|
|
||||||
|
command->userData = data = malloc(sizeof(struct ChangeSelectionData));
|
||||||
|
command->exec = execChangeSelection;
|
||||||
|
command->undo = execUndoSelection;
|
||||||
|
|
||||||
|
data->viewInfo = viewInfo;
|
||||||
|
data->oldViewInfo = *viewInfo;
|
||||||
|
|
||||||
|
data->selectStartTrack = startTrack;
|
||||||
|
data->selectStopTrack = endTrack;
|
||||||
|
data->selectStartRow = startRow;
|
||||||
|
data->selectStopRow = endRow;
|
||||||
|
|
||||||
|
execCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
struct InsertKeyData
|
struct InsertKeyData
|
||||||
|
|||||||
@ -5,6 +5,7 @@ struct sync_track;
|
|||||||
struct track_key;
|
struct track_key;
|
||||||
struct TrackData;
|
struct TrackData;
|
||||||
struct Track;
|
struct Track;
|
||||||
|
struct TrackViewInfo;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ void Commands_clearBookmarks(struct TrackData* trackData);
|
|||||||
void Commands_toggleLoopmark(struct TrackData* trackData, int row);
|
void Commands_toggleLoopmark(struct TrackData* trackData, int row);
|
||||||
void Commands_clearLoopmarks(struct TrackData* trackData);
|
void Commands_clearLoopmarks(struct TrackData* trackData);
|
||||||
void Commands_updateKey(int track, struct track_key* key);
|
void Commands_updateKey(int track, struct track_key* key);
|
||||||
|
void Commands_setSelection(struct TrackViewInfo* viewInfo, int startTrack, int endTrack, int startRow, int endRow);
|
||||||
void Commands_beginMulti(const char* name); // Used (for example) when changing many value at the same time
|
void Commands_beginMulti(const char* name); // Used (for example) when changing many value at the same time
|
||||||
void Commands_endMulti();
|
void Commands_endMulti();
|
||||||
int Commands_undoCount();
|
int Commands_undoCount();
|
||||||
|
|||||||
@ -1168,6 +1168,7 @@ static void onMoveSelection(bool down)
|
|||||||
int buffer_width, track, row;
|
int buffer_width, track, row;
|
||||||
TrackViewInfo* viewInfo = getTrackViewInfo();
|
TrackViewInfo* viewInfo = getTrackViewInfo();
|
||||||
struct sync_track** tracks = getTracks();
|
struct sync_track** tracks = getTracks();
|
||||||
|
int startTrack, stopTrack, startRow, stopRow;
|
||||||
const int selectLeft = mini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
const int selectLeft = mini(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||||
const int selectRight = maxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
const int selectRight = maxi(viewInfo->selectStartTrack, viewInfo->selectStopTrack);
|
||||||
const int selectTop = mini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
const int selectTop = mini(viewInfo->selectStartRow, viewInfo->selectStopRow);
|
||||||
@ -1190,7 +1191,6 @@ static void onMoveSelection(bool down)
|
|||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
newKey = t->keys[idx];
|
newKey = t->keys[idx];
|
||||||
newKey.row = down ? newKey.row + 1 : newKey.row - 1;
|
newKey.row = down ? newKey.row + 1 : newKey.row - 1;
|
||||||
|
|
||||||
@ -1201,12 +1201,17 @@ static void onMoveSelection(bool down)
|
|||||||
|
|
||||||
buffer_width = (selectRight - selectLeft) + 1;
|
buffer_width = (selectRight - selectLeft) + 1;
|
||||||
|
|
||||||
|
startTrack = viewInfo->selectStartTrack;
|
||||||
|
stopTrack = viewInfo->selectStopTrack;
|
||||||
|
startRow = viewInfo->selectStartRow;
|
||||||
|
stopRow = viewInfo->selectStopRow;
|
||||||
|
|
||||||
// move the selection to the next position
|
// move the selection to the next position
|
||||||
|
|
||||||
if (down)
|
if (down)
|
||||||
{
|
{
|
||||||
viewInfo->selectStartRow++;
|
startRow++;
|
||||||
viewInfo->selectStopRow++;
|
stopRow++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1219,24 +1224,26 @@ static void onMoveSelection(bool down)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
viewInfo->selectStartRow--;
|
startRow--;
|
||||||
viewInfo->selectStopRow--;
|
stopRow--;
|
||||||
|
|
||||||
viewInfo->selectStopRow = maxi(viewInfo->selectStopRow, 0);
|
stopRow = maxi(stopRow, 0);
|
||||||
viewInfo->selectStartRow = maxi(viewInfo->selectStartRow, 0);
|
startRow = maxi(startRow, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewInfo->selectStartRow < viewInfo->selectStopRow)
|
Commands_setSelection(viewInfo, startTrack, stopTrack, startRow, stopRow);
|
||||||
|
|
||||||
|
if (startRow < stopRow)
|
||||||
{
|
{
|
||||||
deleteArea(viewInfo->selectStartRow - 1, selectLeft, buffer_width, 1, true);
|
deleteArea(startRow - 1, selectLeft, buffer_width, 1, true);
|
||||||
setRowPos(viewInfo->selectStartRow);
|
setRowPos(startRow);
|
||||||
deleteArea(viewInfo->selectStopRow + 1, selectLeft, buffer_width, 1, true);
|
deleteArea(stopRow + 1, selectLeft, buffer_width, 1, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
deleteArea(viewInfo->selectStopRow - 1, selectLeft, buffer_width, 1, true);
|
deleteArea(stopRow - 1, selectLeft, buffer_width, 1, true);
|
||||||
setRowPos(viewInfo->selectStopRow);
|
setRowPos(stopRow);
|
||||||
deleteArea(viewInfo->selectStartRow + 1, selectLeft, buffer_width, 1, true);
|
deleteArea(startRow + 1, selectLeft, buffer_width, 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Commands_endMulti();
|
Commands_endMulti();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user