@@ -4695,10 +4695,13 @@ namespace winrt::TerminalApp::implementation
46954695 }
46964696
46974697 const auto theme = _settings.GlobalSettings ().CurrentTheme ();
4698- auto requestedTheme{ theme.RequestedTheme () };
4698+ const auto paneActiveBorderColor = theme.Pane () ? theme.Pane ().ActiveBorderColor () : nullptr ;
4699+ const auto paneInactiveBorderColor = theme.Pane () ? theme.Pane ().InactiveBorderColor () : nullptr ;
4700+ const auto broadcastBorderColor = theme.Pane () ? theme.Pane ().BroadcastBorderColor () : nullptr ;
4701+ const auto requestedTheme{ theme.RequestedTheme () };
46994702
47004703 {
4701- _updatePaneResources (requestedTheme);
4704+ _updatePaneResources (requestedTheme, paneActiveBorderColor, paneInactiveBorderColor, broadcastBorderColor );
47024705
47034706 for (const auto & tab : _tabs)
47044707 {
@@ -4802,67 +4805,106 @@ namespace winrt::TerminalApp::implementation
48024805 }
48034806 }
48044807
4808+
4809+ Color TerminalPage::_colorFromKey (const ResourceDictionary& resourceDictionary, const ElementTheme& requestedTheme, const IInspectable& colorKey)
4810+ {
4811+ const auto colorFromResources = ThemeLookup (resourceDictionary, requestedTheme, colorKey);
4812+ // If SystemAccentColor is _not_ a Color for some reason, use
4813+ // Transparent as the color, so we don't do this process again on
4814+ // the next pane (by leaving s_focusedBorderBrush nullptr)
4815+ return winrt::unbox_value_or<Color>(colorFromResources, Colors::Black ());
4816+ }
4817+
4818+ Color TerminalPage::_parseThemeColorToColor (
4819+ const ThemeColor& colorToCopy,
4820+ const ResourceDictionary& resourceDictionary,
4821+ const ElementTheme& requestedTheme,
4822+ const IInspectable& colorKey
4823+ )
4824+ {
4825+ switch (colorToCopy.ColorType ())
4826+ {
4827+ case ThemeColorType::Accent:
4828+ return _colorFromKey (resourceDictionary, requestedTheme, colorKey);
4829+ case ThemeColorType::Color:
4830+ const auto rawColor = colorToCopy.Color ();
4831+ return Color{
4832+ rawColor.A ,
4833+ rawColor.R ,
4834+ rawColor.G ,
4835+ rawColor.B
4836+ };
4837+ case ThemeColorType::TerminalBackground:
4838+ const auto terminalBg = ThemeColor::FromTerminalBackground ().Color ();
4839+ return Color{
4840+ terminalBg.A ,
4841+ terminalBg.R ,
4842+ terminalBg.G ,
4843+ terminalBg.B
4844+ };
4845+ default :
4846+ assert (false && " unknown type for color type in theme color" ); // should never be reached
4847+ return winrt::Windows::UI::Color{};
4848+ }
4849+ }
4850+
48054851 // Function Description:
48064852 // - Attempts to load some XAML resources that Panes will need. This includes:
48074853 // * The Color they'll use for active Panes's borders - SystemAccentColor
48084854 // * The Brush they'll use for inactive Panes - TabViewBackground (to match the
48094855 // color of the titlebar)
48104856 // Arguments:
48114857 // - requestedTheme: this should be the currently active Theme for the app
4858+ // - activeBorderColor: the pane's border color for the application when it is active
4859+ // - inactiveBorderColor: the pane's border color for the application when it is inactive
4860+ // - broadcastBorderColor: the pane's border color for the application when it is broadcast
48124861 // Return Value:
48134862 // - <none>
4814- void TerminalPage::_updatePaneResources (const winrt::Windows::UI::Xaml:: ElementTheme& requestedTheme)
4863+ void TerminalPage::_updatePaneResources (const ElementTheme& requestedTheme, const ThemeColor& activeBorderColor, const ThemeColor& inactiveBorderColor, const ThemeColor& broadcastBorderColor )
48154864 {
48164865 const auto res = Application::Current ().Resources ();
48174866 const auto accentColorKey = winrt::box_value (L" SystemAccentColor" );
4867+ auto activeBrushColor = Colors::Black (), inactiveBrushColor = Colors::Black (), broadcastBrushColor = Colors::Black ();
48184868 if (res.HasKey (accentColorKey))
48194869 {
4820- const auto colorFromResources = ThemeLookup (res, requestedTheme, accentColorKey);
4821- // If SystemAccentColor is _not_ a Color for some reason, use
4822- // Transparent as the color, so we don't do this process again on
4823- // the next pane (by leaving s_focusedBorderBrush nullptr)
4824- auto actualColor = winrt::unbox_value_or<Color>(colorFromResources, Colors::Black ());
4825- _paneResources.focusedBorderBrush = SolidColorBrush (actualColor);
4870+ activeBrushColor = _colorFromKey (res, requestedTheme, accentColorKey);
48264871 }
4827- else
4872+ // Overwrites the accent above (or the black default color if there was no accent color)
4873+ if (activeBorderColor)
48284874 {
4829- // DON'T use Transparent here - if it's "Transparent", then it won't
4830- // be able to hittest for clicks, and then clicking on the border
4831- // will eat focus.
4832- _paneResources.focusedBorderBrush = SolidColorBrush{ Colors::Black () };
4875+ activeBrushColor = _parseThemeColorToColor (activeBorderColor, res, requestedTheme, accentColorKey);
48334876 }
4834-
4877+ // DON'T use Transparent here - if it's "Transparent", then it won't
4878+ // be able to hittest for clicks, and then clicking on the border
4879+ // will eat focus.
4880+ _paneResources.focusedBorderBrush = SolidColorBrush (activeBrushColor);
48354881 const auto unfocusedBorderBrushKey = winrt::box_value (L" UnfocusedBorderBrush" );
48364882 if (res.HasKey (unfocusedBorderBrushKey))
48374883 {
4838- // MAKE SURE TO USE ThemeLookup, so that we get the correct resource for
4839- // the requestedTheme, not just the value from the resources (which
4840- // might not respect the settings' requested theme)
4841- auto obj = ThemeLookup (res, requestedTheme, unfocusedBorderBrushKey);
4842- _paneResources.unfocusedBorderBrush = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4884+ inactiveBrushColor = _colorFromKey (res, requestedTheme, unfocusedBorderBrushKey);
48434885 }
4844- else
4886+ // Overwrites the above (or the black default color if there was no unfocusedBorderBrushKey)
4887+ if (inactiveBorderColor)
48454888 {
4846- // DON'T use Transparent here - if it's "Transparent", then it won't
4847- // be able to hittest for clicks, and then clicking on the border
4848- // will eat focus.
4849- _paneResources.unfocusedBorderBrush = SolidColorBrush{ Colors::Black () };
4889+ inactiveBrushColor = _parseThemeColorToColor (inactiveBorderColor, res, requestedTheme, unfocusedBorderBrushKey);
48504890 }
4851-
4891+ // DON'T use Transparent here - if it's "Transparent", then it won't
4892+ // be able to hittest for clicks, and then clicking on the border
4893+ // will eat focus.
4894+ _paneResources.unfocusedBorderBrush = SolidColorBrush (inactiveBrushColor);
48524895 const auto broadcastColorKey = winrt::box_value (L" BroadcastPaneBorderColor" );
48534896 if (res.HasKey (broadcastColorKey))
48544897 {
4855- // MAKE SURE TO USE ThemeLookup
4856- auto obj = ThemeLookup (res, requestedTheme, broadcastColorKey);
4857- _paneResources.broadcastBorderBrush = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4898+ _colorFromKey (res, requestedTheme, broadcastColorKey);
48584899 }
4859- else
4900+ if (broadcastBorderColor)
48604901 {
4861- // DON'T use Transparent here - if it's "Transparent", then it won't
4862- // be able to hittest for clicks, and then clicking on the border
4863- // will eat focus.
4864- _paneResources.broadcastBorderBrush = SolidColorBrush{ Colors::Black () };
4902+ broadcastBrushColor = _parseThemeColorToColor (broadcastBorderColor, res, requestedTheme, broadcastColorKey);
48654903 }
4904+ // DON'T use Transparent here - if it's "Transparent", then it won't
4905+ // be able to hittest for clicks, and then clicking on the border
4906+ // will eat focus.
4907+ _paneResources.broadcastBorderBrush = SolidColorBrush (broadcastBrushColor);
48664908 }
48674909
48684910 void TerminalPage::WindowActivated (const bool activated)
0 commit comments