Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 7fc717892b fix(app): hide scroll bars reaches every scroller - a ScrollChanged class handler beside Loaded (beta.17 PR-2)
The owner's screenshot of 0.1.0-beta.16 (2026-10-07): with Settings > Window > Hide scroll bars on, the Dashboard still
drew its scroll bar while Settings did not.

Cause, read in dotnet/wpf: BroadcastEventHelper.OnBroadcastCallback raises Loaded only on elements whose
SubtreeHasLoadedChangeHandler is set, and FrameworkElement.ThisHasLoadedChangeEventHandler counts instance handlers,
style EventSetters, template triggers and FEF handlers - not EventManager class handlers. ScrollBarHiding (beta.14)
had one class handler on ScrollViewer.Loaded, plus a walk of the open windows when the toggle changes; the flag is
applied before the first window, so the walk never helped at start-up. WPF UI 4.3.0's ToggleSwitch, CheckBox and
ProgressRing templates carry a Loaded EventTrigger, so Settings' scroller loaded and was hidden; the Dashboard (cards,
text, borders) never loaded as far as the option knew.

- Services/ScrollBarHiding: a class handler on ScrollViewer.ScrollChangedEvent (handledEventsToo), calling the same
  idempotent Set. Every scroller raises it from its first layout, inside ContextLayoutManager.UpdateLayout, so the
  bar is gone before the first frame; the Loaded handler stays. Doc comment and App.xaml.cs comment corrected.
- ScrollBarHidingTests.AScrollerLaidOutWithNoLoadedEventIsHidden: red before (Auto).
- ScrollBarHidingTests.EverySurfaceShownWithTheOptionOnDrawsNoBar: every page navigated in WPF UI's presenter, the
  first run, About, the user guide, a session's summary and every dialog's content, each shown in a real window off
  the screen with the option on first. Red before: the Dashboard's ScrollViewer, Game detail's sessions DataGrid
  (horizontal), the first run's ListBox and MarkdownView, About's ScrollViewer, the user guide's ListBox and
  MarkdownView. Settings and Logs were already hidden (the control); the check requires Dashboard, Settings, Logs and
  the user guide to have something to scroll.
- ScrollBarHidingTests.WpfRaisesLoadedOnlyWhereASubtreeListensForIt: the harness against WPF - a scroller with its own
  Loaded class handler is not called holding a Border, and is holding a CheckBox.
- Docs: 08_UI §Settings (the false "reaches every scroller" struck and dated), 16_WPFUI_SYNTAX §Gotchas (a class
  handler on Loaded is not a load hook), 14_TESTING, CHANGELOG [Unreleased].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 16:26:13 +07:00
7 changed files with 238 additions and 12 deletions

No files matched your search

