Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
346a497398
|
||
|
|
87e7e15e92
|
No files matched your search
+5
-4
@@ -29,7 +29,7 @@ notices Windows shows for it. It draws nothing inside a game, so it cannot make
|
||||
|
||||
| Keys | What they do |
|
||||
|---|---|
|
||||
| **Ctrl+1** … **Ctrl+5** (also with the numeric keypad) | Open Dashboard, Games, Compare, Logs and Settings. |
|
||||
| **Ctrl+1** … **Ctrl+5** (also with the numeric keypad) | Open Dashboard, Games, Compare, Logs and Settings, and move the keyboard into that page; a screen reader hears its title. |
|
||||
| **Alt** or **F10**, then the arrow keys and **Enter** | Move to the menus. **Alt** with a menu's underlined letter opens it (*File*, *Tools*, *Help* in English). |
|
||||
| **Tab** and **Shift+Tab** | Move through a page or a dialog in reading order. |
|
||||
| The **arrow keys**, **Home**, **End**, **Page Up**, **Page Down** | Move inside a list or a table — a game's sessions, the games list, the Compare list, the import checklist. |
|
||||
@@ -61,7 +61,8 @@ The same keys are in the user guide, [The screens](guide/07-screens.md#keyboard-
|
||||
- **The notices above the page can be read where they are shown**, and the button that answers one says which notice it
|
||||
answers.
|
||||
- **Tab goes from control to control**: pictures, lists and the rows of Settings are not stops of their own.
|
||||
- **Dialogs say they are dialogs** and keep the focus inside them until they close.
|
||||
- **Dialogs say they are dialogs**, keep the focus inside them until they close, and then give it back to the control
|
||||
that opened them. A message box opens over FrameLedger's window, never behind it.
|
||||
|
||||
### Seeing the screen
|
||||
|
||||
@@ -94,7 +95,8 @@ from the same translations. The documents — the user guide, this page, the leg
|
||||
alone; a chart's keys move it and stay its own; every control that shows no text has a name; no colour is written
|
||||
into a screen; every text reads against its background in both themes and after a theme switch, and under Windows'
|
||||
four contrast themes and two edited ones is drawn in the theme's own colours at 4.5:1 or better; **Esc** closes the
|
||||
open dialog without an answer; **Ctrl+1** … **Ctrl+5** open the pages in their order; the program declares it follows
|
||||
open dialog without an answer and a dialog gives the focus back; **Ctrl+1** … **Ctrl+5** open the pages in their order
|
||||
and move the keyboard into them; a page slides in only while Windows' animation effects are on; the program declares it follows
|
||||
each screen's scaling.
|
||||
- **By hand**: the owner's pass of 2026-11-09 above, repeated for each release that changes a screen.
|
||||
- **Not tested yet**: NVDA, JAWS, Voice Access, touch, Windows 10, and other people's PCs. They should work through the
|
||||
@@ -114,7 +116,6 @@ Each one with what to do instead. A barrier that is not on this list is worth re
|
||||
screen reader is told each one as it appears.
|
||||
- **Windows' text size setting** (Settings ▸ Accessibility ▸ Text size) **is not followed.** Use display scaling
|
||||
(Settings ▸ System ▸ Display ▸ Scale) or Magnifier.
|
||||
- **Page changes slide in** even when Windows' animation effects are off.
|
||||
- **Pausing capture is only in the menu of the icon by the clock.**
|
||||
- **The windows Windows itself shows** — choosing a file, the administrator prompt — are Windows', not FrameLedger's.
|
||||
|
||||
|
||||
@@ -83,8 +83,17 @@ numeric core and does not move; the heading is the full version — corrected 20
|
||||
theme's own button; a pressed menu item is no longer white on white; nothing is drawn translucent, and a game's picture
|
||||
lends its page no colour, as before.
|
||||
|
||||
- **The keyboard follows a page shortcut.** **Ctrl+1** … **Ctrl+5** now move the focus into the page they open — its
|
||||
first control — and a screen reader hears the page's title; before, the focus stayed where it was, often on the page
|
||||
that had just gone, and Tab began again at the top of the window.
|
||||
- **Pages no longer slide in while Windows' animation effects are off** (Settings ▸ Accessibility ▸ Visual effects),
|
||||
followed as the setting changes.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A message box opens over FrameLedger's window** — Remove game, Delete sessions, the database's and the update's
|
||||
questions. It had no owner, so it could fall behind the window it came from and, closing, give the focus to another
|
||||
program; it is owned by the window that opened it now, and the focus comes back there.
|
||||
- **A double-click on a chart shows all of it again**, as the user guide said; it toggled ScottPlot's render-time overlay.
|
||||
- **The capture agent's state in the title bar reads in the light theme.** It was drawn on WPF UI's fixed green, blue,
|
||||
orange and red under white — 2.78, 2.63, 2.16 and 3.68:1 — and is on the theme's own success, caution and critical
|
||||
|
||||
+14
-2
@@ -1030,7 +1030,7 @@ the requirement was one bullet under §UX rules, and nothing checked it.
|
||||
|
||||
| Keys | Does | Where |
|
||||
|---|---|---|
|
||||
| **Ctrl+1 … Ctrl+5** (and the numeric keypad's 1–5) | Dashboard · Games · Compare · Logs · Settings | `MainWindow` `InputBindings` → `MainWindowViewModel.NavigateToCommand` → `ShellShortcuts` |
|
||||
| **Ctrl+1 … Ctrl+5** (and the numeric keypad's 1–5) | Dashboard · Games · Compare · Logs · Settings — and since beta.35 the page's first control takes the focus once it is shown, its title (the page's first-level heading) said to a screen reader; before, the focus stayed where it was, often on the page that had just gone | `MainWindow` `InputBindings` → `MainWindowViewModel.NavigateToCommand` → `ShellShortcuts`, then `Services/PageFocus` (the shell tells it each page shown, from `NavigationView.Navigated`) |
|
||||
| **Alt**, **F10** | Focuses the menu bar; arrows and Enter walk File / Tools / Help | WPF `Menu`, nothing custom |
|
||||
| **Alt** + a menu's access key | Opens that menu — `_File` `_Tools` `_Help`; `_Tệp` `_Công cụ` `Trợ _giúp`; `ファイル(_F)` `ツール(_T)` `ヘルプ(_H)` *(row added 2026-11-09: the keys existed since P3 and this table did not name them)* | the `Menu_*` strings' `_` |
|
||||
| **Tab / Shift+Tab** | Moves through a page in reading order | layout order; no `TabIndex` overrides |
|
||||
@@ -1039,6 +1039,17 @@ the requirement was one bullet under §UX rules, and nothing checked it.
|
||||
| **Esc** | Closes the open `ContentDialog` or `MessageBox` with no result — the same as its Close/Cancel button | `DialogKeyboard`, one class handler per dialog type registered at start-up |
|
||||
| **Enter** | In the consent dialog's phrase box: enables hooking once the phrase is typed exactly, does nothing before (beta.30, D69); elsewhere in a `ContentDialog`, the default button | WPF's default button (`ConsentPrompt`: `DefaultButton = Primary`) and `ConsentDialogContent.SwallowsEnter` |
|
||||
|
||||
**Focus after a dialog, and motion (beta.35).** A `ContentDialog` gives the focus back to the control that opened it: WPF
|
||||
UI 4.3.0's `ContentDialogHostController` stores `Keyboard.FocusedElement` when the dialog opens and focuses it again, at
|
||||
`DispatcherPriority.Input`, when it closes — the App adds nothing, and
|
||||
`FocusAndMotionTests.AContentDialogGivesTheFocusBackToTheControlThatOpenedIt` holds it (a first measurement said
|
||||
otherwise; it ran on a thread with no dispatcher context, where the dialog's own `finally` never resumed). A WPF UI
|
||||
`MessageBox` sets no owner — null before and after it is shown — so `Services/MessageBoxes` gives it the App's active
|
||||
window: it opens over it and hands the focus back to it, not to another program; every box goes through it
|
||||
(`EveryMessageBoxGoesThroughMessageBoxes`). A page slides in only while Windows' animation effects are on
|
||||
(`SystemParameters.ClientAreaAnimation`, followed as it changes): `Services/PageMotion` sets the `NavigationView`'s
|
||||
`Transition` to `None` while they are off, where WPF UI 4.3.0 played `FadeInWithSlide` whatever they were.
|
||||
|
||||
**Esc is the Close button, never the primary one.** On the consent dialog (FR-2.1) that is ~~"Keep it off"~~ "Keep hooking
|
||||
off" *(the button's text, corrected 2026-10-07)*: nothing is
|
||||
stamped. A dialog that offers no Close button is not dismissed by Esc, and the Legal Gate (FR-11) is a window of its own
|
||||
@@ -1254,6 +1265,7 @@ ScottPlot reads once when the control is made, before it has a window.
|
||||
chart, the FPS readout, the RT/PT/RR chips, the game's artwork — is a Tab stop Narrator says nothing about; text inside
|
||||
a control template (the safety notices' title and message, the readout, the chips) is hidden from the control view;
|
||||
nothing is announced; no text is a heading; several charts tell series apart by colour alone~~ *(closed the same day,
|
||||
§Screen readers above)*; page transitions play with Windows' animation effects off; ~~Windows contrast themes are not
|
||||
§Screen readers above)*; ~~page transitions play with Windows' animation effects off~~ *(not since beta.35,
|
||||
§Keyboard)*; ~~Windows contrast themes are not
|
||||
followed~~ *(followed since beta.35, D91 — §Contrast)*. `ACCESSIBILITY.md` §Known limitations
|
||||
states each to users with what to do instead.
|
||||
+1
-1
@@ -133,7 +133,7 @@ is ready.
|
||||
|
||||
## Keyboard and mouse
|
||||
|
||||
- **Ctrl+1** … **Ctrl+5** open Dashboard, Games, Compare, Logs and Settings.
|
||||
- **Ctrl+1** … **Ctrl+5** open Dashboard, Games, Compare, Logs and Settings, and put the keyboard in that page.
|
||||
- **Alt** or **F10** moves to the menus; **Alt** with a menu's underlined letter opens it (**Alt+F**, **Alt+T** and
|
||||
**Alt+H** for File, Tools and Help in English).
|
||||
- **Esc** closes a dialog the way its Close or Cancel button does.
|
||||
|
||||
@@ -379,6 +379,7 @@ public partial class App : System.Windows.Application
|
||||
services.AddSingleton<TrayViewModel>();
|
||||
services.AddSingleton<TrayHost>();
|
||||
services.AddTransient<MainWindow>();
|
||||
services.AddSingleton<PageFocus>(); // beta.35: Ctrl+1…5 put the keyboard in the page they open
|
||||
services.AddSingleton<MainWindowViewModel>();
|
||||
services.AddSingleton<ILanguageFollower>(static sp => sp.GetRequiredService<TrayHost>());
|
||||
services.AddSingleton<ILanguageFollower>(static sp => sp.GetRequiredService<MainWindowViewModel>());
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.ViewModels;
|
||||
@@ -19,6 +20,8 @@ namespace FrameLedger.App;
|
||||
/// </summary>
|
||||
public partial class MainWindow : FluentWindow
|
||||
{
|
||||
private readonly PageMotion _motion;
|
||||
|
||||
public MainWindow(
|
||||
MainWindowViewModel viewModel,
|
||||
INavigationService navigation,
|
||||
@@ -26,7 +29,8 @@ public partial class MainWindow : FluentWindow
|
||||
IContentDialogService dialogs,
|
||||
INavigationViewPageProvider pages,
|
||||
IThemeApplier theme,
|
||||
AppearanceSettings appearance)
|
||||
AppearanceSettings appearance,
|
||||
PageFocus pageFocus)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(navigation);
|
||||
ArgumentNullException.ThrowIfNull(snackbar);
|
||||
@@ -34,6 +38,7 @@ public partial class MainWindow : FluentWindow
|
||||
ArgumentNullException.ThrowIfNull(pages);
|
||||
ArgumentNullException.ThrowIfNull(theme);
|
||||
ArgumentNullException.ThrowIfNull(appearance);
|
||||
ArgumentNullException.ThrowIfNull(pageFocus);
|
||||
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
@@ -55,6 +60,17 @@ public partial class MainWindow : FluentWindow
|
||||
|
||||
Loaded += (_, _) => theme.Apply(appearance.Theme, this);
|
||||
TimeNavigations();
|
||||
|
||||
// beta.35: a page slides in only while Windows' animation effects are on, followed while the window lives; and the
|
||||
// page a shortcut opens takes the keyboard (PageFocus) — the shell says which page is shown after every navigation.
|
||||
_motion = PageMotion.Follow(RootNavigation);
|
||||
RootNavigation.Navigated += (_, e) =>
|
||||
{
|
||||
if (e.Page is FrameworkElement page)
|
||||
{
|
||||
pageFocus.Shown(page);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -78,4 +94,10 @@ public partial class MainWindow : FluentWindow
|
||||
}
|
||||
|
||||
public MainWindowViewModel ViewModel { get; }
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
_motion.Dispose();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public sealed class Confirmations : IConfirmations
|
||||
SecondaryButtonAppearance = ControlAppearance.Danger,
|
||||
CloseButtonText = Strings.Common_Cancel,
|
||||
};
|
||||
MessageBoxResult result = await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
MessageBoxResult result = await MessageBoxes.ShowAsync(box, ct).ConfigureAwait(true);
|
||||
return result switch
|
||||
{
|
||||
MessageBoxResult.Primary => RemoveGameChoice.KeepSessions,
|
||||
@@ -45,6 +45,6 @@ public sealed class Confirmations : IConfirmations
|
||||
PrimaryButtonAppearance = ControlAppearance.Danger,
|
||||
CloseButtonText = Strings.Common_Cancel,
|
||||
};
|
||||
return await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true) == MessageBoxResult.Primary;
|
||||
return await MessageBoxes.ShowAsync(box, ct).ConfigureAwait(true) == MessageBoxResult.Primary;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public sealed class DatabaseMaintenancePrompts : IDatabaseMaintenancePrompts
|
||||
PrimaryButtonAppearance = ControlAppearance.Danger,
|
||||
CloseButtonText = Strings.Common_Cancel,
|
||||
};
|
||||
MessageBoxResult result = await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
MessageBoxResult result = await MessageBoxes.ShowAsync(box, ct).ConfigureAwait(true);
|
||||
return result == MessageBoxResult.Primary;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Every message box the App shows is owned by its window (beta.35). WPF UI 4.3.0's <see cref="Wpf.Ui.Controls.MessageBox"/>
|
||||
/// sets no owner (measured 2026-11-09: null before and after it is shown), and an ownerless modal window can fall behind the
|
||||
/// window it was opened from and, when it closes, hand the focus to whichever program Windows activates next. Owned by the
|
||||
/// App's active window, it opens over it and gives the focus back to it, where the control that had the keyboard takes it
|
||||
/// again. Every box goes through here (<c>FocusAndMotionTests.EveryMessageBoxGoesThroughMessageBoxes</c>).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The App's other dialogs need nothing of the kind: a <c>ContentDialog</c> lives inside the window, and WPF UI's host stores
|
||||
/// the focused element when it opens and focuses it again when it closes (<c>ContentDialogHostController</c>,
|
||||
/// <c>FocusAndMotionTests.AContentDialogGivesTheFocusBackToTheControlThatOpenedIt</c>).
|
||||
/// </remarks>
|
||||
public static class MessageBoxes
|
||||
{
|
||||
/// <summary>Shows <paramref name="box"/> as a dialog owned by the App's active window.</summary>
|
||||
public static async Task<Wpf.Ui.Controls.MessageBoxResult> ShowAsync(Wpf.Ui.Controls.MessageBox box, CancellationToken ct = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(box);
|
||||
Own(box);
|
||||
return await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
/// <summary>The App's active window, else its main one while it is shown, becomes <paramref name="box"/>'s owner.</summary>
|
||||
internal static void Own(Window box)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(box);
|
||||
System.Windows.Application? app = System.Windows.Application.Current;
|
||||
Window? owner = app?.Windows.OfType<Window>().FirstOrDefault(w => w.IsActive && w.IsVisible && !ReferenceEquals(w, box))
|
||||
?? (app?.MainWindow is { IsVisible: true } main && !ReferenceEquals(main, box) ? main : null);
|
||||
if (owner is not null)
|
||||
{
|
||||
box.Owner = owner;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Ctrl+1 … Ctrl+5 put the keyboard in the page they open (beta.35): once it is shown, its first control takes the focus
|
||||
/// and a screen reader hears its title — its first-level heading. Before, the focus stayed on the control that had it,
|
||||
/// often one of the page that had just gone, and Tab began again at the top of the window. A page chosen in the pane with
|
||||
/// the mouse leaves the focus where WPF UI puts it.
|
||||
/// </summary>
|
||||
public sealed class PageFocus
|
||||
{
|
||||
private readonly IAnnouncer _announcer;
|
||||
private WeakReference<FrameworkElement>? _page;
|
||||
|
||||
public PageFocus(IAnnouncer? announcer = null) => _announcer = announcer ?? NoAnnouncer.Instance;
|
||||
|
||||
/// <summary>The shell's word of the page shown now, after every navigation, by a shortcut or not.</summary>
|
||||
public void Shown(FrameworkElement page)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(page);
|
||||
_page = new WeakReference<FrameworkElement>(page);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// After a shortcut has navigated — or found its page already shown, when WPF UI navigates nowhere — the page shown then
|
||||
/// takes the focus once the dispatcher has laid it out.
|
||||
/// </summary>
|
||||
[SuppressMessage("Usage", "VSTHRD001:Avoid legacy thread switching APIs", Justification = "a WPF application has no JoinableTaskFactory; this posts to the UI thread's own dispatcher, after the new page's layout, and never waits (ScrollBarHiding does the same)")]
|
||||
public void Request()
|
||||
{
|
||||
Dispatcher? dispatcher = System.Windows.Application.Current?.Dispatcher;
|
||||
if (dispatcher is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ = dispatcher.BeginInvoke(DispatcherPriority.Loaded, Take);
|
||||
}
|
||||
|
||||
/// <summary>Moves the focus to the page's first control and says its title.</summary>
|
||||
internal void Enter(FrameworkElement page)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(page);
|
||||
_ = page.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
|
||||
if (Title(page) is { Length: > 0 } title)
|
||||
{
|
||||
_announcer.Announce(title, AnnouncementKind.Status, "Page");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The page's title: the text of its first first-level heading (beta.35, D90 — every page has exactly one).</summary>
|
||||
internal static string? Title(DependencyObject root)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(root);
|
||||
if (root is TextBlock text && AutomationProperties.GetHeadingLevel(text) == AutomationHeadingLevel.Level1)
|
||||
{
|
||||
return text.Text;
|
||||
}
|
||||
|
||||
int count = VisualTreeHelper.GetChildrenCount(root);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (Title(VisualTreeHelper.GetChild(root, i)) is { } found)
|
||||
{
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Take()
|
||||
{
|
||||
if (_page?.TryGetTarget(out FrameworkElement? page) != true || page is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (page.IsLoaded)
|
||||
{
|
||||
Enter(page);
|
||||
return;
|
||||
}
|
||||
|
||||
void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
page.Loaded -= OnLoaded;
|
||||
Enter(page);
|
||||
}
|
||||
|
||||
page.Loaded += OnLoaded;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows;
|
||||
using Wpf.Ui.Animations;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// A page slides in only while Windows' animation effects are on (beta.35): Settings ▸ Accessibility ▸ Visual effects ▸
|
||||
/// Animation effects, which WPF reads as <see cref="SystemParameters.ClientAreaAnimation"/> and announces when it changes.
|
||||
/// WPF UI 4.3.0's navigation plays its own <see cref="Transition.FadeInWithSlide"/> whatever that setting says.
|
||||
/// </summary>
|
||||
public sealed class PageMotion : IDisposable
|
||||
{
|
||||
private readonly NavigationView _navigation;
|
||||
private readonly Func<bool> _animations;
|
||||
|
||||
private PageMotion(NavigationView navigation, Func<bool> animations)
|
||||
{
|
||||
_navigation = navigation;
|
||||
_animations = animations;
|
||||
Apply();
|
||||
SystemParameters.StaticPropertyChanged += OnSystemParameterChanged;
|
||||
}
|
||||
|
||||
/// <summary>The transition for the setting: WPF UI's own while animations are on, none while they are off.</summary>
|
||||
public static Transition For(bool animations) => animations ? Transition.FadeInWithSlide : Transition.None;
|
||||
|
||||
/// <summary>
|
||||
/// Sets <paramref name="navigation"/>'s transition now and whenever the setting changes, until disposed (the shell does
|
||||
/// when its window closes).
|
||||
/// </summary>
|
||||
public static PageMotion Follow(NavigationView navigation, Func<bool>? animations = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(navigation);
|
||||
return new PageMotion(navigation, animations ?? (static () => SystemParameters.ClientAreaAnimation));
|
||||
}
|
||||
|
||||
public void Dispose() => SystemParameters.StaticPropertyChanged -= OnSystemParameterChanged;
|
||||
|
||||
/// <summary>Reads the setting again — what a change does; a test calls it with its own reader.</summary>
|
||||
internal void Apply() => _navigation.Transition = For(_animations());
|
||||
|
||||
[SuppressMessage("Usage", "VSTHRD001:Avoid legacy thread switching APIs", Justification = "Windows' setting change can arrive off the UI thread; the navigation is its dispatcher's to change, posted and never waited on")]
|
||||
private void OnSystemParameterChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (string.Equals(e.PropertyName, nameof(SystemParameters.ClientAreaAnimation), StringComparison.Ordinal))
|
||||
{
|
||||
_ = _navigation.Dispatcher.BeginInvoke(new Action(Apply));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public sealed class UpdatePrompts(IUrlOpener urls, BugReportFlow bugReports) : I
|
||||
CloseButtonText = Strings.Update_Later,
|
||||
MaxWidth = 640,
|
||||
};
|
||||
MessageBoxResult result = await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
MessageBoxResult result = await MessageBoxes.ShowAsync(box, ct).ConfigureAwait(true);
|
||||
return result == MessageBoxResult.Primary;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public sealed class UpdatePrompts(IUrlOpener urls, BugReportFlow bugReports) : I
|
||||
break;
|
||||
}
|
||||
|
||||
MessageBoxResult result = await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
MessageBoxResult result = await MessageBoxes.ShowAsync(box, ct).ConfigureAwait(true);
|
||||
if (result != MessageBoxResult.Primary)
|
||||
{
|
||||
return;
|
||||
@@ -137,6 +137,6 @@ public sealed class UpdatePrompts(IUrlOpener urls, BugReportFlow bugReports) : I
|
||||
CloseButtonText = Strings.Common_Ok,
|
||||
MaxWidth = 560,
|
||||
};
|
||||
await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true);
|
||||
await MessageBoxes.ShowAsync(box, ct).ConfigureAwait(true);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
|
||||
private readonly ShellAnnouncements _said;
|
||||
private readonly IShellPresence _shell;
|
||||
private readonly IPageNavigator _navigator;
|
||||
private readonly PageFocus? _pageFocus;
|
||||
private readonly UiThread _ui = new();
|
||||
|
||||
[ObservableProperty]
|
||||
@@ -67,8 +68,9 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
|
||||
public MainWindowViewModel(IAgentLink agent, IMessageStrip strip, IShellPresence shell, IPageNavigator navigator, AddGameFlow addGame, SafetyNotices notices,
|
||||
BugReportFlow bugReports, IUrlOpener urls, SessionSelection selection, SessionExportService exports, ISessionSummaryOpener summaries, ImportLibraryFlow import,
|
||||
UpdateService updates, IDatabaseMaintenancePrompts maintenance, IDocumentWindows documents, UiMode? mode = null, BuildLine? line = null,
|
||||
IAnnouncer? announcer = null)
|
||||
IAnnouncer? announcer = null, PageFocus? pageFocus = null)
|
||||
{
|
||||
_pageFocus = pageFocus;
|
||||
_mode = mode ?? UiMode.Profile;
|
||||
_line = line ?? BuildLine.Current;
|
||||
_isAlphaBannerOpen = _line.IsAlpha;
|
||||
@@ -205,9 +207,18 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable,
|
||||
[RelayCommand]
|
||||
private void Exit() => _shell.Quit();
|
||||
|
||||
/// <summary>08_UI §Accessibility: Ctrl+1…5 (and the keypad) — the NavigationView's pages in its order.</summary>
|
||||
/// <summary>
|
||||
/// 08_UI §Accessibility: Ctrl+1…5 (and the keypad) — the NavigationView's pages in its order; since beta.35 the page then
|
||||
/// takes the keyboard and its title is said (<see cref="PageFocus"/>).
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private void NavigateTo(string? key) => _ = ShellShortcuts.Navigate(_navigator, key);
|
||||
private void NavigateTo(string? key)
|
||||
{
|
||||
if (ShellShortcuts.Navigate(_navigator, key))
|
||||
{
|
||||
_pageFocus?.Request();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Tools ▸ Agent status… is the Dashboard's Agent card.</summary>
|
||||
[RelayCommand]
|
||||
|
||||
@@ -340,9 +340,13 @@ TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
constexpr std::uint32_t kTotal = 200000;
|
||||
|
||||
std::uint64_t mostOverlapped = 0;
|
||||
std::uint64_t dropped = 0; // the last attempt's: the one that overlapped, when one did
|
||||
std::uint64_t overlappedLast = 0; // the last attempt's two counts: the one that overlapped AND was lapped,
|
||||
std::uint64_t dropped = 0; // when one was
|
||||
int attempts = 0;
|
||||
while (mostOverlapped < kMinOverlappedDrains && attempts < kMaxAttempts) {
|
||||
// Repeated until one attempt both overlapped the writer and was lapped by it (2026-11-09: CI's attempt overlapped
|
||||
// 167058 drains and the reader still kept up with all 200000 records, dropping none). A reader that never counts a
|
||||
// drop fails all eight attempts, so the retry keeps the check's power.
|
||||
while ((overlappedLast < kMinOverlappedDrains || dropped == 0) && attempts < kMaxAttempts) {
|
||||
++attempts;
|
||||
Mapping m{kTiny};
|
||||
RingWriter w;
|
||||
@@ -392,6 +396,7 @@ TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
}
|
||||
producer.join();
|
||||
dropped = lost;
|
||||
overlappedLast = overlapped;
|
||||
|
||||
INFO("attempt " << attempts << ": accepted " << accepted << ", overlapped drains " << overlapped << " of "
|
||||
<< kTotal);
|
||||
@@ -400,11 +405,12 @@ TEST_CASE("a tiny ring, so the writer laps the reader constantly", "[ring]") {
|
||||
mostOverlapped = std::max(mostOverlapped, overlapped);
|
||||
}
|
||||
|
||||
INFO("attempts " << attempts << ", most overlapped drains " << mostOverlapped << ", dropped " << dropped);
|
||||
INFO("attempts " << attempts << ", most overlapped drains " << mostOverlapped << ", the last attempt's "
|
||||
<< overlappedLast << ", dropped " << dropped);
|
||||
// Not vacuous: the reader read the ring while the writer was writing it. `dropped > 0` alone could not say so — a
|
||||
// reader that started after the writer had finished drops nearly everything — and with eight slots the attempt
|
||||
// that overlapped (the last one) is lapped, which the second check holds it to.
|
||||
CHECK(mostOverlapped >= kMinOverlappedDrains);
|
||||
// reader that started after the writer had finished drops nearly everything — so both hold in the same attempt, the
|
||||
// last one: it overlapped and, with eight slots, was lapped.
|
||||
CHECK(overlappedLast >= kMinOverlappedDrains);
|
||||
CHECK(dropped > 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Animations;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Focus and motion (beta.35): a page slides in only while Windows' animation effects are on, and Ctrl+1 … Ctrl+5 put the
|
||||
/// keyboard in the page they open, its title said.
|
||||
/// </summary>
|
||||
public sealed partial class FocusAndMotionTests
|
||||
{
|
||||
[GeneratedRegex(@"\bShowDialogAsync\(", RegexOptions.CultureInvariant, 1000)]
|
||||
private static partial Regex BoxShown();
|
||||
|
||||
[Fact]
|
||||
public void APageSlidesInOnlyWhileWindowsAnimatesAndFollowsTheSettingAsItChanges()
|
||||
{
|
||||
PageMotion.For(animations: true).Should().Be(Transition.FadeInWithSlide, "WPF UI's own, as before");
|
||||
PageMotion.For(animations: false).Should().Be(Transition.None);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheNavigationTakesTheTransitionOfTheSettingNowAndAgainWhenItChanges()
|
||||
{
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
bool animations = false;
|
||||
var navigation = new NavigationView();
|
||||
Transition before = navigation.Transition;
|
||||
using PageMotion motion = PageMotion.Follow(navigation, () => animations);
|
||||
Transition off = navigation.Transition;
|
||||
animations = true;
|
||||
motion.Apply();
|
||||
return (before, off, On: navigation.Transition);
|
||||
});
|
||||
|
||||
facts.before.Should().Be(Transition.FadeInWithSlide, "WPF UI 4.3.0's default, played whatever Windows says");
|
||||
facts.off.Should().Be(Transition.None);
|
||||
facts.On.Should().Be(Transition.FadeInWithSlide);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AShortcutPutsTheFocusOnThePagesFirstControlAndSaysItsTitle()
|
||||
{
|
||||
var said = new RecordingAnnouncer();
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var focus = new PageFocus(said);
|
||||
var elsewhere = new System.Windows.Controls.Button { Content = "Elsewhere" };
|
||||
var heading = new System.Windows.Controls.TextBlock { Text = "Games" };
|
||||
AutomationProperties.SetHeadingLevel(heading, AutomationHeadingLevel.Level1);
|
||||
var first = new System.Windows.Controls.Button { Content = "Add game" };
|
||||
var page = new StackPanel { Children = { heading, first, new System.Windows.Controls.Button { Content = "Import" } } };
|
||||
var root = new StackPanel { Children = { elsewhere, page } };
|
||||
var host = new FluentWindow { Content = root, Width = 300, Height = 300, ShowActivated = true, WindowStartupLocation = WindowStartupLocation.Manual, Left = -10000, Top = -10000 };
|
||||
host.Show();
|
||||
try
|
||||
{
|
||||
Visuals.Pump();
|
||||
_ = elsewhere.Focus();
|
||||
focus.Shown(page);
|
||||
focus.Request();
|
||||
Visuals.Pump();
|
||||
return (Focused: Keyboard.FocusedElement, first, Title: PageFocus.Title(page));
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Close();
|
||||
}
|
||||
});
|
||||
|
||||
facts.Focused.Should().BeSameAs(facts.first, "the page's first control has the keyboard");
|
||||
facts.Title.Should().Be("Games");
|
||||
said.Said.Should().ContainSingle().Which.Should().Be(("Games", AnnouncementKind.Status, "Page"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task APageNotYetShownTakesTheFocusOnceItIs()
|
||||
{
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var focus = new PageFocus();
|
||||
var first = new System.Windows.Controls.Button { Content = "Add game" };
|
||||
var page = new StackPanel { Children = { first } };
|
||||
focus.Shown(page);
|
||||
focus.Request();
|
||||
var host = new FluentWindow { Content = page, Width = 300, Height = 300, ShowActivated = true, WindowStartupLocation = WindowStartupLocation.Manual, Left = -10000, Top = -10000 };
|
||||
host.Show();
|
||||
try
|
||||
{
|
||||
Visuals.Pump();
|
||||
return (Focused: Keyboard.FocusedElement, first);
|
||||
}
|
||||
finally
|
||||
{
|
||||
host.Close();
|
||||
}
|
||||
});
|
||||
|
||||
facts.Focused.Should().BeSameAs(facts.first);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A content dialog gives the keyboard back to the control that opened it — WPF UI 4.3.0's host stores the focused element
|
||||
/// when the dialog opens and focuses it again when it closes, so the App adds nothing; held here so an update that drops it
|
||||
/// goes red. (The dialog's own <c>finally</c>, which takes it out of its host, resumes on the dispatcher's context: without
|
||||
/// one, as on a bare test thread, the dialog stays in its host and the focus on its Close button.)
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public async Task AContentDialogGivesTheFocusBackToTheControlThatOpenedIt()
|
||||
{
|
||||
var facts = await PagesLoadTests.OnStaAsync(() => OnDispatcherContext(() =>
|
||||
{
|
||||
(FluentWindow window, Wpf.Ui.Controls.Button opener, ContentDialogService service) = Shell();
|
||||
try
|
||||
{
|
||||
_ = opener.Focus();
|
||||
Close(service.ShowAsync(new ContentDialog { Title = "T", Content = "Body", CloseButtonText = "Close" }, CancellationToken.None), service);
|
||||
return (Focused: Keyboard.FocusedElement, opener);
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
}));
|
||||
|
||||
facts.Focused.Should().BeSameAs(facts.opener);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AMessageBoxIsOwnedByTheAppsWindowItOpensOver()
|
||||
{
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var window = new FluentWindow { Width = 300, Height = 200, ShowActivated = true, WindowStartupLocation = WindowStartupLocation.Manual, Left = -10000, Top = -10000 };
|
||||
Window? main = System.Windows.Application.Current.MainWindow;
|
||||
window.Show();
|
||||
System.Windows.Application.Current.MainWindow = window;
|
||||
try
|
||||
{
|
||||
var box = new Wpf.Ui.Controls.MessageBox { Title = "T", Content = "C", CloseButtonText = "Close" };
|
||||
Window? before = box.Owner;
|
||||
MessageBoxes.Own(box);
|
||||
return (before, After: box.Owner, window);
|
||||
}
|
||||
finally
|
||||
{
|
||||
System.Windows.Application.Current.MainWindow = main;
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
|
||||
facts.before.Should().BeNull("WPF UI 4.3.0's message box sets no owner");
|
||||
facts.After.Should().BeSameAs(facts.window);
|
||||
}
|
||||
|
||||
/// <summary>Every message box the App shows goes through <see cref="MessageBoxes"/>: no other code shows one.</summary>
|
||||
[Fact]
|
||||
public void EveryMessageBoxGoesThroughMessageBoxes()
|
||||
{
|
||||
string app = Path.Combine(AccessibilityTests.RepoRoot(), "src", "FrameLedger.App");
|
||||
List<string> elsewhere = [.. Directory.EnumerateFiles(app, "*.cs", SearchOption.AllDirectories)
|
||||
.Where(static f => !f.Contains(Path.DirectorySeparatorChar + "obj" + Path.DirectorySeparatorChar, StringComparison.Ordinal)
|
||||
&& !f.EndsWith("MessageBoxes.cs", StringComparison.Ordinal))
|
||||
.Where(static f => BoxShown().IsMatch(File.ReadAllText(f)))
|
||||
.Select(f => Path.GetRelativePath(app, f))];
|
||||
|
||||
elsewhere.Should().BeEmpty("a box shown elsewhere has no owner, and can fall behind the window it came from");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The work under the STA thread's own dispatcher context: WPF UI's <c>ContentDialog.ShowAsync</c> clears its host in a
|
||||
/// <c>finally</c> after an await, which must resume on the dispatcher, as it does in the App.
|
||||
/// </summary>
|
||||
private static T OnDispatcherContext<T>(Func<T> work)
|
||||
{
|
||||
SynchronizationContext? previous = SynchronizationContext.Current;
|
||||
SynchronizationContext.SetSynchronizationContext(new System.Windows.Threading.DispatcherSynchronizationContext(System.Windows.Threading.Dispatcher.CurrentDispatcher));
|
||||
try
|
||||
{
|
||||
return work();
|
||||
}
|
||||
finally
|
||||
{
|
||||
SynchronizationContext.SetSynchronizationContext(previous);
|
||||
}
|
||||
}
|
||||
|
||||
private static (FluentWindow Window, Wpf.Ui.Controls.Button Opener, ContentDialogService Service) Shell()
|
||||
{
|
||||
var opener = new Wpf.Ui.Controls.Button { Content = "Open" };
|
||||
var host = new ContentDialogHost();
|
||||
var grid = new Grid();
|
||||
grid.Children.Add(new StackPanel { Children = { new Wpf.Ui.Controls.Button { Content = "Other" }, opener } });
|
||||
grid.Children.Add(host);
|
||||
var window = new FluentWindow { Content = grid, Width = 500, Height = 400, ShowActivated = true, WindowStartupLocation = WindowStartupLocation.Manual, Left = -10000, Top = -10000 };
|
||||
window.Show();
|
||||
Visuals.Pump();
|
||||
var service = new ContentDialogService();
|
||||
service.SetDialogHost(host);
|
||||
return (window, opener, service);
|
||||
}
|
||||
|
||||
// The dialog open, then closed with no answer, and the dispatcher run until its task has finished.
|
||||
private static void Close(Task<ContentDialogResult> shown, ContentDialogService service)
|
||||
{
|
||||
Visuals.Pump();
|
||||
(service.GetDialogHostEx()?.Content as ContentDialog)?.Hide(ContentDialogResult.None);
|
||||
for (int i = 0; i < 200 && !shown.IsCompleted; i++)
|
||||
{
|
||||
Visuals.Pump();
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
|
||||
shown.IsCompleted.Should().BeTrue("the dialog closed");
|
||||
Visuals.Pump();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user