TAStudio: Fixes to how scrolling while painting input works.

This commit is contained in:
Suuper 2015-07-25 19:55:52 -05:00
parent 0963c17206
commit 6ca7080a85
5 changed files with 45 additions and 56 deletions

View File

@ -784,14 +784,14 @@ namespace BizHawk.Client.EmuHawk
}
}
/// <summary>
/// Scrolls to the given index, according to the scroll settings.
/// </summary>
public void ScrollToIndex(int index)
{
if (ScrollMethod == "near" && !IsVisible(index))
if (ScrollMethod == "near")
{
if (FirstVisibleRow > index)
FirstVisibleRow = index;
else
LastVisibleRow = index;
MakeIndexVisible(index);
}
if (!IsVisible(index) || AlwaysScroll)
{
@ -826,6 +826,19 @@ namespace BizHawk.Client.EmuHawk
}
}
}
/// <summary>
/// Scrolls so that the given index is visible, if it isn't already; doesn't use scroll settings.
/// </summary>
public void MakeIndexVisible(int index)
{
if (!IsVisible(index))
{
if (FirstVisibleRow > index)
FirstVisibleRow = index;
else
LastVisibleRow = index;
}
}
[Browsable(false)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Hidden)]
@ -1448,30 +1461,16 @@ namespace BizHawk.Client.EmuHawk
_columnDownMoved = true;
}
if (IsPaintDown)
{
if (HorizontalOrientation)
{
if (e.X <= ColumnWidth)
_currentX = ColumnWidth + 2; // 2 because ColumnWidth/Height isn't correct
else if (e.X > Width)
_currentX = Width;
}
else
{
if (e.Y <= ColumnHeight)
_currentY = ColumnHeight + 2;
else if (e.Y > Height)
_currentX = Height;
}
}
var newCell = CalculatePointedCell(_currentX.Value, _currentY.Value);
Cell newCell = CalculatePointedCell(_currentX.Value, _currentY.Value);
// SuuperW: Hide lag frames
if (QueryFrameLag != null && newCell.RowIndex.HasValue)
{
newCell.RowIndex += CountLagFramesDisplay(newCell.RowIndex.Value);
}
newCell.RowIndex += FirstVisibleRow;
if (newCell.RowIndex < 0)
newCell.RowIndex = 0;
if (!newCell.Equals(CurrentCell))
{
CellChanged(newCell);
@ -2151,10 +2150,7 @@ namespace BizHawk.Client.EmuHawk
{
if (HorizontalOrientation)
{
if (x >= ColumnWidth)
{
newCell.RowIndex = PixelsToRows(x);
}
newCell.RowIndex = PixelsToRows(x);
int colIndex = (y + VBar.Value) / CellHeight;
if (colIndex >= 0 && colIndex < columns.Count)
@ -2164,14 +2160,11 @@ namespace BizHawk.Client.EmuHawk
}
else
{
if (y >= CellHeight)
{
newCell.RowIndex = PixelsToRows(y);
}
newCell.RowIndex = PixelsToRows(y);
newCell.Column = ColumnAtX(x);
}
}
return newCell;
}
@ -2252,11 +2245,12 @@ namespace BizHawk.Client.EmuHawk
/// <returns>A row number between 0 and VisibleRows if it is a Datarow, otherwise a negative number if above all Datarows.</returns>
private int PixelsToRows(int pixels)
{
// Using Math.Floor and float because integer division rounds towards 0 but we want to round down.
if (_horizontalOrientation)
{
return (pixels - ColumnWidth) / CellWidth;
return (int)Math.Floor((float)(pixels - ColumnWidth) / CellWidth);
}
return (pixels - ColumnHeight) / CellHeight;
return (int)Math.Floor((float)(pixels - ColumnHeight) / CellHeight);
}
/// <summary>

View File

@ -35,8 +35,7 @@ namespace BizHawk.Client.EmuHawk
if (AutoadjustInputMenuItem.Checked)
refreshNeeded = AutoAdjustInput();
if (TasPlaybackBox.FollowCursor)
SetVisibleIndex();
MaybeFollowCursor();
if (TasView.IsPartiallyVisible(Global.Emulator.Frame) || TasView.IsPartiallyVisible(lastRefresh))
refreshNeeded = true;
@ -56,10 +55,7 @@ namespace BizHawk.Client.EmuHawk
TasView.RowCount = CurrentTasMovie.InputLogLength + 1;
if (TasPlaybackBox.FollowCursor)
{
SetVisibleIndex();
}
MaybeFollowCursor();
}
public void Restart()

View File

@ -37,7 +37,7 @@ namespace BizHawk.Client.EmuHawk
private bool mouseButtonHeld
{
get
{ // Need a left click
{
return _rightClickFrame != -1 || _leftButtonHeld;
}
}
@ -734,9 +734,9 @@ namespace BizHawk.Client.EmuHawk
}
}
if (Settings.FollowCursor && mouseButtonHeld)
if (Settings.FollowCursor && mouseButtonHeld) // todo; why FollowCursor? Should probably have it's own flag.
{
SetVisibleIndex(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed
TasView.MakeIndexVisible(TasView.CurrentCell.RowIndex.Value); // todo: limit scrolling speed
}
RefreshTasView();
}

View File

@ -801,10 +801,7 @@ namespace BizHawk.Client.EmuHawk
private void HideLagFramesX_Click(object sender, EventArgs e)
{
TasView.LagFramesToHide = (int)(sender as ToolStripMenuItem).Tag;
if (TasPlaybackBox.FollowCursor)
{
SetVisibleIndex();
}
MaybeFollowCursor();
RefreshDialog();
}

View File

@ -37,10 +37,7 @@ namespace BizHawk.Client.EmuHawk
// Get as close as we can then emulate there
StartAtNearestFrameAndEmulate(frame);
if (TasPlaybackBox.FollowCursor)
{
SetVisibleIndex(frame);
}
MaybeFollowCursor();
return;
}
@ -105,16 +102,21 @@ namespace BizHawk.Client.EmuHawk
GoToFrame(marker.Frame);
}
/// <summary>
/// Makes the given frame visible. If no frame is given, makes the current frame visible.
/// </summary>
public void SetVisibleIndex(int? indexThatMustBeVisible = null)
{
if (!indexThatMustBeVisible.HasValue)
{
indexThatMustBeVisible = CurrentTasMovie.IsRecording
? CurrentTasMovie.InputLogLength
: Emulator.Frame;
}
indexThatMustBeVisible = Emulator.Frame;
TasView.ScrollToIndex(indexThatMustBeVisible.Value);
}
private void MaybeFollowCursor()
{
if (TasPlaybackBox.FollowCursor && !TasView.IsPaintDown)
SetVisibleIndex();
}
}
}