+4
View File
@@ -34,6 +34,10 @@ numeric core and does not move; the heading is the full version — corrected 20
page in view — Settings above all, where the theme is chosen — kept the old theme's colour: light grey on white, or dark
grey on dark. Every such text now follows the switch, on every page, window and dialog (`08_UI` §Contrast,
`16_WPFUI_SYNTAX` §Gotchas).
- **Hide scroll bars hides every scroll bar.** With Settings ▸ Window ▸ Hide scroll bars on, the Dashboard still drew its
scroll bar — and so did the first run, About, the user guide and a game's wide sessions table; only screens with a
switch or a tick box on them lost theirs. Every scroller follows the option now, and still scrolls with the wheel, the
keyboard and touch (`08_UI` §Settings, `16_WPFUI_SYNTAX` §Gotchas).
## [0.1.0-beta.16] - 2026-10-06
+10 -4
View File
@@ -604,13 +604,19 @@ Tail view of `ui-*.log` / `agent-*.log` (toggle), level filter, search (`ui:Auto
### Settings
> **beta.14 (owner request 2026-10-05: "an option to hide the scroll bars but still scroll").** The Window section has
> **Hide scroll bars** (`ui.hide_scrollbars`, off by default). A bar's visibility is bound inside its scroller's template,
> which no style reaches, so `Services.ScrollBarHiding` sets the scrollers themselves: one class handler on
> `ScrollViewer`'s Loaded (registered at start beside `DialogKeyboard`) reaches every scroller the App shows, those inside a
> DataGrid, a TextBox, a rendered document and a dialog included. While on, an axis that is `Auto` or `Visible` becomes
> which no style reaches, so `Services.ScrollBarHiding` sets the scrollers themselves: ~~one class handler on
> `ScrollViewer`'s Loaded (registered at start beside `DialogKeyboard`) reaches every scroller the App shows~~ class
> handlers on `ScrollViewer`'s ScrollChanged and Loaded (registered at start beside `DialogKeyboard`) reach every scroller
> the App shows *(corrected 2026-10-07, beta.17, the owner's screenshot of the Dashboard with its bar: WPF raises Loaded
> only where a subtree listens for it with a handler of its own, and a class handler is not one — `16_WPFUI_SYNTAX`
> §Gotchas. Settings, full of toggle switches whose template listens, lost its bar; the Dashboard, the first run, About,
> the user guide and a game's wide sessions table kept theirs. Every scroller raises ScrollChanged from its first layout)*,
> those inside a DataGrid, a TextBox, a rendered document and a dialog included. While on, an axis that is `Auto` or `Visible` becomes
> `Hidden` — WPF's "no bar, still scrolls": wheel, keyboard and touch — and its own value is kept on it; a `Disabled` axis is
> never touched (it lays its content out at the viewport's width). The toggle applies to the open windows at once, and off
> puts every kept value back. Tests: `ScrollBarHidingTests` (on hides every bar and the wheel still scrolls; off restores
> each; a scroller that loads later follows), `SettingsViewModelTests.HidingScrollBars…`.
> each; a scroller that loads later follows; since beta.17 a scroller laid out with no Loaded at all, and every page,
> window and dialog shown in a real window with the option on), `SettingsViewModelTests.HidingScrollBars…`.
> **beta.11 (owner request 2026-10-03: "remove the Settings rows that have no button or similar").** Every row has a control
> now: the *Games with hooking on* card shows only while a game has hooking on (its empty sentence is gone); the *Elevation*
+7
View File
@@ -71,6 +71,13 @@ under the new theme. `PagesLoadTests.Surfaces` builds every page, window and dia
any check that wants all of them. Colours are compared and texts only reported: another test class may change
`Strings.Culture` between the two builds.
**Loaded needs a shown window, and even then it is not raised everywhere (beta.17).** A tree laid out by hand never raises
Loaded, and a shown one raises it only where a subtree listens for it (`16_WPFUI_SYNTAX` §Gotchas) — so a test that calls
`RaiseEvent(Loaded)` proves a handler, never that WPF reaches it. `ScrollBarHidingTests.EverySurfaceShownWithTheOptionOnDrawsNoBar`
shows each surface in a real window, off the screen and never activated, with the option on before anything is built as
at start-up; `WpfRaisesLoadedOnlyWhereASubtreeListensForIt` checks the harness against WPF itself (a scroller holding a
Border is never loaded, one holding a CheckBox is), on CI too.
**A test that sends input must also say which keys are held.** `Keyboard.Modifiers` is the machine's real keyboard, read
from any thread (a fresh background thread's `GetKeyState` reports the machine's NumLock — measured 2026-10-06), so a
wheel test that read it held whatever key a person pressed while the gate ran: `ChartWheelTests`' plain half went red once
+11 -1
View File
@@ -254,7 +254,17 @@ On startup and on `ApplicationThemeManager.Changed`: for every live plot set fig
- [ ] **A scroll bar's visibility is bound inside its scroller's template** (`ComputedVerticalScrollBarVisibility`), so a style
on `ScrollBar` or `ui:DynamicScrollBar` cannot hide it. Set the scroller's own `ScrollBarVisibility` to `Hidden` — no
bar, and the wheel, the keyboard and touch still scroll (`ui:PassiveScrollViewer` treats only `Disabled` as "cannot
scroll") — as `Services.ScrollBarHiding` does for `ui.hide_scrollbars` (beta.14).
scroll") — as `Services.ScrollBarHiding` does for `ui.hide_scrollbars` (beta.14), reaching each scroller from a class
handler on `ScrollChanged` since beta.17 rather than from `Loaded` alone (next item).
- [ ] **A class handler on `Loaded` is not a load hook.** WPF raises Loaded only on an element whose subtree listens for it
with a handler of its own — an instance handler, a style's `EventSetter`, a template's trigger
(`BroadcastEventHelper.OnBroadcastCallback` walks only into `SubtreeHasLoadedChangeHandler`;
`FrameworkElement.ThisHasLoadedChangeEventHandler`) — and `EventManager.RegisterClassHandler` counts as none of them.
WPF UI 4.3.0's `ToggleSwitch`, `CheckBox` and `ProgressRing` templates carry a Loaded trigger, so a scroller over those
loads and a scroller over plain cards and text never does: `ScrollBarHiding` hid Settings' bar and not the Dashboard's
(beta.17). To reach every instance, hook an event the element raises itself — a scroller's `ScrollChanged` comes from its
first layout. `ScrollBarHidingTests.WpfRaisesLoadedOnlyWhereASubtreeListensForIt` keeps the behaviour visible, and a test
that raises Loaded with `RaiseEvent` proves the handler, never that it is reached.
- [ ] **No dialog in 4.3.0 closes on Esc.** Neither `ContentDialog.cs` nor `MessageBox.cs` at the 4.3.0 tag handles a
key (read 2026-09-15), and `ContentDialog.CloseButtonText` DEFAULTS to "Close" — an empty string is how a dialog
says it has no Close button. `MessageBox.Close()` is `[Obsolete("Use Close with MessageBoxResult instead")]` while no
+2 -1
View File
@@ -77,7 +77,8 @@ public partial class App : System.Windows.Application
HookCrashHandlers();
// 08_UI §Accessibility (P4 PR-8): Esc closes the open ContentDialog or MessageBox, before any window exists.
DialogKeyboard.Register();
// beta.14: ui.hide_scrollbars reaches every scroller as it loads, those in a control's template too.
// beta.14: ui.hide_scrollbars reaches every scroller as it is laid out (beta.17: not only as it loads), those in a
// control's template too.
ScrollBarHiding.Register();
_run = DiagReport.Requested(e.Args) ? DiagAsync() : RunAsync();
}
@@ -10,13 +10,22 @@ namespace FrameLedger.App.Services;
/// <summary>
/// <c>ui.hide_scrollbars</c> (beta.14, owner request 2026-10-05): the App draws no scroll bars, and every scroller still
/// scrolls — with the wheel, the keyboard and touch. A bar's visibility is bound in its scroller's template, so no style can
/// reach it; this sets the scroller's own <see cref="ScrollBarVisibility"/> instead. One class handler on
/// <see cref="ScrollViewer"/>'s <c>Loaded</c>, registered at start beside <see cref="DialogKeyboard"/>, sees every scroller the
/// App shows, those inside a control's template too (a DataGrid's, a TextBox's, a rendered document's, a dialog's). While
/// on, an axis whose bar is <see cref="ScrollBarVisibility.Auto"/> or <see cref="ScrollBarVisibility.Visible"/> becomes
/// reach it; this sets the scroller's own <see cref="ScrollBarVisibility"/> instead, from two class handlers on
/// <see cref="ScrollViewer"/> registered at start beside <see cref="DialogKeyboard"/>, which reach every scroller the App shows,
/// those inside a control's template too (a DataGrid's, a TextBox's, a rendered document's, a dialog's):
/// <list type="bullet">
/// <item><c>ScrollChanged</c>, which every scroller raises from its first layout, when its extent and viewport stop being
/// zero, and again whenever they change — inside the layout pass, so the bar is gone before the first frame is drawn.</item>
/// <item><c>Loaded</c>, which beta.14 relied on alone, wrongly (beta.17, the owner's screenshot: the Dashboard kept its bar).
/// WPF raises Loaded only on an element whose subtree listens for it with a handler of its own — an instance handler, a
/// style's EventSetter, a template's trigger — and a class handler is none of those; WPF UI's toggle switches carry one,
/// so Settings was hidden and the Dashboard, all cards and text, never was. It stays for a scroller that comes back with
/// nothing to lay out again.</item>
/// </list>
/// While on, an axis whose bar is <see cref="ScrollBarVisibility.Auto"/> or <see cref="ScrollBarVisibility.Visible"/> becomes
/// <see cref="ScrollBarVisibility.Hidden"/> — WPF's "no bar, still scrolls" — and its own value is remembered on it;
/// <see cref="ScrollBarVisibility.Disabled"/> is never touched, because a disabled axis lays its content out at the viewport's
/// size and wraps text. Off puts every remembered value back, on screen at once and on the next load for the rest.
/// size and wraps text. Off puts every remembered value back, on screen at once and at the next layout for the rest.
/// </summary>
public static class ScrollBarHiding
{
@@ -32,11 +41,12 @@ public static class ScrollBarHiding
/// <summary>Whether the bars are hidden right now.</summary>
public static bool Hidden => _hidden;
/// <summary>Registers the class handler, once per process.</summary>
/// <summary>Registers the class handlers, once per process.</summary>
public static void Register()
{
if (Interlocked.Exchange(ref _registered, 1) == 0)
{
EventManager.RegisterClassHandler(typeof(ScrollViewer), ScrollViewer.ScrollChangedEvent, new ScrollChangedEventHandler(OnScrollChanged), handledEventsToo: true);
EventManager.RegisterClassHandler(typeof(ScrollViewer), FrameworkElement.LoadedEvent, new RoutedEventHandler(OnLoaded), handledEventsToo: true);
}
}
@@ -96,6 +106,15 @@ public static class ScrollBarHiding
}
}
// ScrollChanged bubbles: a scroller's ancestors that are scrollers hear it too, and each gets the same idempotent check.
private static void OnScrollChanged(object sender, ScrollChangedEventArgs e)
{
if (sender is ScrollViewer viewer)
{
Set(viewer);
}
}
private static void Set(ScrollViewer viewer)
{
Axis(viewer, ScrollViewer.VerticalScrollBarVisibilityProperty, _ownVerticalProperty);
@@ -1,11 +1,13 @@
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using FluentAssertions;
using FrameLedger.App.Pages;
using FrameLedger.App.Services;
namespace FrameLedger.App.Tests;
@@ -128,4 +130,181 @@ public sealed class ScrollBarHidingTests
result.FirstAfterOff.Should().Be(ScrollBarVisibility.Auto, "and gives it back its own setting on its next load after off");
result.LoadedAfterOff.Should().Be(ScrollBarVisibility.Visible, "a scroller the option never touched keeps what it has");
}
/// <summary>
/// beta.17 (the owner's screenshot of 2026-10-07: the Dashboard kept its bar with the option on). WPF raises Loaded only on
/// an element whose subtree listens for it with a handler of its own — an instance handler, a style's EventSetter or a
/// template's trigger (<c>BroadcastEventHelper</c>, <c>FrameworkElement.ThisHasLoadedChangeEventHandler</c>) — and a
/// class handler is none of those, so a scroller over plain cards and text never loaded as far as the option knew. Laid
/// out with no Loaded at all, a scroller must be hidden all the same.
/// </summary>
[Fact]
public async Task AScrollerLaidOutWithNoLoadedEventIsHidden()
{
(ScrollBarVisibility Axis, Visibility Bar, double Scrollable) result = await PagesLoadTests.OnStaAsync(() =>
{
ScrollBarHiding.Register();
try
{
ScrollBarHiding.Apply(true);
var viewer = new ScrollViewer { Height = 120, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, Content = new Border { Height = 600 } };
Visuals.Layout(viewer, 300, 120);
return (viewer.VerticalScrollBarVisibility, viewer.ComputedVerticalScrollBarVisibility, viewer.ScrollableHeight);
}
finally
{
ScrollBarHiding.Apply(false);
}
});
result.Scrollable.Should().BeGreaterThan(0, "the scroller has something to scroll");
result.Axis.Should().Be(ScrollBarVisibility.Hidden, "the option reaches a scroller when it is laid out, Loaded or not");
result.Bar.Should().NotBe(Visibility.Visible);
}
/// <summary>
/// The option as the owner has it: on at start-up (<c>App.RunAsync</c> applies it before the first window), then every
/// surface shown in a real window off the screen — each page navigated in WPF UI's presenter as the shell does, the
/// secondary windows, the first run, every dialog's content. No scroller that has something to scroll draws a bar. Before
/// beta.17 Settings passed (its toggle switches' template has a Loaded trigger, so its scroller loaded) and the Dashboard
/// did not; Settings and the Dashboard must both be scrollable here, or the check proves nothing.
/// </summary>
[Fact]
public async Task EverySurfaceShownWithTheOptionOnDrawsNoBar()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
using PagesLoadTests.Surfaces surfaces = await PagesLoadTests.Surfaces.LoadAsync(s);
(List<string> Bars, HashSet<string> Scrollable) result = await PagesLoadTests.OnStaAsync(() =>
{
ScrollBarHiding.Register();
ScrollBarHiding.Apply(true);
try
{
var bars = new List<string>();
var scrollable = new HashSet<string>(StringComparer.Ordinal);
foreach ((string name, Func<FrameworkElement> build) in surfaces.Pages())
{
Sweep(name, () => InPresenter(build()), bars, scrollable);
}
foreach ((string name, Func<FrameworkElement> build) in surfaces.Windows().Concat(surfaces.Dialogs()))
{
Sweep(name, build, bars, scrollable);
}
return (bars, scrollable);
}
finally
{
ScrollBarHiding.Apply(false);
}
});
result.Scrollable.Should().Contain(["Dashboard", "Settings", "Logs", "User guide"], "the check is vacuous unless those scroll in a window this small");
string.Join(Environment.NewLine, result.Bars).Should().BeEmpty("ui.hide_scrollbars: no scroller the App shows draws a bar, and the wheel still scrolls it");
}
/// <summary>
/// The harness against WPF itself: a scroller of our own with a Loaded class handler, shown in a real window, is never
/// called while it holds only a Border, and is called once it holds a CheckBox, whose template listens for Loaded. If the
/// first half fails, WPF raises Loaded everywhere and the reason above is gone; if the second fails, the harness does not
/// deliver Loaded and <see cref="EverySurfaceShownWithTheOptionOnDrawsNoBar"/> could not tell Settings from the Dashboard.
/// </summary>
[Fact]
public async Task WpfRaisesLoadedOnlyWhereASubtreeListensForIt()
{
(int WithBorder, int WithCheckBox) loads = await PagesLoadTests.OnStaAsync(() =>
(LoadsOfAProbeHolding(new Border { Height = 40 }), LoadsOfAProbeHolding(new CheckBox { Content = "listens" })));
loads.WithBorder.Should().Be(0, "a class handler does not put an element on WPF's Loaded route");
loads.WithCheckBox.Should().BeGreaterThan(0, "WPF UI's CheckBox template has a Loaded trigger, which does");
}
private sealed class ProbeScrollViewer : ScrollViewer
{
static ProbeScrollViewer() => EventManager.RegisterClassHandler(typeof(ProbeScrollViewer), LoadedEvent, new RoutedEventHandler(static (_, _) => Loads++), handledEventsToo: true);
public static int Loads { get; private set; }
}
private static int LoadsOfAProbeHolding(UIElement content)
{
var probe = new ProbeScrollViewer { Content = content };
int before = ProbeScrollViewer.Loads;
Window window = OffScreen(new Window { Content = probe });
try
{
window.Show();
Visuals.Pump();
return ProbeScrollViewer.Loads - before;
}
finally
{
window.Close();
}
}
/// <summary>A page navigated in WPF UI's presenter, as the shell's NavigationView hosts it.</summary>
private static Grid InPresenter(FrameworkElement page)
{
var presenter = new Wpf.Ui.Controls.NavigationViewContentPresenter();
_ = presenter.Navigate(page);
return new Grid { Children = { presenter } };
}
/// <summary>
/// Shows the surface in a real window off the screen, lets WPF load and lay it out, and notes every scroller that has
/// something to scroll and every one of those that draws a bar.
/// </summary>
private static void Sweep(string name, Func<FrameworkElement> build, List<string> bars, HashSet<string> scrollable)
{
FrameworkElement built = build();
Window window = OffScreen(built as Window ?? new Window { Content = built });
try
{
window.Show();
Visuals.Pump();
if (Visuals.Find<LogsPage>(window) is { } logs)
{
// The tail is empty in a scratch folder; fill it as a log file would.
logs.Tail.Text = string.Join(Environment.NewLine, Enumerable.Range(1, 200).Select(static i => "line " + i.ToString(CultureInfo.InvariantCulture)));
Visuals.Pump();
}
foreach (ScrollViewer viewer in Visuals.FindAll<ScrollViewer>(window))
{
bool vertical = viewer.ScrollableHeight > 0.5;
bool horizontal = viewer.ScrollableWidth > 0.5;
if (vertical || horizontal)
{
_ = scrollable.Add(name);
}
if ((vertical && viewer.ComputedVerticalScrollBarVisibility == Visibility.Visible)
|| (horizontal && viewer.ComputedHorizontalScrollBarVisibility == Visibility.Visible))
{
bars.Add(string.Create(CultureInfo.InvariantCulture,
$"{name}: {(viewer.TemplatedParent ?? viewer).GetType().Name} draws a bar ({viewer.ScrollableWidth:0} x {viewer.ScrollableHeight:0} to scroll)"));
}
}
}
finally
{
window.Close();
}
}
/// <summary>A window shown where nobody sees it and never activated, small enough that the surfaces overflow it.</summary>
private static Window OffScreen(Window window)
{
window.Width = 1000;
window.Height = 420;
window.WindowStartupLocation = WindowStartupLocation.Manual;
window.Left = -20000;
window.Top = -20000;
window.ShowActivated = false;
window.ShowInTaskbar = false;
return window;
}
}