diff --git a/docs/ui/DESIGN.md b/docs/ui/DESIGN.md index 6bcfbea5..fbced7ab 100644 --- a/docs/ui/DESIGN.md +++ b/docs/ui/DESIGN.md @@ -84,7 +84,12 @@ Label column left of controls: 116 px in panels, 180 px in Settings. 16 px, 1.5 px strokes, round caps and joins, `currentColor`, drawn as `PathGeometry` / `DrawingImage` resources in `Titano.App/Icons/Icons.xaml` (source SVGs in `branding/ui-icons/` if generated by a tool). No icon fonts, no emoji in shipped UI (the mockups use a few glyphs -only as placeholders: replace ⟳ ▾ ✕ ■ ❚❚ ≡ with drawn icons). Directional icons mirror in RTL. +only as placeholders: replace ⟳ ▾ ✕ ■ ❚❚ ≡ with drawn icons). Directional icons mirror in RTL: +`IconData.IsDirectional` marks the glyphs that point along the reading direction (back/forward, chevrons +left/right, external link, start-aligned lines); `ui:Bidi.IsDirectional` overrides it for a subtree (a ▶ used +as "next", a chevron on a left-to-right time axis). Every other glyph (clocks, media controls, the ▶ rendered +status) and the brand mark keep their drawn orientation. Photos, previews, charts, numbers, paths and +templates are left-to-right islands (`FlowDirection="LeftToRight"` on the smallest element holding them). ## 6. App icon (`branding/`) diff --git a/src/Titano.App/Shell/ScreenCapture.cs b/src/Titano.App/Shell/ScreenCapture.cs index 614afbf3..3ca5ecbb 100644 --- a/src/Titano.App/Shell/ScreenCapture.cs +++ b/src/Titano.App/Shell/ScreenCapture.cs @@ -321,11 +321,25 @@ public static class ScreenCapture return false; } var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32); - bitmap.Render(root); + bitmap.Render(window.FlowDirection == FlowDirection.RightToLeft ? Mirrored(root) : root); var encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmap)); using var stream = File.Create(path); encoder.Save(stream); return true; } + + /// + /// 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. + /// + 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; + } } diff --git a/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs b/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs index 8fe4619b..277be4ad 100644 --- a/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs +++ b/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs @@ -1,4 +1,9 @@ using System.Windows; +using System.Windows.Automation; +using System.Windows.Automation.Peers; +using System.Windows.Automation.Provider; +using System.Windows.Controls; +using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Threading; @@ -8,8 +13,10 @@ using Titano.App.Sections; using Titano.App.Server; using Titano.App.Settings; using Titano.App.Shell; +using Titano.Core.Localization; using Titano.Testing; using Titano.Ui.Controls; +using Titano.Ui.Mvvm; using Titano.Ui.Theming; using Titano.Ui.Visuals; @@ -121,6 +128,108 @@ public sealed class ScreenSmokeTests Assert.Equal(english, app.Shell.Library.Title); }); + [Test] + public Task ArabicMirrorsTheShellFromStartButNotItsPicturesOrLogo() => ScreenHost.RunAsync(async () => + { + // The language is applied before the window exists, as at start-up with Arabic saved in the settings. + await using var app = await SampleApp.StartAsync("ar"); + try + { + var window = app.Window; + Assert.Equal(FlowDirection.RightToLeft, window.FlowDirection, "the main window opens mirrored"); + var rail = (FrameworkElement)window.FindName("Rail"); + Assert.Equal(FlowDirection.RightToLeft, rail.FlowDirection, "the rail mirrors with the window (it starts on the right)"); + + // The first-run dialog keeps the shell behind it out of reach. + Assert.True(app.Shell.IsWelcomeOpen); + Assert.False(rail.IsEnabled, "the rail behind the first-run dialog takes no input"); + app.Shell.CompleteWelcome(); + Assert.True(rail.IsEnabled); + + var id = await app.Sample.FillEditorAsync(); + app.Shell.OpenSequence(id); + await app.Shell.Sequence.OpenAsync(id); + var editor = Assert.NotNull(app.Shell.Sequence.Editor); + Assert.True(await editor.WhenIdleAsync(TimeSpan.FromSeconds(60)), "the editor settled"); + await app.ExpectAsync("sequence-ar"); + + // Directional glyphs follow the reading direction; the others, the logo, the picture and the charts do not. + var back = Assert.NotNull(app.FindAll