From 9e4f81e3a4697a0ab079a1cea78f7f9362ed424b Mon Sep 17 00:00:00 2001
From: RetroEdit <30182911+RetroEdit@users.noreply.github.com>
Date: Fri, 18 Sep 2020 19:39:04 +0000
Subject: [PATCH] Markers/branch multi-selection (#2409)
Fixes #2215
* Make marker/branch columns use ColumnType.Text
One step towards fixing multiselect for markers and branches
* Disable some input operations while TasView is unfocused
This prevents accidentally deleting inputs while branches or markers are selected.
---
.../CustomControls/InputRoll/InputRoll.cs | 5 ++++
.../CustomControls/InputRoll/RollColumn.cs | 4 ++-
.../tools/TAStudio/BookmarksBranchesBox.cs | 9 ++++---
.../tools/TAStudio/MarkerControl.cs | 6 +++--
.../tools/TAStudio/TAStudio.MenuItems.cs | 26 +++++++++----------
.../tools/TAStudio/TAStudio.cs | 2 +-
6 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
index 0e93bd8844..7e7cf6de3c 100644
--- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
+++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs
@@ -946,6 +946,11 @@ namespace BizHawk.Client.EmuHawk
public bool AnyRowsSelected => _selectedItems.Any(cell => cell.RowIndex.HasValue);
+ ///
+ /// Rows are selected and the selection is in focus.
+ ///
+ public bool SelectionFocused => AnyRowsSelected && Focused;
+
public IEnumerable GenerateContextMenuItems()
{
if (Rotatable)
diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs
index 31bb397b64..dc188e626d 100644
--- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs
+++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/RollColumn.cs
@@ -8,7 +8,9 @@
public int Right { get; set; }
public string Name { get; set; }
public string Text { get; set; }
- public ColumnType Type { get; set; }
+
+ // Is this the default we want? ColumnType.Text is the most common.
+ public ColumnType Type { get; set; } = ColumnType.Boolean;
public bool Visible { get; set; } = true;
///
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs
index 3d62a7dcfc..1652606780 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs
@@ -76,19 +76,22 @@ namespace BizHawk.Client.EmuHawk
{
Name = BranchNumberColumnName,
Text = "#",
- UnscaledWidth = 30
+ UnscaledWidth = 30,
+ Type = ColumnType.Text
},
new RollColumn
{
Name = FrameColumnName,
Text = "Frame",
- UnscaledWidth = 64
+ UnscaledWidth = 64,
+ Type = ColumnType.Text
},
new RollColumn
{
Name = UserTextColumnName,
Text = "UserText",
- UnscaledWidth = 90
+ UnscaledWidth = 90,
+ Type = ColumnType.Text
}
});
}
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs
index e532605dd8..6881d0c796 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs
@@ -43,13 +43,15 @@ namespace BizHawk.Client.EmuHawk
{
Name = "FrameColumn",
Text = "Frame",
- UnscaledWidth = 52
+ UnscaledWidth = 52,
+ Type = ColumnType.Text
},
new RollColumn
{
Name = "LabelColumn",
Text = "",
- UnscaledWidth = 125
+ UnscaledWidth = 125,
+ Type = ColumnType.Text
}
});
}
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
index 2f34be0762..b15402ae0b 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs
@@ -205,7 +205,7 @@ namespace BizHawk.Client.EmuHawk
private void SaveSelectionToMacroMenuItem_Click(object sender, EventArgs e)
{
- if (!TasView.AnyRowsSelected)
+ if (!TasView.SelectionFocused)
{
return;
}
@@ -230,7 +230,7 @@ namespace BizHawk.Client.EmuHawk
private void PlaceMacroAtSelectionMenuItem_Click(object sender, EventArgs e)
{
- if (!TasView.AnyRowsSelected)
+ if (!TasView.SelectionFocused)
{
return;
}
@@ -392,7 +392,7 @@ namespace BizHawk.Client.EmuHawk
private void SelectBetweenMarkersMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var prevMarker = CurrentTasMovie.Markers.PreviousOrCurrent(TasView.LastSelectedIndex ?? 0);
var nextMarker = CurrentTasMovie.Markers.Next(TasView.LastSelectedIndex ?? 0);
@@ -424,7 +424,7 @@ namespace BizHawk.Client.EmuHawk
private void CopyMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
_tasClipboard.Clear();
var list = TasView.SelectedRows.ToArray();
@@ -450,7 +450,7 @@ namespace BizHawk.Client.EmuHawk
private void PasteMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
// TODO: if highlighting 2 rows and pasting 3, only paste 2 of them
// FCEUX Taseditor doesn't do this, but I think it is the expected behavior in editor programs
@@ -493,7 +493,7 @@ namespace BizHawk.Client.EmuHawk
private void PasteInsertMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
// copy paste from PasteMenuItem_Click!
IDataObject data = Clipboard.GetDataObject();
@@ -534,7 +534,7 @@ namespace BizHawk.Client.EmuHawk
private void CutMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
var rollBackFrame = TasView.FirstSelectedIndex ?? 0;
@@ -572,7 +572,7 @@ namespace BizHawk.Client.EmuHawk
private void ClearFramesMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var firstWithInput = FirstNonEmptySelectedFrame;
bool needsToRollback = firstWithInput.HasValue && firstWithInput < Emulator.Frame;
@@ -598,7 +598,7 @@ namespace BizHawk.Client.EmuHawk
private void DeleteFramesMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
var rollBackFrame = TasView.FirstSelectedIndex ?? 0;
@@ -640,7 +640,7 @@ namespace BizHawk.Client.EmuHawk
{
for (int i = 0; i < timesToClone; i++)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var framesToInsert = TasView.SelectedRows;
var insertionFrame = Math.Min((TasView.LastSelectedIndex ?? 0) + 1, CurrentTasMovie.InputLogLength);
@@ -665,7 +665,7 @@ namespace BizHawk.Client.EmuHawk
private void InsertFrameMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var insertionFrame = TasView.FirstSelectedIndex ?? 0;
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
@@ -684,7 +684,7 @@ namespace BizHawk.Client.EmuHawk
private void InsertNumFramesMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
int insertionFrame = TasView.FirstSelectedIndex ?? 0;
using var framesPrompt = new FramesPrompt();
@@ -697,7 +697,7 @@ namespace BizHawk.Client.EmuHawk
private void TruncateMenuItem_Click(object sender, EventArgs e)
{
- if (TasView.AnyRowsSelected)
+ if (TasView.SelectionFocused)
{
var rollbackFrame = TasView.LastSelectedIndex ?? 0;
var needsToRollback = TasView.FirstSelectedIndex < Emulator.Frame;
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
index d8f6bcfde6..7caac936c1 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs
@@ -702,7 +702,7 @@ namespace BizHawk.Client.EmuHawk
private void DummyLoadMacro(string path)
{
- if (!TasView.AnyRowsSelected)
+ if (!TasView.SelectionFocused)
{
return;
}