Skip to content

Commit 97b01e4

Browse files
committed
Setting to set pane highlight active, inactive and broadcast color
This commit adds a new setting in which you can configure the active highlight color of panes aswell as inactive and broadcast.
1 parent 2d64a3a commit 97b01e4

File tree

7 files changed

+96
-26
lines changed

7 files changed

+96
-26
lines changed

doc/cascadia/profiles.schema.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,24 @@
20002000
}
20012001
}
20022002
},
2003+
"PaneTheme": {
2004+
"additionalProperties": false,
2005+
"description": "A set of properties for customizing the appearance of the panes",
2006+
"properties": {
2007+
"activeBorderColor": {
2008+
"description": "The color of the pane border when the pane is active",
2009+
"$ref": "#/$defs/ThemeColor"
2010+
},
2011+
"inactiveBorderColor": {
2012+
"description": "The color of the pane border when the pane is inactive",
2013+
"$ref": "#/$defs/ThemeColor"
2014+
},
2015+
"broadcastBorderColor": {
2016+
"description": "The color of the pane border when broadcasted",
2017+
"$ref": "#/$defs/ThemeColor"
2018+
}
2019+
}
2020+
},
20032021
"WindowTheme": {
20042022
"additionalProperties": false,
20052023
"description": "A set of properties for customizing the appearance of the window itself",
@@ -2056,6 +2074,9 @@
20562074
},
20572075
"window": {
20582076
"$ref": "#/$defs/WindowTheme"
2077+
},
2078+
"pane": {
2079+
"$ref": "#/$defs/PaneTheme"
20592080
}
20602081
}
20612082
},

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

src/cascadia/TerminalApp/TerminalPage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ namespace winrt::TerminalApp::implementation
519519

520520
void _updateThemeColors();
521521
void _updateAllTabCloseButtons();
522-
void _updatePaneResources(const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme);
522+
void _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);
523523

524524
safe_void_coroutine _ControlCompletionsChangedHandler(const winrt::Windows::Foundation::IInspectable sender, const winrt::Microsoft::Terminal::Control::CompletionsChangedEventArgs args);
525525

src/cascadia/TerminalSettingsModel/MTSMSettings.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ Author(s):
147147
X(winrt::Microsoft::Terminal::Settings::Model::WindowTheme, Window, "window", nullptr) \
148148
X(winrt::Microsoft::Terminal::Settings::Model::SettingsTheme, Settings, "settings", nullptr) \
149149
X(winrt::Microsoft::Terminal::Settings::Model::TabRowTheme, TabRow, "tabRow", nullptr) \
150-
X(winrt::Microsoft::Terminal::Settings::Model::TabTheme, Tab, "tab", nullptr)
150+
X(winrt::Microsoft::Terminal::Settings::Model::TabTheme, Tab, "tab", nullptr) \
151+
X(winrt::Microsoft::Terminal::Settings::Model::PaneTheme, Pane, "pane", nullptr)
151152

152153
#define MTSM_THEME_WINDOW_SETTINGS(X) \
153154
X(winrt::Windows::UI::Xaml::ElementTheme, RequestedTheme, "applicationTheme", winrt::Windows::UI::Xaml::ElementTheme::Default) \
@@ -163,6 +164,11 @@ Author(s):
163164
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Background, "background", nullptr) \
164165
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, UnfocusedBackground, "unfocusedBackground", nullptr)
165166

167+
#define MTSM_THEME_PANE_SETTINGS(X) \
168+
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, ActiveBorderColor, "activeBorderColor", nullptr) \
169+
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, InactiveBorderColor, "inactiveBorderColor", nullptr) \
170+
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, BroadcastBorderColor, "broadcastBorderColor", nullptr)
171+
166172
#define MTSM_THEME_TAB_SETTINGS(X) \
167173
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Background, "background", nullptr) \
168174
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, UnfocusedBackground, "unfocusedBackground", nullptr) \

