Fit more of the log on screen and edit a cell without fighting it
The theme gave each cell 32 pixels of height, which fits about seven contacts in the window. A row is now as tall as its text and one pixel either side, so about fifteen fit. Editing a cell: - the columns bind one way, and the value is written back when the edit is taken, on Enter or a click elsewhere. A two-way binding wrote on every key press, which took the edit as the first character was typed and closed the box. - Enter on the current cell opens the box. The handler runs before the grid's own, which reads Enter as "move down a line". - Left, Right, Home and End stay in the box. The grid read a key the box left alone as "go to the next cell", and the box leaves a key alone when the caret cannot move; End also landed at the start of the text. - the box takes the height and the left inset of the text it covers, so nothing moves as it opens. An edit no longer rebuilds the list. The lines on screen are given the contact again, so the view stays where the operator put it instead of jumping to the top and back. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157i7PiZyqBkquxS9A6FTdQ
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using Avalonia.Media;
|
||||
using Nonemm.Contests;
|
||||
using Nonemm.Core;
|
||||
@@ -9,28 +10,35 @@ namespace Nonemm.App.Windows;
|
||||
/// so the columns can follow the contest exchange and the operator's choice
|
||||
/// instead of being fixed in the XAML. The colour comes from the same scorer as
|
||||
/// the entry window and the bandmap.
|
||||
public sealed class LogRow
|
||||
public sealed class LogRow : INotifyPropertyChanged
|
||||
{
|
||||
private readonly Func<Qso, QsoField, string, bool> edit;
|
||||
|
||||
public LogRow(Qso qso, Verdict? verdict, Func<Qso, QsoField, string, bool> edit)
|
||||
public LogRow(Qso qso, Verdict? verdict)
|
||||
{
|
||||
Qso = qso;
|
||||
Verdict = verdict;
|
||||
this.edit = edit;
|
||||
}
|
||||
|
||||
public Qso Qso { get; }
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
public Verdict? Verdict { get; }
|
||||
public Qso Qso { get; private set; }
|
||||
|
||||
/// `name` is a `QsoField` name. A refused edit leaves the contact alone, so
|
||||
/// the grid reads the old value back and the cell reverts.
|
||||
public string this[string name]
|
||||
public Verdict? Verdict { get; private set; }
|
||||
|
||||
/// Takes the contact again after it was edited. The grid redraws the line
|
||||
/// it is already showing, so the view stays where it was. "Item" is the
|
||||
/// name the indexer below has in the metadata, and the name the binding
|
||||
/// listens for; any other name is ignored.
|
||||
public void Show(Qso qso, Verdict? verdict)
|
||||
{
|
||||
get => QsoEditor.Read(Qso, Enum.Parse<QsoField>(name));
|
||||
set => edit(Qso, Enum.Parse<QsoField>(name), value);
|
||||
Qso = qso;
|
||||
Verdict = verdict;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item"));
|
||||
}
|
||||
|
||||
/// `name` is a `QsoField` name. Read only: an edited cell is written back by
|
||||
/// `LogWindow.TakeCellEdit` when the operator takes the edit, not as the
|
||||
/// text is typed.
|
||||
public string this[string name] => QsoEditor.Read(Qso, Enum.Parse<QsoField>(name));
|
||||
|
||||
public IBrush Colour => Verdicts.Colour(Verdict);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user