Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class TAStudio
private int _axisPaintState;
private bool _patternPaint;
private bool _startCursorDrag;
private bool _startSelectionDrag;
private int _startSelectionDrag = -1;
private bool _selectionDragState;
private bool _suppressContextMenu;
private int _startRow;
Expand Down Expand Up @@ -828,7 +828,7 @@ private void TasView_MouseDown(object sender, MouseEventArgs e)
}
else
{
_startSelectionDrag = true;
_startSelectionDrag = frame;
_selectionDragState = roll.IsRowSelected(frame);
}
}
Expand Down Expand Up @@ -1124,7 +1124,7 @@ private void ClearLeftMouseStates()
{
_leftButtonHeld = false;
_startCursorDrag = false;
_startSelectionDrag = false;
_startSelectionDrag = -1;
_startBoolDrawColumn = "";
_startAxisDrawColumn = "";

Expand Down Expand Up @@ -1314,12 +1314,30 @@ private void TasView_PointedCellChanged(object sender, InputRoll.CellEventArgs e
{
GoToFrame(e.NewCell.RowIndex.Value);
}
else if (_startSelectionDrag)
else if (_startSelectionDrag != -1)
{
for (var i = startVal; i <= endVal; i++)
void selectRange(int a, int b, bool v)
{
if (!roll.IsRowSelected(i))
roll.SelectRow(i, _selectionDragState);
if (a < b) for (int i = a; i <= b; i++) roll.SelectRow(i, v);
else for (int i = b; i <= a; i++) roll.SelectRow(i, v);
}
int rawStart = e.OldCell.RowIndex.Value;
int rawEnd = e.NewCell.RowIndex.Value;
int sign = Math.Sign(rawEnd - rawStart);
int startDiff = rawStart - _startSelectionDrag;
int endDiff = rawEnd - _startSelectionDrag;
if (Math.Sign(startDiff) == Math.Sign(endDiff))
{
// select if moving away from start, deselect if moving towards
bool movingAway = Math.Abs(endDiff) > Math.Abs(startDiff);
if (movingAway) selectRange(rawStart + sign, rawEnd, _selectionDragState);
else selectRange(rawStart, rawEnd - sign, !_selectionDragState);
}
else
{
// crossing from one side of selection start to the other
if (rawStart != _startSelectionDrag) selectRange(rawStart, _startSelectionDrag - sign, !_selectionDragState);
if (rawEnd != _startSelectionDrag) selectRange(_startSelectionDrag + sign, rawEnd, _selectionDragState);
}

SetSplicer();
Expand Down
Loading