diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp b/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp index 37ab687d507..517df7de8c1 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.cpp @@ -20,23 +20,25 @@ using namespace winrt::Windows::Foundation::Collections; namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { + static constexpr int ColorTableDivider = 8; + static const std::array TableColorNames = { - RS_(L"ColorScheme_Black/Header"), - RS_(L"ColorScheme_Red/Header"), - RS_(L"ColorScheme_Green/Header"), - RS_(L"ColorScheme_Yellow/Header"), - RS_(L"ColorScheme_Blue/Header"), - RS_(L"ColorScheme_Purple/Header"), - RS_(L"ColorScheme_Cyan/Header"), - RS_(L"ColorScheme_White/Header"), - RS_(L"ColorScheme_BrightBlack/Header"), - RS_(L"ColorScheme_BrightRed/Header"), - RS_(L"ColorScheme_BrightGreen/Header"), - RS_(L"ColorScheme_BrightYellow/Header"), - RS_(L"ColorScheme_BrightBlue/Header"), - RS_(L"ColorScheme_BrightPurple/Header"), - RS_(L"ColorScheme_BrightCyan/Header"), - RS_(L"ColorScheme_BrightWhite/Header") + RS_(L"ColorScheme_Black/ToolTip"), + RS_(L"ColorScheme_Red/ToolTip"), + RS_(L"ColorScheme_Green/ToolTip"), + RS_(L"ColorScheme_Yellow/ToolTip"), + RS_(L"ColorScheme_Blue/ToolTip"), + RS_(L"ColorScheme_Purple/ToolTip"), + RS_(L"ColorScheme_Cyan/ToolTip"), + RS_(L"ColorScheme_White/ToolTip"), + RS_(L"ColorScheme_BrightBlack/ToolTip"), + RS_(L"ColorScheme_BrightRed/ToolTip"), + RS_(L"ColorScheme_BrightGreen/ToolTip"), + RS_(L"ColorScheme_BrightYellow/ToolTip"), + RS_(L"ColorScheme_BrightBlue/ToolTip"), + RS_(L"ColorScheme_BrightPurple/ToolTip"), + RS_(L"ColorScheme_BrightCyan/ToolTip"), + RS_(L"ColorScheme_BrightWhite/ToolTip") }; static const std::array InBoxSchemes = { @@ -53,7 +55,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation ColorSchemes::ColorSchemes() : _ColorSchemeList{ single_threaded_observable_vector() }, - _CurrentColorTable{ single_threaded_observable_vector() } + _CurrentNonBrightColorTable{ single_threaded_observable_vector() }, + _CurrentBrightColorTable{ single_threaded_observable_vector() } { InitializeComponent(); } @@ -71,7 +74,15 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation for (uint8_t i = 0; i < TableColorNames.size(); ++i) { auto entry = winrt::make(i, Windows::UI::Color{ 0, 0, 0, 0 }); - _CurrentColorTable.Append(entry); + + if (i < ColorTableDivider) + { + _CurrentNonBrightColorTable.Append(entry); + } + else + { + _CurrentBrightColorTable.Append(entry); + } } // Try to look up the scheme that was navigated to. If we find it, immediately select it. @@ -137,16 +148,16 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation } // Function Description: - // - Called when a ColorPicker control has selected a new color. This is specifically + // - Called when a ColorPicker control of the non-bright colour table has selected a new color. This is specifically // called by color pickers assigned to a color table entry. It takes the index // that's been stuffed in the Tag property of the color picker and uses it - // to update the color table accordingly. + // to update the non-bright color table accordingly. // Arguments: - // - sender: the color picker that raised this event. + // - sender: the color picker of the non-bright colour table that raised this event. // - args: the args that contains the new color that was picked. // Return Value: // - - void ColorSchemes::ColorPickerChanged(IInspectable const& sender, + void ColorSchemes::NonBrightColorPickerChanged(IInspectable const& sender, ColorChangedEventArgs const& args) { if (auto picker = sender.try_as()) @@ -155,7 +166,31 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { auto index = winrt::unbox_value(tag); CurrentColorScheme().SetColorTableEntry(index, args.NewColor()); - _CurrentColorTable.GetAt(index).Color(args.NewColor()); + _CurrentNonBrightColorTable.GetAt(index).Color(args.NewColor()); + } + } + } + + // Function Description: + // - Called when a ColorPicker control of the bright colour table has selected a new color. This is specifically + // called by color pickers assigned to a color table entry. It takes the index + // that's been stuffed in the Tag property of the color picker and uses it + // to update the bright color table accordingly. + // Arguments: + // - sender: the color picker of the bright colour table that raised this event. + // - args: the args that contains the new color that was picked. + // Return Value: + // - + void ColorSchemes::BrightColorPickerChanged(IInspectable const& sender, + ColorChangedEventArgs const& args) + { + if (auto picker = sender.try_as()) + { + if (auto tag = picker.Tag()) + { + auto index = winrt::unbox_value(tag); + CurrentColorScheme().SetColorTableEntry(index, args.NewColor()); + _CurrentBrightColorTable.GetAt(index - ColorTableDivider).Color(args.NewColor()); } } } @@ -284,6 +319,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation // Function Description: // - Updates the currently modifiable color table based on the given current color scheme. + // There are 7 non-bright colours and 7 bright colours. // Arguments: // - colorScheme: the color scheme to retrieve the color table from // Return Value: @@ -292,7 +328,13 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation { for (uint8_t i = 0; i < TableColorNames.size(); ++i) { - _CurrentColorTable.GetAt(i).Color(colorScheme.Table()[i]); + // Fill the element of "_CurrentNonBrightColorTable" with the non-bright colors (lower index on the color scheme object's table: 0-7). + int indexNonBrightColor = i; + // Fill the element of "_CurrentBrightColorTable" with the bright colors (higher index on the color scheme object's table: 8-15). + int indexBrightColor = i + ColorTableDivider; + + _CurrentNonBrightColorTable.GetAt(i).Color(colorScheme.Table()[indexNonBrightColor]); + _CurrentBrightColorTable.GetAt(i).Color(colorScheme.Table()[indexBrightColor]); } } diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.h b/src/cascadia/TerminalSettingsEditor/ColorSchemes.h index 6f053e99591..1f54f5218cd 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.h +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.h @@ -27,7 +27,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e); void ColorSchemeSelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::SelectionChangedEventArgs const& args); - void ColorPickerChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::ColorChangedEventArgs const& args); + void NonBrightColorPickerChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::ColorChangedEventArgs const& args); + void BrightColorPickerChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::Controls::ColorChangedEventArgs const& args); void AddNew_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e); void Rename_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e); @@ -39,7 +40,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation void DeleteConfirmation_Click(winrt::Windows::Foundation::IInspectable const& sender, winrt::Windows::UI::Xaml::RoutedEventArgs const& e); GETSET_PROPERTY(Editor::ColorSchemesPageNavigationState, State, nullptr); - GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector, CurrentColorTable, nullptr); + GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector, CurrentNonBrightColorTable, nullptr); + GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector, CurrentBrightColorTable, nullptr); GETSET_PROPERTY(Windows::Foundation::Collections::IObservableVector, ColorSchemeList, nullptr); WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler); diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.idl b/src/cascadia/TerminalSettingsEditor/ColorSchemes.idl index 21c80c2b466..e1f0d85b877 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.idl +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.idl @@ -19,7 +19,8 @@ namespace Microsoft.Terminal.Settings.Editor Boolean IsRenaming { get; }; Microsoft.Terminal.Settings.Model.ColorScheme CurrentColorScheme { get; }; - Windows.Foundation.Collections.IObservableVector CurrentColorTable; + Windows.Foundation.Collections.IObservableVector CurrentNonBrightColorTable; + Windows.Foundation.Collections.IObservableVector CurrentBrightColorTable; Windows.Foundation.Collections.IObservableVector ColorSchemeList { get; }; } diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemes.xaml b/src/cascadia/TerminalSettingsEditor/ColorSchemes.xaml index 0dddeb1069d..2d70b2dda72 100644 --- a/src/cascadia/TerminalSettingsEditor/ColorSchemes.xaml +++ b/src/cascadia/TerminalSettingsEditor/ColorSchemes.xaml @@ -17,11 +17,11 @@ the MIT License. See LICENSE in the project root for license information. --> - 0,0,10,20 + 0,0,10,10