From 44a2565f5ccb13372cfdb83253f42f7a24e284d9 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 26 Nov 2019 11:19:34 -0600 Subject: [PATCH] InputRoll - refactor MouseDown hack that checks if emulator is paused, better is to recalculate the pointed cell, anytime it may have changed --- .../CustomControls/InputRoll/InputRoll.cs | 66 +++++++++---------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index 7120e9454e..67d8969687 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -704,6 +704,8 @@ namespace BizHawk.Client.EmuHawk _programmaticallyUpdatingScrollBarValues = false; } } + + PointMouseToNewCell(); } } @@ -766,6 +768,8 @@ namespace BizHawk.Client.EmuHawk } while ((lastVisible - value < 0 || lastVisible - value > _lagFrames[VisibleRows - halfRow]) && FirstVisibleRow != 0); } + + PointMouseToNewCell(); } } @@ -910,6 +914,8 @@ namespace BizHawk.Client.EmuHawk } } } + + PointMouseToNewCell(); } /// @@ -972,6 +978,31 @@ namespace BizHawk.Client.EmuHawk private bool _columnDownMoved; private int _previousX; // TODO: move me + // It's necessary to call this anytime the control is programmatically scrolled + // Since the mouse may not be pointing to the same cell anymore + private void PointMouseToNewCell() + { + if (_currentX.HasValue && _currentY.HasValue) + { + var newCell = CalculatePointedCell(_currentX.Value, _currentY.Value); + if (CurrentCell != newCell) + { + if (QueryFrameLag != null && newCell.RowIndex.HasValue) + { + newCell.RowIndex += CountLagFramesDisplay(newCell.RowIndex.Value); + } + + newCell.RowIndex += FirstVisibleRow; + if (newCell.RowIndex < 0) + { + newCell.RowIndex = 0; + } + + CellChanged(newCell); + } + } + } + protected override void OnMouseMove(MouseEventArgs e) { _previousX = _currentX ?? 0; @@ -1058,41 +1089,6 @@ namespace BizHawk.Client.EmuHawk // TODO add query callback of whether to select the cell or not protected override void OnMouseDown(MouseEventArgs e) { - if (!GlobalWin.MainForm.EmulatorPaused && _currentX.HasValue) - { - // TODO: this is copy pasta from OnMouseMove() - Cell newCell = CalculatePointedCell(_currentX.Value, _currentY.Value); - 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); - - if (IsHoveringOnColumnCell || - (WasHoveringOnColumnCell && !IsHoveringOnColumnCell)) - { - Refresh(); - } - else if (_columnDown != null) - { - Refresh(); - } - } - else if (_columnDown != null) - { - Refresh(); - } - } - if (e.Button == MouseButtons.Left) { if (IsHoveringOnColumnEdge)