@@ -4689,10 +4689,13 @@ namespace winrt::TerminalApp::implementation
46894689 }
46904690
46914691 const auto theme = _settings.GlobalSettings ().CurrentTheme ();
4692+ auto paneActiveBorderColor = theme.Pane () ? theme.Pane ().ActiveBorderColor () : nullptr ;
4693+ auto paneInactiveBorderColor = theme.Pane () ? theme.Pane ().InactiveBorderColor () : nullptr ;
4694+ auto broadcastBorderColor = theme.Pane () ? theme.Pane ().BroadcastBorderColor () : nullptr ;
46924695 auto requestedTheme{ theme.RequestedTheme () };
46934696
46944697 {
4695- _updatePaneResources (requestedTheme);
4698+ _updatePaneResources (requestedTheme, paneActiveBorderColor, paneInactiveBorderColor, broadcastBorderColor );
46964699
46974700 for (const auto & tab : _tabs)
46984701 {
@@ -4803,60 +4806,75 @@ namespace winrt::TerminalApp::implementation
48034806 // color of the titlebar)
48044807 // Arguments:
48054808 // - requestedTheme: this should be the currently active Theme for the app
4809+ // - activeBorderColor: the pane's border color for the application when it is active
4810+ // - inactiveBorderColor: the pane's border color for the application when it is inactive
4811+ // - broadcastBorderColor: the pane's border color for the application when it is broadcast
48064812 // Return Value:
48074813 // - <none>
4808- void TerminalPage::_updatePaneResources (const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme)
4814+ void TerminalPage::_updatePaneResources (const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme, const winrt::Microsoft::Terminal::Settings::Model::ThemeColor& activeBorderColor, const winrt::Microsoft::Terminal::Settings::Model::ThemeColor& inactiveBorderColor, const winrt::Microsoft::Terminal::Settings::Model::ThemeColor& broadcastBorderColor )
48094815 {
48104816 const auto res = Application::Current ().Resources ();
48114817 const auto accentColorKey = winrt::box_value (L" SystemAccentColor" );
4818+ auto activeBrushColor = Colors::Black (), inactiveBrushColor = Colors::Black (), broadcastBrushColor = Colors::Black ();
48124819 if (res.HasKey (accentColorKey))
48134820 {
48144821 const auto colorFromResources = ThemeLookup (res, requestedTheme, accentColorKey);
48154822 // If SystemAccentColor is _not_ a Color for some reason, use
48164823 // Transparent as the color, so we don't do this process again on
48174824 // the next pane (by leaving s_focusedBorderBrush nullptr)
4818- auto actualColor = winrt::unbox_value_or<Color>(colorFromResources, Colors::Black ());
4819- _paneResources.focusedBorderBrush = SolidColorBrush (actualColor);
4820- }
4821- else
4825+ activeBrushColor = winrt::unbox_value_or<Color>(colorFromResources, Colors::Black ());
4826+ }
4827+ // Temporary until a suggestion is given to make this nicer (Mutative)
4828+ auto copyTerminalColorObjToUIColorObj = [](winrt::Windows::UI::Color& colorToModify, const winrt::Microsoft::Terminal::Settings::Model::ThemeColor& colorToCopy) {
4829+ // There is most likely a way to use unbox_value_or here but when I tried it, it did not work (always gave the OR value), need feedback on how to improve this
4830+ auto rawColor = colorToCopy.Color ();
4831+ colorToModify.B = rawColor.B ;
4832+ colorToModify.R = rawColor.R ;
4833+ colorToModify.G = rawColor.G ;
4834+ colorToModify.A = rawColor.A ;
4835+ };
4836+ // Overwrites the accent above (or the black default color if there was no accent color)
4837+ if (activeBorderColor)
48224838 {
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 () };
4839+ copyTerminalColorObjToUIColorObj (activeBrushColor, activeBorderColor);
48274840 }
4828-
4841+ // DON'T use Transparent here - if it's "Transparent", then it won't
4842+ // be able to hittest for clicks, and then clicking on the border
4843+ // will eat focus.
4844+ _paneResources.focusedBorderBrush = SolidColorBrush (activeBrushColor);
48294845 const auto unfocusedBorderBrushKey = winrt::box_value (L" UnfocusedBorderBrush" );
48304846 if (res.HasKey (unfocusedBorderBrushKey))
48314847 {
48324848 // MAKE SURE TO USE ThemeLookup, so that we get the correct resource for
48334849 // the requestedTheme, not just the value from the resources (which
48344850 // might not respect the settings' requested theme)
48354851 auto obj = ThemeLookup (res, requestedTheme, unfocusedBorderBrushKey);
4836- _paneResources. unfocusedBorderBrush = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4852+ inactiveBrushColor = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>(). Color ();
48374853 }
4838- else
4854+ // Overwrites the above (or the black default color if there was no unfocusedBorderBrushKey)
4855+ if (inactiveBorderColor)
48394856 {
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 () };
4857+ copyTerminalColorObjToUIColorObj (inactiveBrushColor, inactiveBorderColor);
48444858 }
4845-
4859+ // DON'T use Transparent here - if it's "Transparent", then it won't
4860+ // be able to hittest for clicks, and then clicking on the border
4861+ // will eat focus.
4862+ _paneResources.unfocusedBorderBrush = SolidColorBrush (inactiveBrushColor);
48464863 const auto broadcastColorKey = winrt::box_value (L" BroadcastPaneBorderColor" );
48474864 if (res.HasKey (broadcastColorKey))
48484865 {
48494866 // MAKE SURE TO USE ThemeLookup
48504867 auto obj = ThemeLookup (res, requestedTheme, broadcastColorKey);
4851- _paneResources. broadcastBorderBrush = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>();
4868+ broadcastBrushColor = obj.try_as <winrt::Windows::UI::Xaml::Media::SolidColorBrush>(). Color ();
48524869 }
4853- else
4870+ if (broadcastBorderColor)
48544871 {
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 () };
4872+ copyTerminalColorObjToUIColorObj (broadcastBrushColor, broadcastBorderColor);
48594873 }
4874+ // DON'T use Transparent here - if it's "Transparent", then it won't
4875+ // be able to hittest for clicks, and then clicking on the border
4876+ // will eat focus.
4877+ _paneResources.broadcastBorderBrush = SolidColorBrush (broadcastBrushColor);
48604878 }
48614879
48624880 void TerminalPage::WindowActivated (const bool activated)
0 commit comments