UI: Fixed issues with checkbox columns in lists

Cheat list, breakpoint list
This commit is contained in:
Sour 2023-02-20 20:15:44 -05:00
parent ce9eedd71b
commit 4c9d6fd7b4
3 changed files with 8 additions and 50 deletions

View file

@ -662,39 +662,6 @@
<Control ID="btnUpdate">Update</Control>
<Control ID="btnCancel">Cancel</Control>
</Form>
<Form ID="frmHdPackEditor" Title="HD Pack Builder">
<Control ID="grpPreview">CHR Bank Preview</Control>
<Control ID="lblChrBank">CHR Bank:</Control>
<Control ID="grpOptions">Recording Options</Control>
<Control ID="lblBankSize">CHR Bank Size:</Control>
<Control ID="lblScale">Scale/Filter:</Control>
<Control ID="chkSortByFrequency">Sort pages by usage frequency</Control>
<Control ID="chkLargeSprites">Use 8x16 sprite display mode</Control>
<Control ID="chkGroupBlankTiles">Group blank tiles</Control>
<Control ID="chkIgnoreOverscan">Ignore tiles at the edges of the screen (overscan)</Control>
<Control ID="lblFolder">Save Folder:</Control>
<Control ID="btnSelectFolder">Browse...</Control>
<Control ID="btnStartRecording">Start Recording</Control>
<Control ID="btnStopRecording">Stop Recording</Control>
<Control ID="btnOpenFolder">Open Save Folder</Control>
</Form>
<Form ID="frmSelectExportRange" Title="Export specific range...">
<Control ID="lblStartTime">Start time:</Control>
<Control ID="lblEndTime">End time:</Control>
<Control ID="btnOK">OK</Control>
<Control ID="btnCancel">Cancel</Control>
</Form>
<Form ID="frmHelp" Title="Command-line options">
<Control ID="grpExample">Usage Example</Control>
<Control ID="tpgGeneralOptions">General</Control>
<Control ID="tpgVideoOptions">Video Options</Control>
<Control ID="tpgAudioOptions">Audio Options</Control>
<Control ID="tpgEmulationOptions">Emulation Options</Control>
<Control ID="lblExplanation">This will start Mesen in fullscreen mode with the "MyGame.nes" rom loaded. It will also use the NTSC filter, set at a 2x scale and configure the Overscan settings. The "DoNotSaveSettings" flag is used to prevent the command line switches from pernanently altering Mesen's settings.</Control>
</Form>
<Form ID="frmCopyFiles" Title="Please wait...">
<Control ID="lblCopying">Copying:</Control>
</Form>
<Form ID="SetupWizardWindow">
<Control ID="wndTitle">Mesen</Control>
<Control ID="lblMesen">Mesen - Emulator</Control>

View file

@ -205,14 +205,7 @@ public class DataBox : TemplatedControl
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
if(change.Property == SelectionProperty) {
if(change.OldValue is ISelectionModel oldModel) {
oldModel.SelectionChanged -= Selection_SelectionChanged;
}
if(change.NewValue is ISelectionModel newModel) {
newModel.SelectionChanged += Selection_SelectionChanged;
}
} else if(change.Property == ColumnsProperty) {
if(change.Property == ColumnsProperty) {
if(change.NewValue is AvaloniaList<DataBoxColumn> columns && columns.Count > ColumnWidths.Count) {
for(int i = ColumnWidths.Count; i < columns.Count; i++) {
ColumnWidths.Add(columns[i].InitialWidth);
@ -222,15 +215,6 @@ public class DataBox : TemplatedControl
base.OnPropertyChanged(change);
}
private void Selection_SelectionChanged(object? sender, SelectionModelSelectionChangedEventArgs e)
{
if(IsKeyboardFocusWithin && Selection?.SelectedIndex >= 0 && Selection.SelectedItems.Count == 1) {
//When selection is changed and only 1 row is selected, move keyboard focus to that row
//Only do this if the DataBox already contained the keyboard focus
_rowsPresenter?.ContainerFromIndex(Selection.SelectedIndex)?.Focus();
}
}
internal void Attach()
{
if (_headersPresenter is { })
@ -319,6 +303,9 @@ public class DataBox : TemplatedControl
if(e.Key == Key.Space) {
ProcessKeyPress(" ");
e.Handled = true;
} else if(IsKeyboardFocusWithin && FocusManager.Instance?.Current is CheckBox) {
//Allow up/down arrow keys to work properly when focus is on a checkbox column
_rowsPresenter?.ContainerFromIndex(Selection.SelectedIndex)?.Focus();
}
}

View file

@ -52,8 +52,12 @@ namespace Mesen.ViewModels
public void Sort(object? param = null)
{
List<CheatCode> sortedCheats = new List<CheatCode>(Cheats);
CheatCode? selectedItem = Selection.SelectedItem;
SortHelper.SortList(sortedCheats, SortState.SortOrder, _comparers, "Codes");
Cheats.Replace(sortedCheats);
if(selectedItem != null) {
Selection.SelectedItem = selectedItem;
}
}
public void LoadCheats()