Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ATS tab status indicators #9076

Merged
6 commits merged into from Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/cascadia/TerminalApp/CommandPalette.xaml
Expand Up @@ -133,10 +133,10 @@ the MIT License. See LICENSE in the project root for license information. -->

<mux:ProgressRing
Grid.Column="0"
IsActive="{x:Bind Item.(local:TabPaletteItem.IsProgressRingActive), Mode=OneWay}"
Visibility="{x:Bind Item.(local:TabPaletteItem.IsProgressRingActive), Mode=OneWay}"
IsIndeterminate="{x:Bind Item.(local:TabPaletteItem.IsProgressRingIndeterminate), Mode=OneWay}"
Value="{x:Bind Item.(local:TabPaletteItem.ProgressValue), Mode=OneWay}"
IsActive="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsProgressRingActive, Mode=OneWay}"
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsProgressRingActive, Mode=OneWay}"
IsIndeterminate="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsProgressRingIndeterminate, Mode=OneWay}"
Value="{x:Bind Item.(local:TabPaletteItem.TabStatus).ProgressValue, Mode=OneWay}"
MinHeight="0"
MinWidth="0"
Height="15"
Expand All @@ -163,17 +163,25 @@ the MIT License. See LICENSE in the project root for license information. -->

<FontIcon
FontFamily="Segoe MDL2 Assets"
Visibility="{x:Bind Item.(local:TabPaletteItem.BellIndicator), Mode=OneWay}"
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).BellIndicator, Mode=OneWay}"
Glyph="&#xEA8F;"
FontSize="12"
Margin="0,0,8,0"/>

<FontIcon
FontFamily="Segoe MDL2 Assets"
Visibility="{x:Bind Item.(local:TabPaletteItem.IsPaneZoomed), Mode=OneWay}"
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsPaneZoomed, Mode=OneWay}"
Glyph="&#xE8A3;"
FontSize="12"
Margin="0,0,8,0"/>

<FontIcon x:Name="HeaderLockIcon"
FontFamily="Segoe MDL2 Assets"
Visibility="{x:Bind Item.(local:TabPaletteItem.TabStatus).IsReadOnlyActive, Mode=OneWay}"
Glyph="&#xE72E;"
FontSize="12"
Margin="0,0,8,0"/>

</StackPanel>
</Grid>
</ListViewItem>
Expand Down
7 changes: 1 addition & 6 deletions src/cascadia/TerminalApp/TabHeaderControl.h
Expand Up @@ -22,13 +22,8 @@ namespace winrt::TerminalApp::implementation

WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
OBSERVABLE_GETSET_PROPERTY(winrt::hstring, Title, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, IsPaneZoomed, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(double, RenamerMaxWidth, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, IsProgressRingActive, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, IsProgressRingIndeterminate, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, BellIndicator, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(uint32_t, ProgressValue, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, IsReadOnlyActive, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, _PropertyChangedHandlers);

private:
bool _receivedKeyDown{ false };
Expand Down
9 changes: 3 additions & 6 deletions src/cascadia/TerminalApp/TabHeaderControl.idl
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import "TerminalTabStatus.idl";

namespace TerminalApp
{
Expand All @@ -8,17 +9,13 @@ namespace TerminalApp
[default_interface] runtimeclass TabHeaderControl : Windows.UI.Xaml.Controls.UserControl, Windows.UI.Xaml.Data.INotifyPropertyChanged
{
String Title { get; set; };
Boolean IsPaneZoomed { get; set; };
Double RenamerMaxWidth { get; set; };
Boolean IsProgressRingActive { get; set; };
Boolean IsProgressRingIndeterminate { get; set; };
Boolean BellIndicator { get; set; };
UInt32 ProgressValue { get; set; };
Boolean IsReadOnlyActive { get; set; };

TabHeaderControl();
void BeginRename();

TerminalTabStatus TabStatus { get; set; };

event TitleChangeRequestedArgs TitleChangeRequested;
}
}
16 changes: 8 additions & 8 deletions src/cascadia/TerminalApp/TabHeaderControl.xaml
Expand Up @@ -27,14 +27,14 @@ the MIT License. See LICENSE in the project root for license information. -->
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</UserControl.Resources>

<StackPanel x:Name="HeaderStackPanel"
Orientation="Horizontal">
<mux:ProgressRing x:Name="HeaderProgressRing"
IsActive="{x:Bind IsProgressRingActive, Mode=OneWay}"
Visibility="{x:Bind IsProgressRingActive, Mode=OneWay}"
IsIndeterminate="{x:Bind IsProgressRingIndeterminate, Mode=OneWay}"
Value="{x:Bind ProgressValue, Mode=OneWay}"
IsActive="{x:Bind TabStatus.IsProgressRingActive, Mode=OneWay}"
Visibility="{x:Bind TabStatus.IsProgressRingActive, Mode=OneWay}"
IsIndeterminate="{x:Bind TabStatus.IsProgressRingIndeterminate, Mode=OneWay}"
Value="{x:Bind TabStatus.ProgressValue, Mode=OneWay}"
MinHeight="0"
MinWidth="0"
Height="15"
Expand All @@ -45,19 +45,19 @@ the MIT License. See LICENSE in the project root for license information. -->
and use a negative margin for the progress ring here to put it where the icon would be-->
<FontIcon x:Name="HeaderBellIndicator"
FontFamily="Segoe MDL2 Assets"
Visibility="{x:Bind BellIndicator, Mode=OneWay}"
Visibility="{x:Bind TabStatus.BellIndicator, Mode=OneWay}"
Glyph="&#xEA8F;"
FontSize="12"
Margin="0,0,8,0"/>
<FontIcon x:Name="HeaderZoomIcon"
FontFamily="Segoe MDL2 Assets"
Visibility="{x:Bind IsPaneZoomed, Mode=OneWay}"
Visibility="{x:Bind TabStatus.IsPaneZoomed, Mode=OneWay}"
Glyph="&#xE8A3;"
FontSize="12"
Margin="0,0,8,0"/>
<FontIcon x:Name="HeaderLockIcon"
FontFamily="Segoe MDL2 Assets"
Visibility="{x:Bind IsReadOnlyActive, Mode=OneWay}"
Visibility="{x:Bind TabStatus.IsReadOnlyActive, Mode=OneWay}"
Glyph="&#xE72E;"
FontSize="12"
Margin="0,0,8,0"/>
Expand Down
52 changes: 13 additions & 39 deletions src/cascadia/TerminalApp/TabPaletteItem.cpp
Expand Up @@ -25,18 +25,6 @@ namespace winrt::TerminalApp::implementation
Name(tab.Title());
Icon(tab.Icon());

if (const auto terminalTab{ tab.try_as<winrt::TerminalApp::TerminalTab>() })
{
if (const auto tabImpl{ winrt::get_self<winrt::TerminalApp::implementation::TerminalTab>(terminalTab) })
{
IsProgressRingActive(tabImpl->IsProgressRingActive());
IsProgressRingIndeterminate(tabImpl->IsProgressRingIndeterminate());
ProgressValue(tabImpl->ProgressValue());
BellIndicator(tabImpl->BellIndicator());
IsPaneZoomed(tabImpl->IsPaneZoomed());
}
}

_tabChangedRevoker = tab.PropertyChanged(winrt::auto_revoke, [weakThis{ get_weak() }](auto& sender, auto& e) {
auto item{ weakThis.get() };
auto senderTab{ sender.try_as<winrt::TerminalApp::TabBase>() };
Expand All @@ -52,34 +40,20 @@ namespace winrt::TerminalApp::implementation
{
item->Icon(senderTab.Icon());
}

if (const auto terminalTab{ senderTab.try_as<winrt::TerminalApp::TerminalTab>() })
{
if (const auto tabImpl{ winrt::get_self<winrt::TerminalApp::implementation::TerminalTab>(terminalTab) })
{
if (changedProperty == L"IsProgressRingActive")
{
item->IsProgressRingActive(tabImpl->IsProgressRingActive());
}
else if (changedProperty == L"IsProgressRingIndeterminate")
{
item->IsProgressRingIndeterminate(tabImpl->IsProgressRingIndeterminate());
}
else if (changedProperty == L"ProgressValue")
{
item->ProgressValue(tabImpl->ProgressValue());
}
else if (changedProperty == L"IsPaneZoomed")
{
item->IsPaneZoomed(tabImpl->IsPaneZoomed());
}
else if (changedProperty == L"BellIndicator")
{
item->BellIndicator(tabImpl->BellIndicator());
}
}
}
}
});

if (const auto terminalTab{ tab.try_as<winrt::TerminalApp::TerminalTab>() })
{
const auto status = terminalTab.TabStatus();
TabStatus(status);

_tabStatusChangedRevoker = status.PropertyChanged(winrt::auto_revoke, [weakThis{ get_weak() }](auto& /*sender*/, auto& /*e*/) {
// Sometimes nested bindings do not get updated,
// thus let's notify property changed on TabStatus when one of its properties changes
auto item{ weakThis.get() };
item->_PropertyChangedHandlers(*item, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"TabStatus" });
});
}
}
}
8 changes: 2 additions & 6 deletions src/cascadia/TerminalApp/TabPaletteItem.h
Expand Up @@ -19,16 +19,12 @@ namespace winrt::TerminalApp::implementation
return _tab.get();
}

OBSERVABLE_GETSET_PROPERTY(bool, IsProgressRingActive, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, IsProgressRingIndeterminate, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(uint32_t, ProgressValue, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, IsPaneZoomed, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(bool, BellIndicator, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, _PropertyChangedHandlers);

private:
winrt::weak_ref<winrt::TerminalApp::TabBase> _tab;
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _tabChangedRevoker;
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _tabHeaderChangedRevoker;
Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _tabStatusChangedRevoker;
};
}

Expand Down
7 changes: 2 additions & 5 deletions src/cascadia/TerminalApp/TabPaletteItem.idl
Expand Up @@ -3,6 +3,7 @@

import "PaletteItem.idl";
import "TabBase.idl";
import "TerminalTabStatus.idl";

namespace TerminalApp
{
Expand All @@ -12,10 +13,6 @@ namespace TerminalApp

TabBase Tab { get; };

Boolean IsProgressRingActive { get; set; };
Boolean IsProgressRingIndeterminate { get; set; };
UInt32 ProgressValue { get; set; };
Boolean IsPaneZoomed { get; set; };
Boolean BellIndicator { get; set; };
TerminalTabStatus TabStatus { get; };
Don-Vito marked this conversation as resolved.
Show resolved Hide resolved
}
}
11 changes: 11 additions & 0 deletions src/cascadia/TerminalApp/TerminalAppLib.vcxproj
Expand Up @@ -97,6 +97,10 @@
<DependentUpon>TerminalPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="TerminalTabStatus.h">
<DependentUpon>TerminalTabStatus.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="TitlebarControl.h">
<DependentUpon>TitlebarControl.xaml</DependentUpon>
</ClInclude>
Expand Down Expand Up @@ -173,6 +177,10 @@
<DependentUpon>TerminalPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="TerminalTabStatus.cpp">
<DependentUpon>TerminalTabStatus.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="TitlebarControl.cpp">
<DependentUpon>TitlebarControl.xaml</DependentUpon>
</ClCompile>
Expand Down Expand Up @@ -255,6 +263,9 @@
<DependentUpon>TerminalPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Midl>
<Midl Include="TerminalTabStatus.idl">
<SubType>Designer</SubType>
</Midl>
<Midl Include="TitlebarControl.idl">
<DependentUpon>TitlebarControl.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down
5 changes: 4 additions & 1 deletion src/cascadia/TerminalApp/TerminalAppLib.vcxproj.filters
Expand Up @@ -131,6 +131,9 @@
<Midl Include="HighlightedText.idl">
<Filter>highlightedText</Filter>
</Midl>
<Midl Include="TerminalTabStatus.idl">
<Filter>tab</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down Expand Up @@ -204,4 +207,4 @@
<Filter>app</Filter>
</ApplicationDefinition>
</ItemGroup>
</Project>
</Project>
32 changes: 16 additions & 16 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Expand Up @@ -43,6 +43,8 @@ namespace winrt::TerminalApp::implementation
_MakeTabViewItem();
_CreateContextMenu();

