mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 06:55:59 +01:00
fix: nothing under the mouse is silent: dividers, previews, class pictures, categories
A page swept point by point left a few places a reader heard nothing: the panel dividers, the vehicle preview in the depot and the texture base, the picture by a vehicle class and the empty part of the settings categories. Each now has a name; a picture with a caption beside it reads as the caption. The tests that build controls run one after another: a control belongs to the thread that made the first one, and side by side they now and then failed.
This commit is contained in:
@@ -6,6 +6,7 @@ using StarterNG.Controls;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class AnnouncerTests
|
public class AnnouncerTests
|
||||||
{
|
{
|
||||||
private DateTime _now = new(2026, 11, 15, 12, 0, 0, DateTimeKind.Utc);
|
private DateTime _now = new(2026, 11, 15, 12, 0, 0, DateTimeKind.Utc);
|
||||||
@@ -81,6 +82,7 @@ public class AnnouncerTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class NamedGroupTests
|
public class NamedGroupTests
|
||||||
{
|
{
|
||||||
static NamedGroupTests() => ScreenReaderNames.Install();
|
static NamedGroupTests() => ScreenReaderNames.Install();
|
||||||
|
|||||||
11
StarterNG.Tests/AvaloniaControls.cs
Normal file
11
StarterNG.Tests/AvaloniaControls.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that build Avalonia controls run one after another: a control belongs to the
|
||||||
|
/// thread that made the first one, and run side by side they now and then failed.
|
||||||
|
/// </summary>
|
||||||
|
[CollectionDefinition(Name)]
|
||||||
|
public sealed class AvaloniaControls
|
||||||
|
{
|
||||||
|
public const string Name = "Avalonia controls";
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ using StarterNG.Controls;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class ExpandableTreeViewItemTests
|
public class ExpandableTreeViewItemTests
|
||||||
{
|
{
|
||||||
private static IExpandCollapseProvider Peer(ExpandableTreeViewItem item) =>
|
private static IExpandCollapseProvider Peer(ExpandableTreeViewItem item) =>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using StarterNG.Controls;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class FieldLabelTests
|
public class FieldLabelTests
|
||||||
{
|
{
|
||||||
static FieldLabelTests() => ScreenReaderNames.Install();
|
static FieldLabelTests() => ScreenReaderNames.Install();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using StarterNG.Controls;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class KeyboardFocusTests
|
public class KeyboardFocusTests
|
||||||
{
|
{
|
||||||
private readonly Button _window = new();
|
private readonly Button _window = new();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using StarterNG.Infrastructure;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class MouseReadingTests
|
public class MouseReadingTests
|
||||||
{
|
{
|
||||||
static MouseReadingTests() => ScreenReaderNames.Install();
|
static MouseReadingTests() => ScreenReaderNames.Install();
|
||||||
@@ -20,6 +21,18 @@ public class MouseReadingTests
|
|||||||
Assert.Same(button, AutomationProperties.GetLabeledBy(logo));
|
Assert.Same(button, AutomationProperties.GetLabeledBy(logo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void A_picture_beside_a_caption_is_read_as_the_caption()
|
||||||
|
{
|
||||||
|
var mini = new Image();
|
||||||
|
var caption = new TextBlock { Text = "EU07" };
|
||||||
|
_ = new StackPanel { Children = { mini, new TextBlock { IsVisible = false, Text = "ukryte" }, caption } };
|
||||||
|
|
||||||
|
ScreenReaderNames.NamePicture(mini);
|
||||||
|
|
||||||
|
Assert.Same(caption, AutomationProperties.GetLabeledBy(mini));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void A_picture_in_a_card_is_read_as_the_card_tooltip()
|
public void A_picture_in_a_card_is_read_as_the_card_tooltip()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using StarterNG.Controls;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class ReadableSliderTests
|
public class ReadableSliderTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using StarterNG.Controls;
|
|||||||
|
|
||||||
namespace StarterNG.Tests;
|
namespace StarterNG.Tests;
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class ScreenReaderNamesTests
|
public class ScreenReaderNamesTests
|
||||||
{
|
{
|
||||||
static ScreenReaderNamesTests() => ScreenReaderNames.Install();
|
static ScreenReaderNamesTests() => ScreenReaderNames.Install();
|
||||||
@@ -188,6 +189,7 @@ public class ScreenReaderNamesTests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Collection(AvaloniaControls.Name)]
|
||||||
public class PickerNameTests
|
public class PickerNameTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public static class ScreenReaderNames
|
|||||||
private const int PictureReach = 3;
|
private const int PictureReach = 3;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Names a picture after the button or card it lies in. Under the mouse a reader
|
/// Names a picture after the caption beside it or the button or card it lies in. Under the mouse a reader
|
||||||
/// hears what lies there, and a bare picture said nothing: a vehicle in the consist,
|
/// hears what lies there, and a bare picture said nothing: a vehicle in the consist,
|
||||||
/// the logo, an icon on a button.
|
/// the logo, an icon on a button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -176,6 +176,14 @@ public static class ScreenReaderNames
|
|||||||
|| AutomationProperties.GetLabeledBy(picture) is not null)
|
|| AutomationProperties.GetLabeledBy(picture) is not null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// A caption beside it says what it shows, such as a vehicle class by its picture.
|
||||||
|
if (picture.Parent is Panel row
|
||||||
|
&& row.Children.OfType<TextBlock>().FirstOrDefault(t => t.IsVisible && !string.IsNullOrWhiteSpace(t.Text)) is { } caption)
|
||||||
|
{
|
||||||
|
AutomationProperties.SetLabeledBy(picture, caption);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var holder = picture.Parent as Control;
|
var holder = picture.Parent as Control;
|
||||||
for (int i = 0; i < PictureReach && holder is not null; i++, holder = holder.Parent as Control)
|
for (int i = 0; i < PictureReach && holder is not null; i++, holder = holder.Parent as Control)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Automation;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Templates;
|
using Avalonia.Controls.Templates;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
@@ -338,6 +339,7 @@ public sealed class VehicleBrowser
|
|||||||
|
|
||||||
Selected = null;
|
Selected = null;
|
||||||
miniPreview.Source = null;
|
miniPreview.Source = null;
|
||||||
|
miniPreview.ClearValue(AutomationProperties.NameProperty);
|
||||||
addVehicleButton.IsEnabled = false;
|
addVehicleButton.IsEnabled = false;
|
||||||
|
|
||||||
vehicleListBox.Items.Clear();
|
vehicleListBox.Items.Clear();
|
||||||
@@ -381,10 +383,12 @@ public sealed class VehicleBrowser
|
|||||||
|
|
||||||
public void VehicleListBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
public void VehicleListBox_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (vehicleListBox.SelectedItem is ListBoxItem { Tag: VehicleTexture texture })
|
if (vehicleListBox.SelectedItem is ListBoxItem { Tag: VehicleTexture texture } row)
|
||||||
{
|
{
|
||||||
Selected = texture;
|
Selected = texture;
|
||||||
miniPreview.Source = _minis.Get(_db.ResolveMiniName(texture), MiniPreviewHeight);
|
miniPreview.Source = _minis.Get(_db.ResolveMiniName(texture), MiniPreviewHeight);
|
||||||
|
// Under the mouse a reader hears which vehicle the picture shows.
|
||||||
|
AutomationProperties.SetName(miniPreview, ScreenReaderNames.TextOf(row.Content));
|
||||||
addVehicleButton.IsEnabled = true;
|
addVehicleButton.IsEnabled = true;
|
||||||
SyncCombosTo(texture);
|
SyncCombosTo(texture);
|
||||||
|
|
||||||
@@ -397,6 +401,7 @@ public sealed class VehicleBrowser
|
|||||||
{
|
{
|
||||||
Selected = null;
|
Selected = null;
|
||||||
miniPreview.Source = null;
|
miniPreview.Source = null;
|
||||||
|
miniPreview.ClearValue(AutomationProperties.NameProperty);
|
||||||
addVehicleButton.IsEnabled = false;
|
addVehicleButton.IsEnabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
</HeaderedContentControl>
|
</HeaderedContentControl>
|
||||||
|
|
||||||
<GridSplitter IsTabStop="False" Grid.Column="1" Grid.Row="0" Width="6"
|
<GridSplitter IsTabStop="False" AutomationProperties.Name="{Binding [PanelSplitter], Source={x:Static starterNg:App.Loc}}" Grid.Column="1" Grid.Row="0" Width="6"
|
||||||
Background="Transparent" ResizeDirection="Columns" />
|
Background="Transparent" ResizeDirection="Columns" />
|
||||||
|
|
||||||
<Grid Grid.Column="2" Grid.Row="0">
|
<Grid Grid.Column="2" Grid.Row="0">
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
SelectionChanged="VehicleList_OnSelectionChanged" />
|
SelectionChanged="VehicleList_OnSelectionChanged" />
|
||||||
</HeaderedContentControl>
|
</HeaderedContentControl>
|
||||||
|
|
||||||
<GridSplitter IsTabStop="False" Grid.Row="1" Height="4" HorizontalAlignment="Stretch"
|
<GridSplitter IsTabStop="False" AutomationProperties.Name="{Binding [PanelSplitter], Source={x:Static starterNg:App.Loc}}" Grid.Row="1" Height="4" HorizontalAlignment="Stretch"
|
||||||
Background="Transparent" ResizeDirection="Rows" />
|
Background="Transparent" ResizeDirection="Rows" />
|
||||||
|
|
||||||
<TabControl Grid.Row="2" Name="infoTabs">
|
<TabControl Grid.Row="2" Name="infoTabs">
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
Click="ExportIniButton_OnClick" />
|
Click="ExportIniButton_OnClick" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<ListBox x:Name="CategoryList" AutomationProperties.LandmarkType="Navigation" Classes="SettingsNav" SelectedIndex="0"
|
<ListBox x:Name="CategoryList" AutomationProperties.LandmarkType="Navigation" AutomationProperties.Name="{Binding [SettingsCategories], Source={x:Static starterNg:App.Loc}}" Classes="SettingsNav" SelectedIndex="0"
|
||||||
ItemContainerTheme="{StaticResource SettingsNavItem}"
|
ItemContainerTheme="{StaticResource SettingsNavItem}"
|
||||||
SelectionChanged="CategoryList_OnSelectionChanged">
|
SelectionChanged="CategoryList_OnSelectionChanged">
|
||||||
<ListBoxItem Tag="general" Content="{Binding [General], Source={x:Static starterNg:App.Loc}}" />
|
<ListBoxItem Tag="general" Content="{Binding [General], Source={x:Static starterNg:App.Loc}}" />
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
<Grid RowDefinitions="Auto,*,4,Auto,*,Auto,Auto">
|
<Grid RowDefinitions="Auto,*,4,Auto,*,Auto,Auto">
|
||||||
<TextBlock Grid.Row="0" Classes="Heading" Text="{Binding [Category], Source={x:Static starterNg:App.Loc}}" />
|
<TextBlock Grid.Row="0" Classes="Heading" Text="{Binding [Category], Source={x:Static starterNg:App.Loc}}" />
|
||||||
<ListBox Name="categoryList" Grid.Row="1" Classes="Compact" />
|
<ListBox Name="categoryList" Grid.Row="1" Classes="Compact" />
|
||||||
<GridSplitter IsTabStop="False" Grid.Row="2" Height="4" HorizontalAlignment="Stretch"
|
<GridSplitter IsTabStop="False" AutomationProperties.Name="{Binding [PanelSplitter], Source={x:Static starterNg:App.Loc}}" Grid.Row="2" Height="4" HorizontalAlignment="Stretch"
|
||||||
Background="Transparent" ResizeDirection="Rows" />
|
Background="Transparent" ResizeDirection="Rows" />
|
||||||
<TextBlock Grid.Row="3" Classes="Heading" Text="{Binding [Class], Source={x:Static starterNg:App.Loc}}" />
|
<TextBlock Grid.Row="3" Classes="Heading" Text="{Binding [Class], Source={x:Static starterNg:App.Loc}}" />
|
||||||
<ListBox Name="classList" Grid.Row="4" Classes="Compact">
|
<ListBox Name="classList" Grid.Row="4" Classes="Compact">
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<GridSplitter IsTabStop="False" Grid.Column="1" Width="3" Background="Transparent" ResizeDirection="Columns" />
|
<GridSplitter IsTabStop="False" AutomationProperties.Name="{Binding [PanelSplitter], Source={x:Static starterNg:App.Loc}}" Grid.Column="1" Width="3" Background="Transparent" ResizeDirection="Columns" />
|
||||||
|
|
||||||
<Border Grid.Column="2" Classes="Panel">
|
<Border Grid.Column="2" Classes="Panel">
|
||||||
<Grid RowDefinitions="Auto,*">
|
<Grid RowDefinitions="Auto,*">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Avalonia.Automation;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
@@ -180,6 +181,7 @@ public partial class VehicleBaseWindow : Window
|
|||||||
if (row is null)
|
if (row is null)
|
||||||
{
|
{
|
||||||
preview.Source = null;
|
preview.Source = null;
|
||||||
|
preview.ClearValue(AutomationProperties.NameProperty);
|
||||||
detailTitle.Text = "";
|
detailTitle.Text = "";
|
||||||
detailText.Text = App.Loc["TextureBasePick"];
|
detailText.Text = App.Loc["TextureBasePick"];
|
||||||
ToolTip.SetTip(detailText, null);
|
ToolTip.SetTip(detailText, null);
|
||||||
@@ -188,6 +190,7 @@ public partial class VehicleBaseWindow : Window
|
|||||||
|
|
||||||
preview.Source = _minis.Get(_db.ResolveMiniName(row.Texture), PreviewHeight);
|
preview.Source = _minis.Get(_db.ResolveMiniName(row.Texture), PreviewHeight);
|
||||||
detailTitle.Text = string.Join(" · ", new[] { row.Skin, row.Class, row.Operator }.Where(s => s.Length > 0));
|
detailTitle.Text = string.Join(" · ", new[] { row.Skin, row.Class, row.Operator }.Where(s => s.Length > 0));
|
||||||
|
AutomationProperties.SetName(preview, detailTitle.Text);
|
||||||
|
|
||||||
var lines = new[]
|
var lines = new[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -568,6 +568,8 @@
|
|||||||
<String key="TreeExpanded">rozbaleno</String>
|
<String key="TreeExpanded">rozbaleno</String>
|
||||||
<String key="TreeCollapsed">sbaleno</String>
|
<String key="TreeCollapsed">sbaleno</String>
|
||||||
<String key="SceneryImage">Obrázek scenérie</String>
|
<String key="SceneryImage">Obrázek scenérie</String>
|
||||||
|
<String key="PanelSplitter">Oddělovač panelů</String>
|
||||||
|
<String key="SettingsCategories">Kategorie nastavení</String>
|
||||||
<String key="SettingsNotSaved">Nastavení se nepodařilo uložit</String>
|
<String key="SettingsNotSaved">Nastavení se nepodařilo uložit</String>
|
||||||
<String key="UnsavedChanges">Neuložené změny</String>
|
<String key="UnsavedChanges">Neuložené změny</String>
|
||||||
|
|
||||||
|
|||||||
@@ -594,6 +594,8 @@
|
|||||||
<String key="TreeExpanded">expanded</String>
|
<String key="TreeExpanded">expanded</String>
|
||||||
<String key="TreeCollapsed">collapsed</String>
|
<String key="TreeCollapsed">collapsed</String>
|
||||||
<String key="SceneryImage">Scenery picture</String>
|
<String key="SceneryImage">Scenery picture</String>
|
||||||
|
<String key="PanelSplitter">Panel divider</String>
|
||||||
|
<String key="SettingsCategories">Settings categories</String>
|
||||||
<String key="SettingsNotSaved">Could not save the settings</String>
|
<String key="SettingsNotSaved">Could not save the settings</String>
|
||||||
<String key="UnsavedChanges">Unsaved changes</String>
|
<String key="UnsavedChanges">Unsaved changes</String>
|
||||||
|
|
||||||
|
|||||||
@@ -568,6 +568,8 @@
|
|||||||
<String key="TreeExpanded">kibontva</String>
|
<String key="TreeExpanded">kibontva</String>
|
||||||
<String key="TreeCollapsed">összecsukva</String>
|
<String key="TreeCollapsed">összecsukva</String>
|
||||||
<String key="SceneryImage">A pálya képe</String>
|
<String key="SceneryImage">A pálya képe</String>
|
||||||
|
<String key="PanelSplitter">Panelelválasztó</String>
|
||||||
|
<String key="SettingsCategories">Beállítási kategóriák</String>
|
||||||
<String key="SettingsNotSaved">A beállításokat nem sikerült elmenteni</String>
|
<String key="SettingsNotSaved">A beállításokat nem sikerült elmenteni</String>
|
||||||
<String key="UnsavedChanges">Nem mentett módosítások</String>
|
<String key="UnsavedChanges">Nem mentett módosítások</String>
|
||||||
|
|
||||||
|
|||||||
@@ -594,6 +594,8 @@
|
|||||||
<String key="TreeExpanded">rozwinięte</String>
|
<String key="TreeExpanded">rozwinięte</String>
|
||||||
<String key="TreeCollapsed">zwinięte</String>
|
<String key="TreeCollapsed">zwinięte</String>
|
||||||
<String key="SceneryImage">Obraz scenerii</String>
|
<String key="SceneryImage">Obraz scenerii</String>
|
||||||
|
<String key="PanelSplitter">Rozdzielacz paneli</String>
|
||||||
|
<String key="SettingsCategories">Kategorie ustawień</String>
|
||||||
<String key="SettingsNotSaved">Nie udało się zapisać ustawień</String>
|
<String key="SettingsNotSaved">Nie udało się zapisać ustawień</String>
|
||||||
<String key="UnsavedChanges">Niezapisane zmiany</String>
|
<String key="UnsavedChanges">Niezapisane zmiany</String>
|
||||||
|
|
||||||
|
|||||||
@@ -568,6 +568,8 @@
|
|||||||
<String key="TreeExpanded">развёрнуто</String>
|
<String key="TreeExpanded">развёрнуто</String>
|
||||||
<String key="TreeCollapsed">свёрнуто</String>
|
<String key="TreeCollapsed">свёрнуто</String>
|
||||||
<String key="SceneryImage">Изображение сценерии</String>
|
<String key="SceneryImage">Изображение сценерии</String>
|
||||||
|
<String key="PanelSplitter">Разделитель панелей</String>
|
||||||
|
<String key="SettingsCategories">Категории настроек</String>
|
||||||
<String key="SettingsNotSaved">Не удалось сохранить настройки</String>
|
<String key="SettingsNotSaved">Не удалось сохранить настройки</String>
|
||||||
<String key="UnsavedChanges">Несохранённые изменения</String>
|
<String key="UnsavedChanges">Несохранённые изменения</String>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user