8
8
#include " SettingsPaneContent.h"
9
9
#include " Tab.g.cpp"
10
10
#include " Utils.h"
11
- #include " ColorHelper.h"
12
11
#include " AppLogic.h"
12
+ #include " ../../types/inc/ColorFix.hpp"
13
13
14
14
using namespace winrt ;
15
15
using namespace winrt ::Windows::UI::Xaml;
@@ -2275,11 +2275,13 @@ namespace winrt::TerminalApp::implementation
2275
2275
// the background color
2276
2276
// - This method should only be called on the UI thread.
2277
2277
// Arguments:
2278
- // - color : the color the user picked for their tab
2278
+ // - uiColor : the color the user picked for their tab
2279
2279
// Return Value:
2280
2280
// - <none>
2281
- void Tab::_ApplyTabColorOnUIThread (const winrt::Windows::UI::Color& color )
2281
+ void Tab::_ApplyTabColorOnUIThread (const winrt::Windows::UI::Color& uiColor )
2282
2282
{
2283
+ constexpr auto lightnessThreshold = 0 .6f ;
2284
+ const til::color color{ uiColor };
2283
2285
Media::SolidColorBrush selectedTabBrush{};
2284
2286
Media::SolidColorBrush deselectedTabBrush{};
2285
2287
Media::SolidColorBrush fontBrush{};
@@ -2292,7 +2294,7 @@ namespace winrt::TerminalApp::implementation
2292
2294
// calculate the luminance of the current color and select a font
2293
2295
// color based on that
2294
2296
// see https://www.w3.org/TR/WCAG20/#relativeluminancedef
2295
- if (TerminalApp::ColorHelper::IsBrightColor (color))
2297
+ if (ColorFix::GetLightness (color) >= lightnessThreshold )
2296
2298
{
2297
2299
auto subtleFillColorSecondary = winrt::Windows::UI::Colors::Black ();
2298
2300
subtleFillColorSecondary.A = 0x09 ;
@@ -2312,8 +2314,8 @@ namespace winrt::TerminalApp::implementation
2312
2314
}
2313
2315
2314
2316
// The tab font should be based on the evaluated appearance of the tab color layered on tab row.
2315
- const auto layeredTabColor = til:: color{ color } .layer_over (_tabRowColor);
2316
- if (TerminalApp::ColorHelper::IsBrightColor (layeredTabColor))
2317
+ const auto layeredTabColor = color.layer_over (_tabRowColor);
2318
+ if (ColorFix::GetLightness (layeredTabColor) >= lightnessThreshold )
2317
2319
{
2318
2320
fontBrush.Color (winrt::Windows::UI::Colors::Black ());
2319
2321
auto secondaryFontColor = winrt::Windows::UI::Colors::Black ();
@@ -2333,8 +2335,7 @@ namespace winrt::TerminalApp::implementation
2333
2335
selectedTabBrush.Color (color);
2334
2336
2335
2337
// Start with the current tab color, set to Opacity=.3
2336
- til::color deselectedTabColor{ color };
2337
- deselectedTabColor = deselectedTabColor.with_alpha (77 ); // 255 * .3 = 77
2338
+ auto deselectedTabColor = color.with_alpha (77 ); // 255 * .3 = 77
2338
2339
2339
2340
// If we DON'T have a color set from the color picker, or the profile's
2340
2341
// tabColor, but we do have a unfocused color in the theme, use the
@@ -2376,7 +2377,7 @@ namespace winrt::TerminalApp::implementation
2376
2377
// We don't want that to result in white text on a white tab row for
2377
2378
// inactive tabs.
2378
2379
const auto deselectedActualColor = deselectedTabColor.layer_over (_tabRowColor);
2379
- if (TerminalApp::ColorHelper::IsBrightColor (deselectedActualColor))
2380
+ if (ColorFix::GetLightness (deselectedActualColor) >= lightnessThreshold )
2380
2381
{
2381
2382
deselectedFontBrush.Color (winrt::Windows::UI::Colors::Black ());
2382
2383
}
0 commit comments