Skip to content

Commit 03611c5

Browse files
sjvrensburgclaude
andcommitted
fix(freeze-panes): flyout matches toolbar width exactly
The flyout's width now tracks the toolbar's own border width (captured whenever the annotation tools aren't shown, since that's the toolbar's common/base width) instead of a fixed guess, applied to the FreezePanesView content each time it opens. The default FlyoutPresenter adds its own theme padding around content, so matching the content Width alone still rendered a slightly wider popup than the toolbar — zeroed via a FlyoutPresenter.noPad style class (FreezePanesView already supplies its own Margin, so nothing is lost) so the flyout's width now maps 1:1 to the toolbar's. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 846efe2 commit 03611c5

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

src/RailReader2/Views/FreezePanesView.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
x:Class="RailReader2.Views.FreezePanesView"
66
x:DataType="vm:MainWindowViewModel">
77
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
8-
<StackPanel Margin="8,6" Spacing="6" MinWidth="200">
8+
<StackPanel Name="RootPanel" Margin="8,6" Spacing="6" HorizontalAlignment="Stretch">
99
<TextBlock Text="Freeze panes" FontWeight="SemiBold" />
1010
<TextBlock Name="CaptionText"
11-
Text="Pin rows / columns in place while the rest of the page scrolls — works on any page."
11+
Text="Pin rows / columns in place while the rest of the page scrolls."
1212
TextWrapping="Wrap" Opacity="0.7" />
1313
<StackPanel Spacing="4">
1414
<ToggleButton Name="FreezeRowsButton"

src/RailReader2/Views/ToolBarView.axaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
<Setter Property="Margin" Value="3,2" />
1212
<Setter Property="Background" Value="{DynamicResource SystemControlForegroundBaseMediumLowBrush}" />
1313
</Style>
14+
<!-- The default FlyoutPresenter adds its own theme padding around content, so a content Width
15+
set to match the toolbar's width still renders a wider popup than the toolbar. Zeroed here
16+
(FreezePanesView supplies its own Margin) so the freeze flyout's Width maps 1:1 to what's
17+
actually on screen. -->
18+
<Style Selector="FlyoutPresenter.noPad">
19+
<Setter Property="Padding" Value="0" />
20+
</Style>
1421
</UserControl.Styles>
1522

1623
<Border Name="RootBorder"

src/RailReader2/Views/ToolBarView.axaml.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,24 @@ public ToolBarView()
6767
// with the toolbar's bottom-left edge, regardless of where the Freeze button sits in the row.
6868
// Button.Flyout would anchor to the button itself instead, so this is wired manually.
6969
_freezeFlyout.Placement = PlacementMode.BottomEdgeAlignedLeft;
70+
_freezeFlyout.FlyoutPresenterClasses.Add("noPad");
71+
// Track the toolbar's width whenever the annotation tools aren't shown (its "base" width — the
72+
// common case, since freeze is unrelated to annotation mode), so the flyout matches it exactly
73+
// even if opened while the annotation section happens to be expanded.
74+
RootBorder.LayoutUpdated += (_, _) =>
75+
{
76+
if (!AnnotationSection.IsVisible) _baseToolbarWidth = RootBorder.Bounds.Width;
77+
};
7078
FreezeButton.Click += (_, _) =>
7179
{
72-
if (_freezeFlyout.IsOpen) _freezeFlyout.Hide();
73-
else _freezeFlyout.ShowAt(RootBorder);
80+
if (_freezeFlyout.IsOpen) { _freezeFlyout.Hide(); return; }
81+
_freezeView.Width = _baseToolbarWidth > 0 ? _baseToolbarWidth : RootBorder.Bounds.Width;
82+
_freezeFlyout.ShowAt(RootBorder);
7483
};
7584
}
7685

86+
private double _baseToolbarWidth;
87+
7788
private void OnVmPropertyChanged(object? sender, PropertyChangedEventArgs args)
7889
{
7990
switch (args.PropertyName)

0 commit comments

Comments
 (0)