_headerControl.TabStatus(_tabStatus);

// Add an event handler for the header control to tell us when they want their title to change
_headerControl.TitleChangeRequested([weakThis = get_weak()](auto&& title) {
if (auto tab{ weakThis.get() })
Expand Down Expand Up @@ -162,7 +164,7 @@ namespace winrt::TerminalApp::implementation
lastFocusedControl.TaskbarProgressChanged();
}
// When we gain focus, remove the bell indicator if it is active
if (_headerControl.BellIndicator())
if (_tabStatus.BellIndicator())
{
ShowBellIndicator(false);
}
Expand Down Expand Up @@ -288,8 +290,7 @@ namespace winrt::TerminalApp::implementation

if (auto tab{ weakThis.get() })
{
tab->_headerControl.BellIndicator(show);
BellIndicator(show);
_tabStatus.BellIndicator(show);
}
}

Expand Down Expand Up @@ -579,25 +580,25 @@ namespace winrt::TerminalApp::implementation
if (tab->GetActiveTerminalControl().TaskbarState() == 3)
{
// 3 is the indeterminate state, set the progress ring as such
tab->_headerControl.IsProgressRingIndeterminate(true);
tab->_tabStatus.IsProgressRingIndeterminate(true);
}
else
{
// any non-indeterminate state has a value, set the progress ring as such
tab->_headerControl.IsProgressRingIndeterminate(false);
tab->_headerControl.ProgressValue(gsl::narrow<uint32_t>(tab->GetActiveTerminalControl().TaskbarProgress()));
tab->_tabStatus.IsProgressRingIndeterminate(false);

const auto progressValue = gsl::narrow<uint32_t>(tab->GetActiveTerminalControl().TaskbarProgress());
tab->_tabStatus.ProgressValue(progressValue);
}
// Hide the tab icon (the progress ring is placed over it)
tab->HideIcon(true);
tab->_headerControl.IsProgressRingActive(true);
tab->IsProgressRingActive(true);
tab->_tabStatus.IsProgressRingActive(true);
}
else
{
// Show the tab icon
tab->HideIcon(false);
tab->_headerControl.IsProgressRingActive(false);
tab->IsProgressRingActive(false);
tab->_tabStatus.IsProgressRingActive(false);
Don-Vito marked this conversation as resolved.
Show resolved Hide resolved
}
}
});
Expand Down Expand Up @@ -676,7 +677,7 @@ namespace winrt::TerminalApp::implementation
}
tab->_focusState = WUX::FocusState::Programmatic;
// This tab has gained focus, remove the bell indicator if it is active
if (tab->_headerControl.BellIndicator())
if (tab->_tabStatus.BellIndicator())
{
tab->ShowBellIndicator(false);
}
Expand Down Expand Up @@ -1106,17 +1107,15 @@ namespace winrt::TerminalApp::implementation
_zoomedPane = _activePane;
_rootPane->Maximize(_zoomedPane);
// Update the tab header to show the magnifying glass
_headerControl.IsPaneZoomed(true);
IsPaneZoomed(true);
_tabStatus.IsPaneZoomed(true);
Content(_zoomedPane->GetRootElement());
}
void TerminalTab::ExitZoom()
{
_rootPane->Restore(_zoomedPane);
_zoomedPane = nullptr;
// Update the tab header to hide the magnifying glass
_headerControl.IsPaneZoomed(false);
IsPaneZoomed(false);
_tabStatus.IsPaneZoomed(false);
Content(_rootPane->GetRootElement());
}

Expand Down Expand Up @@ -1145,7 +1144,8 @@ namespace winrt::TerminalApp::implementation
const auto control = GetActiveTerminalControl();
if (control)
{
_headerControl.IsReadOnlyActive(control.ReadOnly());
const auto isReadOnlyActive = control.ReadOnly();
_tabStatus.IsReadOnlyActive(isReadOnlyActive);
}

ReadOnly(_rootPane->ContainsReadOnly());
Expand Down