Skip to content

Commit c5e01b0

Browse files
committed
Add color indicator for tab switch menu (CTRL+T)
1 parent 93d592b commit c5e01b0

File tree

8 files changed

+34
-0
lines changed

8 files changed

+34
-0
lines changed

src/cascadia/TerminalApp/CommandPalette.xaml

+7
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@
205205
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsInputBroadcastActive, Mode=OneWay}" />
206206

207207
</StackPanel>
208+
209+
<Ellipse Grid.Column="4"
210+
Width="8"
211+
Height="8"
212+
HorizontalAlignment="Center"
213+
VerticalAlignment="Center"
214+
Fill="{x:Bind mtu:Converters.ColorToBrush(Item.TabColorIndicator), Mode=OneWay}" />
208215
</Grid>
209216
</DataTemplate>
210217

src/cascadia/TerminalApp/PaletteItem.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace winrt::TerminalApp::implementation
1515

1616
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, PropertyChanged.raise);
1717
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Icon, PropertyChanged.raise);
18+
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Color, TabColorIndicator, PropertyChanged.raise);
1819
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, KeyChordText, PropertyChanged.raise);
1920
};
2021
}

src/cascadia/TerminalApp/PaletteItem.idl

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace TerminalApp
88
String Name;
99
String KeyChordText;
1010
String Icon;
11+
Windows.UI.Color TabColorIndicator;
1112
Windows.UI.Xaml.Controls.IconElement ResolvedIcon { get; };
1213
}
1314
}

src/cascadia/TerminalApp/TabBase.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,22 @@ namespace winrt::TerminalApp::implementation
340340
{
341341
_ClearTabBackgroundColor();
342342
}
343+
344+
_UpdateTabColorIndicator();
345+
}
346+
347+
void TabBase::_UpdateTabColorIndicator()
348+
{
349+
const auto currentColor = GetTabColor();
350+
351+
if (currentColor.has_value())
352+
{
353+
TabColorIndicator(currentColor.value());
354+
}
355+
else
356+
{
357+
TabColorIndicator(Windows::UI::Colors::Transparent());
358+
}
343359
}
344360

345361
// Method Description:

src/cascadia/TerminalApp/TabBase.h

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ namespace winrt::TerminalApp::implementation
4545

4646
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Title, PropertyChanged.raise);
4747
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Icon, PropertyChanged.raise);
48+
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Color, TabColorIndicator, PropertyChanged.raise);
4849
WINRT_OBSERVABLE_PROPERTY(bool, ReadOnly, PropertyChanged.raise, false);
4950
WINRT_PROPERTY(winrt::Microsoft::UI::Xaml::Controls::TabViewItem, TabViewItem, nullptr);
5051

@@ -78,6 +79,7 @@ namespace winrt::TerminalApp::implementation
7879

7980
void _RecalculateAndApplyTabColor();
8081
void _ApplyTabColorOnUIThread(const winrt::Windows::UI::Color& color);
82+
void _UpdateTabColorIndicator();
8183
void _ClearTabBackgroundColor();
8284
void _RefreshVisualState();
8385
virtual winrt::Windows::UI::Xaml::Media::Brush _BackgroundBrush() = 0;

src/cascadia/TerminalApp/TabBase.idl

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace TerminalApp
88
{
99
String Title { get; };
1010
String Icon { get; };
11+
Windows.UI.Color TabColorIndicator { get; };
1112
Boolean ReadOnly { get; };
1213
Microsoft.Terminal.Settings.Model.TabCloseButtonVisibility CloseButtonVisibility { get; set; };
1314

src/cascadia/TerminalApp/TabPaletteItem.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ namespace winrt::TerminalApp::implementation
2424
{
2525
Name(tab.Title());
2626
Icon(tab.Icon());
27+
TabColorIndicator(tab.TabColorIndicator());
2728

2829
_tabChangedRevoker = tab.PropertyChanged(winrt::auto_revoke, [weakThis{ get_weak() }](auto& sender, auto& e) {
2930
auto item{ weakThis.get() };
@@ -40,6 +41,10 @@ namespace winrt::TerminalApp::implementation
4041
{
4142
item->Icon(senderTab.Icon());
4243
}
44+
else if (changedProperty == L"TabColorIndicator")
45+
{
46+
item->TabColorIndicator(senderTab.TabColorIndicator());
47+
}
4348
}
4449
});
4550

src/cascadia/TerminalApp/pch.h

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <winrt/Windows.UI.Xaml.Automation.Peers.h>
4141
#include <winrt/Windows.UI.Xaml.Controls.h>
4242
#include <winrt/Windows.UI.Xaml.Controls.Primitives.h>
43+
#include <winrt/Windows.UI.Xaml.Shapes.h>
4344
#include <winrt/Windows.UI.Xaml.Data.h>
4445
#include <winrt/Windows.UI.Xaml.Documents.h>
4546
#include <winrt/Windows.UI.Xaml.Input.h>

0 commit comments

Comments
 (0)