diff --git a/.github/actions/spelling/excludes.txt b/.github/actions/spelling/excludes.txt index 4b6ae25b163..896211b8f17 100644 --- a/.github/actions/spelling/excludes.txt +++ b/.github/actions/spelling/excludes.txt @@ -99,6 +99,7 @@ Resources/(?!en) ^NOTICE.md ^oss/ ^samples/PixelShaders/Screenshots/ +^src/cascadia/TerminalSettingsEditor/SegoeFluentIconList.h$ ^src/interactivity/onecore/BgfxEngine\. ^src/renderer/atlas/ ^src/renderer/wddmcon/WddmConRenderer\. diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.cpp b/src/cascadia/TerminalSettingsEditor/Appearances.cpp index 4e6bc3b74fc..bf85a5db29d 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.cpp +++ b/src/cascadia/TerminalSettingsEditor/Appearances.cpp @@ -221,6 +221,30 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // box, prevent it from ever being changed again. _NotifyChanges(L"UseDesktopBGImage", L"BackgroundImageSettingsVisible"); } + else if (viewModelProperty == L"Foreground") + { + _NotifyChanges(L"ForegroundPreview"); + } + else if (viewModelProperty == L"Background") + { + _NotifyChanges(L"BackgroundPreview"); + } + else if (viewModelProperty == L"SelectionBackground") + { + _NotifyChanges(L"SelectionBackgroundPreview"); + } + else if (viewModelProperty == L"CursorColor") + { + _NotifyChanges(L"CursorColorPreview"); + } + else if (viewModelProperty == L"DarkColorSchemeName" || viewModelProperty == L"LightColorSchemeName") + { + _NotifyChanges(L"CurrentColorScheme"); + } + else if (viewModelProperty == L"CurrentColorScheme") + { + _NotifyChanges(L"ForegroundPreview", L"BackgroundPreview", L"SelectionBackgroundPreview", L"CursorColorPreview"); + } }); // Cache the original BG image path. If the user clicks "Use desktop @@ -928,7 +952,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation _NotifyChanges(L"CurrentColorScheme"); } - Editor::ColorSchemeViewModel AppearanceViewModel::CurrentColorScheme() + Editor::ColorSchemeViewModel AppearanceViewModel::CurrentColorScheme() const { const auto schemeName{ DarkColorSchemeName() }; const auto allSchemes{ SchemesList() }; @@ -950,6 +974,42 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation LightColorSchemeName(val.Name()); } + static inline Windows::UI::Color _getColorPreview(const IReference& modelVal, Windows::UI::Color deducedVal) + { + if (modelVal) + { + // user defined an override value + return Windows::UI::Color{ + .A = 255, + .R = modelVal.Value().R, + .G = modelVal.Value().G, + .B = modelVal.Value().B + }; + } + // set to null --> deduce value from color scheme + return deducedVal; + } + + Windows::UI::Color AppearanceViewModel::ForegroundPreview() const + { + return _getColorPreview(_appearance.Foreground(), CurrentColorScheme().ForegroundColor().Color()); + } + + Windows::UI::Color AppearanceViewModel::BackgroundPreview() const + { + return _getColorPreview(_appearance.Background(), CurrentColorScheme().BackgroundColor().Color()); + } + + Windows::UI::Color AppearanceViewModel::SelectionBackgroundPreview() const + { + return _getColorPreview(_appearance.SelectionBackground(), CurrentColorScheme().SelectionBackgroundColor().Color()); + } + + Windows::UI::Color AppearanceViewModel::CursorColorPreview() const + { + return _getColorPreview(_appearance.CursorColor(), CurrentColorScheme().CursorColor().Color()); + } + DependencyProperty Appearances::_AppearanceProperty{ nullptr }; Appearances::Appearances() diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.h b/src/cascadia/TerminalSettingsEditor/Appearances.h index aba3abd45ff..c31c1269cf1 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.h +++ b/src/cascadia/TerminalSettingsEditor/Appearances.h @@ -127,9 +127,14 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void SetBackgroundImagePath(winrt::hstring path); void ClearColorScheme(); - Editor::ColorSchemeViewModel CurrentColorScheme(); + Editor::ColorSchemeViewModel CurrentColorScheme() const; void CurrentColorScheme(const Editor::ColorSchemeViewModel& val); + Windows::UI::Color ForegroundPreview() const; + Windows::UI::Color BackgroundPreview() const; + Windows::UI::Color SelectionBackgroundPreview() const; + Windows::UI::Color CursorColorPreview() const; + WINRT_PROPERTY(bool, IsDefault, false); // These settings are not defined in AppearanceConfig, so we grab them @@ -153,6 +158,10 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation OBSERVABLE_PROJECTED_SETTING(_appearance, BackgroundImageAlignment); OBSERVABLE_PROJECTED_SETTING(_appearance, IntenseTextStyle); OBSERVABLE_PROJECTED_SETTING(_appearance, AdjustIndistinguishableColors); + OBSERVABLE_PROJECTED_SETTING(_appearance, Foreground); + OBSERVABLE_PROJECTED_SETTING(_appearance, Background); + OBSERVABLE_PROJECTED_SETTING(_appearance, SelectionBackground); + OBSERVABLE_PROJECTED_SETTING(_appearance, CursorColor); WINRT_OBSERVABLE_PROPERTY(Windows::Foundation::Collections::IObservableVector, SchemesList, _propertyChangedHandlers, nullptr); private: diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.idl b/src/cascadia/TerminalSettingsEditor/Appearances.idl index 5a22a190d2d..68cbd4ee76b 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.idl +++ b/src/cascadia/TerminalSettingsEditor/Appearances.idl @@ -45,6 +45,11 @@ namespace Microsoft.Terminal.Settings.Editor ColorSchemeViewModel CurrentColorScheme; IObservableVector SchemesList; + Windows.UI.Color ForegroundPreview { get; }; + Windows.UI.Color BackgroundPreview { get; }; + Windows.UI.Color SelectionBackgroundPreview { get; }; + Windows.UI.Color CursorColorPreview { get; }; + String MissingFontFaces { get; }; String ProportionalFontFaces { get; }; Boolean HasPowerlineCharacters { get; }; @@ -78,6 +83,11 @@ namespace Microsoft.Terminal.Settings.Editor OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.ConvergedAlignment, BackgroundImageAlignment); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Settings.Model.IntenseStyle, IntenseTextStyle); OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Microsoft.Terminal.Core.AdjustTextMode, AdjustIndistinguishableColors); + + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.Foundation.IReference, Foreground); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.Foundation.IReference, Background); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.Foundation.IReference, SelectionBackground); + OBSERVABLE_PROJECTED_APPEARANCE_SETTING(Windows.Foundation.IReference, CursorColor); } [default_interface] runtimeclass Appearances : Windows.UI.Xaml.Controls.UserControl, Windows.UI.Xaml.Data.INotifyPropertyChanged diff --git a/src/cascadia/TerminalSettingsEditor/Appearances.xaml b/src/cascadia/TerminalSettingsEditor/Appearances.xaml index 0ed87caa624..9789ac91450 100644 --- a/src/cascadia/TerminalSettingsEditor/Appearances.xaml +++ b/src/cascadia/TerminalSettingsEditor/Appearances.xaml @@ -69,138 +69,188 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + SettingOverrideSource="{x:Bind Appearance.DarkColorSchemeNameOverrideSource, Mode=OneWay}" + Style="{StaticResource ExpanderSettingContainerStyleWithComplexPreview}"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h index 12b26c160bf..45d3983f9ab 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h @@ -69,6 +69,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation return hstring{ fmt::format(FMT_COMPILE(L"{} RGB({}, {}, {})"), _Name, _Color.R, _Color.G, _Color.B) }; } + hstring NameWithHexCode() const + { + return hstring{ fmt::format(FMT_COMPILE(L"{} #{:02X}{:02X}{:02X}"), _Name, _Color.R, _Color.G, _Color.B) }; + } + til::property_changed_event PropertyChanged; WINRT_OBSERVABLE_PROPERTY(Windows::UI::Color, Color, PropertyChanged.raise); WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, PropertyChanged.raise); diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl index bf36ef4146b..9ad129b2285 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl @@ -36,5 +36,6 @@ namespace Microsoft.Terminal.Settings.Editor IInspectable Tag; Windows.UI.Color Color; String AccessibleName { get; }; + String NameWithHexCode { get; }; } } diff --git a/src/cascadia/TerminalSettingsEditor/CommonResources.xaml b/src/cascadia/TerminalSettingsEditor/CommonResources.xaml index 1e32c65078b..00e1fa559a1 100644 --- a/src/cascadia/TerminalSettingsEditor/CommonResources.xaml +++ b/src/cascadia/TerminalSettingsEditor/CommonResources.xaml @@ -4,6 +4,8 @@ --> @@ -60,6 +62,9 @@ + + + Firebrick 14.0 @@ -69,6 +74,32 @@ 1000 13,0,13,48 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +