From cb575d36b4a9bf816834d7eaeec602bda51cdaf5 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 11 Jul 2020 13:49:00 -0500 Subject: [PATCH] add an option to InputRoll for "Selection when paging", as a bit of a hack to revert Tastudio back to its old PgUp/Dn behavior, while still keeping the current behavior for other input roll usages (as it makes more sense for traditional listview behavior). Fixes #2074 --- .../CustomControls/InputRoll/InputRoll.cs | 62 +++++++++++++------ .../tools/TAStudio/TAStudio.Designer.cs | 1 + 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index 0f8e3ebb40..71367af1b5 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -376,6 +376,14 @@ namespace BizHawk.Client.EmuHawk [Category("Behavior")] public int SeekingCutoffInterval { get; set; } + /// + /// Gets or sets a value indicating whether pressing page up/down will cause + /// the current selection to change + /// + [DefaultValue(false)] + [Category("Behavior")] + public bool ChangeSelectionWhenPaging { get; set; } = true; + /// /// Returns all columns including those that are not visible /// @@ -1352,33 +1360,47 @@ namespace BizHawk.Client.EmuHawk // Scroll else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageUp) // Page Up { - var selectedRow = SelectedRows.Any() ? SelectedRows.First() : FirstVisibleRow; - var increment = LastVisibleRow - FirstVisibleRow; - var newSelectedRow = selectedRow - increment; - if (newSelectedRow < 0) + if (ChangeSelectionWhenPaging) { - newSelectedRow = 0; - } + var selectedRow = SelectedRows.Any() ? SelectedRows.First() : FirstVisibleRow; + var increment = LastVisibleRow - FirstVisibleRow; + var newSelectedRow = selectedRow - increment; + if (newSelectedRow < 0) + { + newSelectedRow = 0; + } - FirstVisibleRow = newSelectedRow; - DeselectAll(); - SelectRow(newSelectedRow, true); - Refresh(); + FirstVisibleRow = newSelectedRow; + DeselectAll(); + SelectRow(newSelectedRow, true); + Refresh(); + } + else if (FirstVisibleRow > 0) + { + LastVisibleRow = FirstVisibleRow; + } } else if (!e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.PageDown) // Page Down { - var selectedRow = SelectedRows.Any() ? SelectedRows.First() : FirstVisibleRow; - var increment = LastVisibleRow - FirstVisibleRow; - var newSelectedRow = selectedRow + increment; - if (newSelectedRow > RowCount - 1) + if (ChangeSelectionWhenPaging) { - newSelectedRow = RowCount - 1; - } + var selectedRow = SelectedRows.Any() ? SelectedRows.First() : FirstVisibleRow; + var increment = LastVisibleRow - FirstVisibleRow; + var newSelectedRow = selectedRow + increment; + if (newSelectedRow > RowCount - 1) + { + newSelectedRow = RowCount - 1; + } - LastVisibleRow = newSelectedRow; - DeselectAll(); - SelectRow(newSelectedRow, true); - Refresh(); + LastVisibleRow = newSelectedRow; + DeselectAll(); + SelectRow(newSelectedRow, true); + Refresh(); + } + else if (LastVisibleRow < RowCount) + { + FirstVisibleRow = LastVisibleRow; + } } else if (AllowMassNavigationShortcuts && !e.Control && !e.Alt && !e.Shift && e.KeyCode == Keys.Home) // Home { diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs index 9ca029fcc1..0a27906217 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Designer.cs @@ -880,6 +880,7 @@ namespace BizHawk.Client.EmuHawk // // TasView // + this.TasView.ChangeSelectionWhenPaging = false; this.TasView.InputPaintingMode = true; this.TasView.CellWidthPadding = 3; this.TasView.GridLines = true;