@@ -4689,10 +4689,13 @@ namespace winrt::TerminalApp::implementation
46894689 }
46904690
46914691 const auto theme = _settings.GlobalSettings ().CurrentTheme ();
4692- auto requestedTheme{ theme.RequestedTheme () };
4692+ const auto paneActiveBorderColor = theme.Pane () ? theme.Pane ().ActiveBorderColor () : nullptr ;
4693+ const auto paneInactiveBorderColor = theme.Pane () ? theme.Pane ().InactiveBorderColor () : nullptr ;
4694+ const auto broadcastBorderColor = theme.Pane () ? theme.Pane ().BroadcastBorderColor () : nullptr ;
4695+ const auto requestedTheme{ theme.RequestedTheme () };
46934696
46944697 {
4695- _updatePaneResources (requestedTheme);
4698+ _updatePaneResources (requestedTheme, paneActiveBorderColor, paneInactiveBorderColor, broadcastBorderColor );
46964699
46974700 for (const auto & tab : _tabs)
46984701 {
@@ -4796,67 +4799,106 @@ namespace winrt::TerminalApp::implementation
47964799 }
47974800 }
47984801
4802+
4803+ Color TerminalPage::_colorFromKey (const ResourceDictionary& resourceDictionary, const ElementTheme& requestedTheme, const IInspectable& colorKey)
4804+ {
4805+ const auto colorFromResources = ThemeLookup (resourceDictionary, requestedTheme, colorKey);
4806+ // If SystemAccentColor is _not_ a Color for some reason, use
4807+ // Transparent as the color, so we don't do this process again on
4808+ // the next pane (by leaving s_focusedBorderBrush nullptr)
4809+ return winrt::unbox_value_or<Color>(colorFromResources, Colors::Black ());
4810+ }
4811+
4812+ Color TerminalPage::_parseThemeColorToColor (
4813+ const ThemeColor& colorToCopy,
4814+ const ResourceDictionary& resourceDictionary,
4815+ const ElementTheme& requestedTheme,
4816+ const IInspectable& colorKey
4817+ )
4818+ {
4819+ switch (colorToCopy.ColorType ())
4820+ {
4821+ case ThemeColorType::Accent:
4822+ return _colorFromKey (resourceDictionary, requestedTheme, colorKey);
4823+ case ThemeColorType::Color:
4824+ const auto rawColor = colorToCopy.Color ();
4825+ return Color{
4826+ rawColor.A ,
4827+ rawColor.R ,
4828+ rawColor.G ,
4829+ rawColor.B
4830+ };
4831+ case ThemeColorType::TerminalBackground:
4832+ const auto terminalBg = ThemeColor::FromTerminalBackground ().Color ();
4833+ return Color{
4834+ terminalBg.A ,
4835+ terminalBg.R ,
4836+ terminalBg.G ,
4837+ terminalBg.B
4838+ };
4839+ default :
4840+ assert (false && " unknown type for color type in theme color" ); // should never be reached
4841+ return winrt::Windows::UI::Color{};
4842+ }
4843+ }
4844+
47994845 // Function Description:
48004846 // - Attempts to load some XAML resources that Panes will need. This includes:
48014847 // * The Color they'll use for active Panes's borders - SystemAccentColor
48024848 // * The Brush they'll use for inactive Panes - TabViewBackground (to match the
48034849 // color of the titlebar)
48044850 // Arguments:
48054851 // - requestedTheme: this should be the currently active Theme for the app
4852+ // - activeBorderColor: the pane's border color for the application when it is active
4853+ // - inactiveBorderColor: the pane's border color for the application when it is inactive
4854+ // - broadcastBorderColor: the pane's border color for the application when it is broadcast
48064855 // Return Value:
48074856 // - <none>
4808- void TerminalPage::_updatePaneResources (const winrt::Windows::UI::Xaml:: ElementTheme& requestedTheme)
4857+ void TerminalPage::_updatePaneResources (const ElementTheme& requestedTheme, const ThemeColor& activeBorderColor, const ThemeColor& inactiveBorderColor, const ThemeColor& broadcastBorderColor )
48094858 {
48104859 const auto res = Application::Current ().Resources ();
48114860 const auto accentColorKey = winrt::box_value (L" SystemAccentColor" );
4861+ auto activeBrushColor = Colors::Black (), inactiveBrushColor = Colors::Black (), broadcastBrushColor = Colors::Black ();
48124862 if (res.HasKey (accentColorKey))
48134863 {
4814- const auto colorFromResources = ThemeLookup (res, requestedTheme, accentColorKey);
4815- // If SystemAccentColor is _not_ a Color for some reason, use
4816- // Transparent as the color, so we don't do this process again on
4817- // the next pane (by leaving s_focusedBorderBrush nullptr)
4818- auto actualColor = winrt::unbox_value_or<Color>(colorFromResources, Colors::Black ());
4819- _paneResources.focusedBorderBrush = SolidColorBrush (actualColor);
4864+ activeBrushColor = _colorFromKey (res, requestedTheme, accentColorKey);
48204865 }
4821- else
4866+ // Overwrites the accent above (or the black default color if there was no accent color)
4867+ if (activeBorderColor)
48224868 {
4823- // DON'T use Transparent here - if it's "Transparent", then it won't
4824- // be able to hittest for clicks, and then clicking on the border
4825- // will eat focus.
4826- _paneResources.focusedBorderBrush = SolidColorBrush{ Colors::Black () };
4869+ activeBrushColor = _parseThemeColorToColor (activeBorderColor, res, requestedTheme, accentColorKey);
48274870 }
4828-
4871+ // DON'T use Transparent here - if it's "Transparent", then it won't
4872+ // be able to hittest for clicks, and then clicking on the border
4873+ // will eat focus.
4874+ _paneResources.focusedBorderBrush = SolidColorBrush (activeBrushColor);
48294875 const auto unfocusedBorderBrushKey = winrt::box_value (L" UnfocusedBorderBrush" );
48304876 if (res.HasKey (unfocusedBorderBrushKey))
48314877 {
4832- // MAKE SURE TO USE ThemeLookup, so that we get the correct resource for
4833- // the requestedTheme, not just the value from the resources (which
4834- // might not respect the settings' requested theme)
4835- auto obj = ThemeLookup (res, requestedTheme, unfocusedBorderBrushKey);
4836- _paneResources.unfocusedBorderBrush = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4878+ inactiveBrushColor = _colorFromKey (res, requestedTheme, unfocusedBorderBrushKey);
48374879 }
4838- else
4880+ // Overwrites the above (or the black default color if there was no unfocusedBorderBrushKey)
4881+ if (inactiveBorderColor)
48394882 {
4840- // DON'T use Transparent here - if it's "Transparent", then it won't
4841- // be able to hittest for clicks, and then clicking on the border
4842- // will eat focus.
4843- _paneResources.unfocusedBorderBrush = SolidColorBrush{ Colors::Black () };
4883+ inactiveBrushColor = _parseThemeColorToColor (inactiveBorderColor, res, requestedTheme, unfocusedBorderBrushKey);
48444884 }
4845-
4885+ // DON'T use Transparent here - if it's "Transparent", then it won't
4886+ // be able to hittest for clicks, and then clicking on the border
4887+ // will eat focus.
4888+ _paneResources.unfocusedBorderBrush = SolidColorBrush (inactiveBrushColor);
48464889 const auto broadcastColorKey = winrt::box_value (L" BroadcastPaneBorderColor" );
48474890 if (res.HasKey (broadcastColorKey))
48484891 {
4849- // MAKE SURE TO USE ThemeLookup
4850- auto obj = ThemeLookup (res, requestedTheme, broadcastColorKey);
4851- _paneResources.broadcastBorderBrush = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4892+ _colorFromKey (res, requestedTheme, broadcastColorKey);
48524893 }
4853- else
4894+ if (broadcastBorderColor)
48544895 {
4855- // DON'T use Transparent here - if it's "Transparent", then it won't
4856- // be able to hittest for clicks, and then clicking on the border
4857- // will eat focus.
4858- _paneResources.broadcastBorderBrush = SolidColorBrush{ Colors::Black () };
4896+ broadcastBrushColor = _parseThemeColorToColor (broadcastBorderColor, res, requestedTheme, broadcastColorKey);
48594897 }
4898+ // DON'T use Transparent here - if it's "Transparent", then it won't
4899+ // be able to hittest for clicks, and then clicking on the border
4900+ // will eat focus.
4901+ _paneResources.broadcastBorderBrush = SolidColorBrush (broadcastBrushColor);
48604902 }
48614903
48624904 void TerminalPage::WindowActivated (const bool activated)
0 commit comments