-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Settings UI] [Colour schemes page] Redesign Colour Buttons #8997
Changes from all commits
731c75f
63f86a9
56d3f42
062b9f8
3a3477f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<hstring, 16> 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<std::wstring, 9> InBoxSchemes = { | ||
|
@@ -53,7 +55,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |
|
||
ColorSchemes::ColorSchemes() : | ||
_ColorSchemeList{ single_threaded_observable_vector<Model::ColorScheme>() }, | ||
_CurrentColorTable{ single_threaded_observable_vector<Editor::ColorTableEntry>() } | ||
_CurrentNonBrightColorTable{ single_threaded_observable_vector<Editor::ColorTableEntry>() }, | ||
_CurrentBrightColorTable{ single_threaded_observable_vector<Editor::ColorTableEntry>() } | ||
{ | ||
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<ColorTableEntry>(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: | ||
// - <none> | ||
void ColorSchemes::ColorPickerChanged(IInspectable const& sender, | ||
void ColorSchemes::NonBrightColorPickerChanged(IInspectable const& sender, | ||
ColorChangedEventArgs const& args) | ||
{ | ||
if (auto picker = sender.try_as<ColorPicker>()) | ||
|
@@ -155,7 +166,31 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation | |
{ | ||
auto index = winrt::unbox_value<uint8_t>(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: | ||
// - <none> | ||
void ColorSchemes::BrightColorPickerChanged(IInspectable const& sender, | ||
ColorChangedEventArgs const& args) | ||
{ | ||
if (auto picker = sender.try_as<ColorPicker>()) | ||
{ | ||
if (auto tag = picker.Tag()) | ||
{ | ||
auto index = winrt::unbox_value<uint8_t>(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]); | ||
} | ||
Comment on lines
329
to
338
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you really tried this code?
|
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is false. we have 8+8 colors. But the list index goes from 0-7. If you count from 0-7 you count 8 times.