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

Set Progress ring color based on the status from the running process #15847

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TabHeaderControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
MinWidth="0"
MinHeight="0"
Margin="3,0,8,0"
Foreground="{x:Bind TabStatus.ProgressColor, Mode=OneWay}"
IsActive="{x:Bind TabStatus.IsProgressRingActive, Mode=OneWay}"
IsIndeterminate="{x:Bind TabStatus.IsProgressRingIndeterminate, Mode=OneWay}"
Visibility="{x:Bind TabStatus.IsProgressRingActive, Mode=OneWay}"
Expand Down
8 changes: 8 additions & 0 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,14 @@ namespace winrt::TerminalApp::implementation

const auto progressValue = gsl::narrow<uint32_t>(state.Progress());
_tabStatus.ProgressValue(progressValue);

const auto color =
(taskbarState == 2) ?
winrt::Windows::UI::Colors::Red() :
((taskbarState == 4) ?
winrt::Windows::UI::Colors::Orange() :
winrt::Windows::UI::Colors::Green());
Comment on lines +1041 to +1046
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer a switch statement here for readability!

Also for tastbarState = 3 we should probably set it to the default color (it currently adopts the color based on the previous state, so it could be any of red/orange/green depending).

_tabStatus.ProgressColor(winrt::Windows::UI::Xaml::Media::SolidColorBrush(color));
}
// Hide the tab icon (the progress ring is placed over it)
HideIcon(true);
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/TerminalTabStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "TerminalTabStatus.g.h"
#include <winrt/windows.ui.core.h>

namespace winrt::TerminalApp::implementation
{
Expand All @@ -19,6 +20,7 @@ namespace winrt::TerminalApp::implementation
WINRT_OBSERVABLE_PROPERTY(bool, IsReadOnlyActive, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(uint32_t, ProgressValue, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(bool, IsInputBroadcastActive, _PropertyChangedHandlers);
WINRT_OBSERVABLE_PROPERTY(winrt::Windows::UI::Xaml::Media::SolidColorBrush, ProgressColor, _PropertyChangedHandlers, winrt::Windows::UI::Colors::Green());
};
}

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalTabStatus.idl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ namespace TerminalApp
UInt32 ProgressValue { get; set; };
Boolean IsReadOnlyActive { get; set; };
Boolean IsInputBroadcastActive { get; set; };
Windows.UI.Xaml.Media.SolidColorBrush ProgressColor { get; set; };
}
}