fix(app): captures render RTL windows as they are; the rail's check binds one way
- As the Uploader and Setup captures now do: the content of a right-to-left window already renders mirrored, so no second flip. - The rail's buttons share a GroupName across its two lists; their check binds one way, so a window not yet on screen cannot write another's selection back into the shell. - The Arabic smoke test also checks that the rail is drawn on the right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
3 files changed
+9
-19
No files matched your search
@@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
<!-- Navigation rail: full names, collapsible to icons (BRIEF §12.1). Expanded it is at least 128 px and grows with
|
<!-- Navigation rail: full names, collapsible to icons (BRIEF §12.1). Expanded it is at least 128 px and grows with
|
||||||
the longest label of the language (up to 200 px); collapsed it is 48 px of icons. While the first-run dialog is
|
the longest label of the language (up to 200 px); collapsed it is 48 px of icons. While the first-run dialog is
|
||||||
open the shell behind it takes no input. -->
|
open the shell behind it takes no input. The buttons of both lists form one group (GroupName); their check
|
||||||
|
binds one way, the section the shell navigates to (a GroupName spans every window not yet on screen). -->
|
||||||
<Border x:Name="Rail" Background="{DynamicResource Brush.Chrome}" ui:NavRail.IsCollapsed="{Binding IsRailCollapsed}"
|
<Border x:Name="Rail" Background="{DynamicResource Brush.Chrome}" ui:NavRail.IsCollapsed="{Binding IsRailCollapsed}"
|
||||||
IsEnabled="{Binding IsShellEnabled}">
|
IsEnabled="{Binding IsShellEnabled}">
|
||||||
<Border.Style>
|
<Border.Style>
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
|
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
|
||||||
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
|
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
|
||||||
IsChecked="{Binding IsSelected}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
|
IsChecked="{Binding IsSelected, Mode=OneWay}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
|
||||||
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
|
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
@@ -49,7 +50,7 @@
|
|||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
|
<DataTemplate DataType="{x:Type shell:SectionViewModel}">
|
||||||
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
|
<ui:NavRailButton GroupName="Rail" Glyph="{Binding Glyph}" Content="{Binding Label}" Badge="{Binding Badge}"
|
||||||
IsChecked="{Binding IsSelected}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
|
IsChecked="{Binding IsSelected, Mode=OneWay}" ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Label}"
|
||||||
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
|
Command="{Binding DataContext.NavigateCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}" CommandParameter="{Binding}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
|
|||||||
@@ -321,25 +321,12 @@ public static class ScreenCapture
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
|
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
|
||||||
bitmap.Render(window.FlowDirection == FlowDirection.RightToLeft ? Mirrored(root) : root);
|
// A right-to-left window's content already renders mirrored, as on screen.
|
||||||
|
bitmap.Render(root);
|
||||||
var encoder = new PngBitmapEncoder();
|
var encoder = new PngBitmapEncoder();
|
||||||
encoder.Frames.Add(BitmapFrame.Create(bitmap));
|
encoder.Frames.Add(BitmapFrame.Create(bitmap));
|
||||||
using var stream = File.Create(path);
|
using var stream = File.Create(path);
|
||||||
encoder.Save(stream);
|
encoder.Save(stream);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A right-to-left window is mirrored by a transform on the window itself, which rendering its content alone
|
|
||||||
/// would leave out (mirrored glyphs, left-to-right layout): draw the content through that mirror.
|
|
||||||
/// </summary>
|
|
||||||
private static DrawingVisual Mirrored(FrameworkElement root)
|
|
||||||
{
|
|
||||||
var size = new Rect(0, 0, root.ActualWidth, root.ActualHeight);
|
|
||||||
var visual = new DrawingVisual();
|
|
||||||
using var dc = visual.RenderOpen();
|
|
||||||
dc.PushTransform(new MatrixTransform(-1, 0, 0, 1, size.Width, 0));
|
|
||||||
dc.DrawRectangle(new VisualBrush(root) { Stretch = Stretch.Fill, ViewboxUnits = BrushMappingMode.Absolute, Viewbox = size }, null, size);
|
|
||||||
return visual;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -138,7 +138,9 @@ public sealed class ScreenSmokeTests
|
|||||||
var window = app.Window;
|
var window = app.Window;
|
||||||
Assert.Equal(FlowDirection.RightToLeft, window.FlowDirection, "the main window opens mirrored");
|
Assert.Equal(FlowDirection.RightToLeft, window.FlowDirection, "the main window opens mirrored");
|
||||||
var rail = (FrameworkElement)window.FindName("Rail");
|
var rail = (FrameworkElement)window.FindName("Rail");
|
||||||
Assert.Equal(FlowDirection.RightToLeft, rail.FlowDirection, "the rail mirrors with the window (it starts on the right)");
|
Assert.Equal(FlowDirection.RightToLeft, rail.FlowDirection, "the rail mirrors with the window");
|
||||||
|
// The window's content carries the mirror (a capture of it alone reads right to left, as on screen).
|
||||||
|
Assert.Greater(rail.TranslatePoint(new Point(rail.ActualWidth / 2, 0), window).X, window.ActualWidth / 2, "the rail starts on the right");
|
||||||
|
|
||||||
// The first-run dialog keeps the shell behind it out of reach.
|
// The first-run dialog keeps the shell behind it out of reach.
|
||||||
Assert.True(app.Shell.IsWelcomeOpen);
|
Assert.True(app.Shell.IsWelcomeOpen);
|
||||||
|
|||||||
Reference in new issue
Block a user