src/cascadia/TerminalSettingsModel/Theme.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "SettingsTheme.g.h"
1313
#include "ThemeColor.g.cpp"
1414
#include "WindowTheme.g.cpp"
15+
#include "PaneTheme.g.cpp"
1516
#include "TabRowTheme.g.cpp"
1617
#include "TabTheme.g.cpp"
1718
#include "ThemePair.g.cpp"
@@ -60,6 +61,7 @@ THEME_OBJECT(WindowTheme, MTSM_THEME_WINDOW_SETTINGS);
6061
THEME_OBJECT(SettingsTheme, MTSM_THEME_SETTINGS_SETTINGS);
6162
THEME_OBJECT(TabRowTheme, MTSM_THEME_TABROW_SETTINGS);
6263
THEME_OBJECT(TabTheme, MTSM_THEME_TAB_SETTINGS);
64+
THEME_OBJECT(PaneTheme, MTSM_THEME_PANE_SETTINGS);
6365

6466
#undef THEME_SETTINGS_COPY
6567
#undef THEME_SETTINGS_TO_JSON
@@ -224,6 +226,7 @@ THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, WindowTheme,
224226
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, SettingsTheme, MTSM_THEME_SETTINGS_SETTINGS);
225227
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, TabRowTheme, MTSM_THEME_TABROW_SETTINGS);
226228
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, TabTheme, MTSM_THEME_TAB_SETTINGS);
229+
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, PaneTheme, MTSM_THEME_PANE_SETTINGS);
227230

228231
#undef THEME_SETTINGS_FROM_JSON
229232
#undef THEME_SETTINGS_TO_JSON
@@ -254,6 +257,10 @@ winrt::com_ptr<Theme> Theme::Copy() const
254257
{
255258
theme->_Tab = *winrt::get_self<implementation::TabTheme>(_Tab)->Copy();
256259
}
260+
if (_Pane)
261+
{
262+
theme->_Pane = *winrt::get_self<implementation::PaneTheme>(_Pane)->Copy();
263+
}
257264
if (_Settings)
258265
{
259266
theme->_Settings = *winrt::get_self<implementation::SettingsTheme>(_Settings)->Copy();
@@ -334,6 +341,13 @@ void Theme::LogSettingChanges(std::set<std::string>& changes, const std::string_
334341
const auto outerJsonKey = outerTabJsonKey;
335342
MTSM_THEME_TAB_SETTINGS(LOG_IF_SET)
336343
}
344+
345+
if (isPaneSet)
346+
{
347+
const auto obj = _Pane;
348+
const auto outerJsonKey = outerPaneJsonKey;
349+
MTSM_THEME_PANE_SETTINGS(LOG_IF_SET);
350+
}
337351
#undef LOG_IF_SET
338352
#undef GENERATE_SET_CHECK_AND_JSON_KEYS
339353
#pragma warning(pop)

src/cascadia/TerminalSettingsModel/Theme.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Author(s):
2323
#include "WindowTheme.g.h"
2424
#include "TabRowTheme.g.h"
2525
#include "TabTheme.g.h"
26+
#include "PaneTheme.g.h"
2627
#include "ThemePair.g.h"
2728
#include "Theme.g.h"
2829

@@ -85,6 +86,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
8586
THEME_OBJECT(SettingsTheme, MTSM_THEME_SETTINGS_SETTINGS);
8687
THEME_OBJECT(TabRowTheme, MTSM_THEME_TABROW_SETTINGS);
8788
THEME_OBJECT(TabTheme, MTSM_THEME_TAB_SETTINGS);
89+
THEME_OBJECT(PaneTheme, MTSM_THEME_PANE_SETTINGS);
8890

8991
struct Theme : ThemeT<Theme>
9092
{

src/cascadia/TerminalSettingsModel/Theme.idl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ namespace Microsoft.Terminal.Settings.Model
7171
ThemeColor UnfocusedBackground { get; };
7272
}
7373

74+
runtimeclass PaneTheme {
75+
ThemeColor ActiveBorderColor { get; };
76+
ThemeColor InactiveBorderColor { get; };
77+
ThemeColor BroadcastBorderColor { get; };
78+
}
79+
7480
runtimeclass TabTheme {
7581
ThemeColor Background { get; };
7682
ThemeColor UnfocusedBackground { get; };
@@ -93,6 +99,9 @@ namespace Microsoft.Terminal.Settings.Model
9399
// tabRow.* Namespace
94100
TabRowTheme TabRow { get; };
95101

102+
// pane.* Namespace
103+
PaneTheme Pane { get; };
104+
96105
// tab.* Namespace
97106
TabTheme Tab { get; };
98107

0 commit comments

Comments
 (0)