From 057183b651e254ff29a25a9c3ca4f56032c34048 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Wed, 10 Jan 2024 10:06:14 -0800 Subject: [PATCH] Update SUI Color Scheme colors' AutoProp.Name and ToolTip (#16544) In the Settings UI's Color Scheme page (where you edit the color scheme itself), update the color chip buttons to include the RGB value in the tooltip and screen reader announcements. Closes #15985 Closes #15983 ## Validation Steps Performed Tooltip and screen reader announcement is updated on launch and when a new value is selected. --- .../ColorSchemeViewModel.cpp | 14 ++++++++++++++ .../TerminalSettingsEditor/ColorSchemeViewModel.h | 7 +++++++ .../ColorSchemeViewModel.idl | 1 + .../TerminalSettingsEditor/EditColorScheme.xaml | 4 ++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp index 4bd995b6c4a..04e9433bbba 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp @@ -178,6 +178,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Name(TableColorNames[index]); Tag(winrt::box_value(index)); Color(color); + + PropertyChanged({ get_weak(), &ColorTableEntry::_PropertyChangedHandler }); } ColorTableEntry::ColorTableEntry(std::wstring_view tag, Windows::UI::Color color) @@ -185,5 +187,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation Name(LocalizedNameForEnumName(L"ColorScheme_", tag, L"Text")); Tag(winrt::box_value(tag)); Color(color); + + PropertyChanged({ get_weak(), &ColorTableEntry::_PropertyChangedHandler }); + } + + void ColorTableEntry::_PropertyChangedHandler(const IInspectable& /*sender*/, const PropertyChangedEventArgs& args) + { + const auto propertyName{ args.PropertyName() }; + if (propertyName == L"Color" || propertyName == L"Name") + { + _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"AccessibleName" }); + } } + } diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h index 539b0636c3c..7c45638e709 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h @@ -63,6 +63,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation ColorTableEntry(uint8_t index, Windows::UI::Color color); ColorTableEntry(std::wstring_view tag, Windows::UI::Color color); + hstring AccessibleName() const + { + return hstring{ fmt::format(FMT_COMPILE(L"{} RGB({}, {}, {})"), _Name, _Color.R, _Color.G, _Color.B) }; + } + WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); WINRT_OBSERVABLE_PROPERTY(Windows::UI::Color, Color, _PropertyChangedHandlers); WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, _PropertyChangedHandlers); @@ -70,5 +75,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation private: Windows::UI::Color _color; + + void _PropertyChangedHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args); }; }; diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl index 3247ef125e3..b041c2ab93f 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl @@ -34,5 +34,6 @@ namespace Microsoft.Terminal.Settings.Editor String Name { get; }; IInspectable Tag; Windows.UI.Color Color; + String AccessibleName { get; }; } } diff --git a/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml b/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml index 8e68567bb82..c98f5c8d6c4 100644 --- a/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml +++ b/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml @@ -55,10 +55,10 @@ -