mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-16 13:04:09 +01:00
NVDA passes over a group that is not content as well as control, so titled panels and the landmarks are now both. A setting's explanation and the note on why the simulator ignores it are read after its name. The key under each setting is no longer a silent stop for Tab, and a step of the fog slider moves the shown distance.
108 lines
3.7 KiB
C#
108 lines
3.7 KiB
C#
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
|
|
namespace StarterNG.Controls;
|
|
|
|
public class SettingRow : ContentControl
|
|
{
|
|
public static readonly StyledProperty<string?> LabelProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(Label));
|
|
|
|
public static readonly StyledProperty<string?> DescriptionProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(Description));
|
|
|
|
public static readonly StyledProperty<string?> ConfigKeyProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(ConfigKey));
|
|
|
|
public static readonly StyledProperty<string?> ValueTextProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(ValueText));
|
|
|
|
/// <summary>
|
|
/// Why the simulator to be started would pass this setting over; the row dims
|
|
/// and says so. The input stays usable - the file may serve another build.
|
|
/// </summary>
|
|
public static readonly StyledProperty<string?> IdleNoteProperty =
|
|
AvaloniaProperty.Register<SettingRow, string?>(nameof(IdleNote));
|
|
|
|
public string? Label
|
|
{
|
|
get => GetValue(LabelProperty);
|
|
set => SetValue(LabelProperty, value);
|
|
}
|
|
|
|
public string? Description
|
|
{
|
|
get => GetValue(DescriptionProperty);
|
|
set => SetValue(DescriptionProperty, value);
|
|
}
|
|
|
|
public string? ConfigKey
|
|
{
|
|
get => GetValue(ConfigKeyProperty);
|
|
set => SetValue(ConfigKeyProperty, value);
|
|
}
|
|
|
|
public string? ValueText
|
|
{
|
|
get => GetValue(ValueTextProperty);
|
|
set => SetValue(ValueTextProperty, value);
|
|
}
|
|
|
|
public string? IdleNote
|
|
{
|
|
get => GetValue(IdleNoteProperty);
|
|
set => SetValue(IdleNoteProperty, value);
|
|
}
|
|
|
|
public SettingRow()
|
|
{
|
|
UpdatePseudoClasses();
|
|
}
|
|
|
|
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
{
|
|
base.OnPropertyChanged(change);
|
|
|
|
if (change.Property == LabelProperty ||
|
|
change.Property == DescriptionProperty ||
|
|
change.Property == ConfigKeyProperty ||
|
|
change.Property == ValueTextProperty ||
|
|
change.Property == IdleNoteProperty ||
|
|
change.Property == ContentProperty)
|
|
UpdatePseudoClasses();
|
|
|
|
if (change.Property == IdleNoteProperty)
|
|
ToolTip.SetTip(this, string.IsNullOrEmpty(IdleNote) ? null : IdleNote);
|
|
|
|
if (change.Property == LabelProperty || change.Property == ContentProperty)
|
|
ScreenReaderNames.NameInputs(Content, Label);
|
|
|
|
if (change.Property == ValueTextProperty || change.Property == ContentProperty)
|
|
ScreenReaderNames.TellValue(Content, ValueText);
|
|
|
|
if (change.Property == DescriptionProperty || change.Property == IdleNoteProperty ||
|
|
change.Property == ContentProperty)
|
|
ScreenReaderNames.DescribeInputs(Content, Description, IdleNote);
|
|
}
|
|
|
|
// Again once in the window: a panel given as content may be filled after it was set.
|
|
protected override void OnLoaded(RoutedEventArgs e)
|
|
{
|
|
base.OnLoaded(e);
|
|
ScreenReaderNames.NameInputs(Content, Label);
|
|
ScreenReaderNames.TellValue(Content, ValueText);
|
|
ScreenReaderNames.DescribeInputs(Content, Description, IdleNote);
|
|
}
|
|
|
|
private void UpdatePseudoClasses()
|
|
{
|
|
PseudoClasses.Set(":no-label", string.IsNullOrEmpty(Label));
|
|
PseudoClasses.Set(":no-description", string.IsNullOrEmpty(Description));
|
|
PseudoClasses.Set(":no-key", string.IsNullOrEmpty(ConfigKey));
|
|
PseudoClasses.Set(":no-value", string.IsNullOrEmpty(ValueText));
|
|
PseudoClasses.Set(":no-content", Content is null);
|
|
PseudoClasses.Set(":idle", !string.IsNullOrEmpty(IdleNote));
|
|
}
|
|
}
|