Skip to content

Add support for tab.unfocusedBackground#13689

Merged
zadjii-msft merged 24 commits intomainfrom
dev/migrie/b/13684-inactiveTabBg
Aug 31, 2022
Merged

Add support for tab.unfocusedBackground#13689
zadjii-msft merged 24 commits intomainfrom
dev/migrie/b/13684-inactiveTabBg

Conversation

@zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Aug 5, 2022

Does what it sounds like on the label.

This is important, because when unset, the tab will use the active Background color to create an inactive BG, which maybe isn't what we want. Consider:

  • a bright cyan active BG,
  • and terminalBG for the tabRow bg.

Without an unfocusedBackground setting, all the tabs will still appear cyan when unfocused, which is extra gross.

As a judgement call, I made terminalBackground and accent use 30% opacity when set, to match the existing coloration.

See also #13554. If we want to make the default theme tab.background: terminalBackground, we should make tab.unfocusedBackground transparent (#00000000) by default. Otherwise, a Campell (#0c0c0c) tab on any tab row will still have a faint tab visible.

This also does a lot of code shuffling, to get SettingsUI tabs to behave sensibly. We want those tabs to have (#0c0c0c, #ffffff) colored BGs for terminalBackground (see mail thread).

We also don't want dark focused tabs colors, combined with light tab row colors, combined with transparent unfocused tabs, to result in unfocused tabs having white-on-white text. That's gross. So that's been added to this PR in b38b704.

@ghost ghost added Area-Theming Anything related to the theming of elements of the window Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Aug 5, 2022
@ghost ghost added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) labels Aug 16, 2022
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Welp, definitely reviewed this out of order haha. Didn't realize most of the new stuff in TabBase came straight out of TerminalTab. I've got a lot of comments, so I'll circle back to this PR after they're addressed.

Comment on lines +96 to +97
// Look through the theme dictionaries we defined:
for (const auto& [dictionaryKey, dict] : dictionary.ThemeDictionaries())
Copy link
Member

Choose a reason for hiding this comment

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

So the heuristic is if a Source isn't defined, we assume it's ours? And we can guarantee that the Source will always be set by MUX?

Should we go the extra mile and set a source ourselves? Like "TerminalAppResources" or something like that? 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, yea. I don't think mu will ever not set that.

I honestly don't know the right way to set our own source. We're just looking it up out of the App.xaml resources, I'm not sure that gets to have a Source unless we move it to a separate file. idk.

Comment on lines +442 to +467
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderBackgroundSelected"), selectedTabBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderBackgroundPointerOver"), hoverTabBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderBackgroundPressed"), selectedTabBrush);

// Similarly, TabViewItem().Foreground() sets the color for the text
// when the TabViewItem isn't selected, but not when it is hovered,
// pressed, dragged, or selected, so we'll need to just set them all
// anyways.
TabViewItem().Foreground(deselectedFontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderForeground"), deselectedFontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderForegroundSelected"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderForegroundPointerOver"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderForegroundPressed"), fontBrush);

TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderCloseButtonForeground"), deselectedFontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderCloseButtonForegroundPressed"), secondaryFontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderCloseButtonForegroundPointerOver"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderPressedCloseButtonForeground"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderPointerOverCloseButtonForeground"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderSelectedCloseButtonForeground"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderCloseButtonBackgroundPressed"), subtleFillColorTertiaryBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderCloseButtonBackgroundPointerOver"), subtleFillColorSecondaryBrush);

TabViewItem().Resources().Insert(winrt::box_value(L"TabViewButtonForegroundActiveTab"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewButtonForegroundPressed"), fontBrush);
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewButtonForegroundPointerOver"), fontBrush);
Copy link
Member

Choose a reason for hiding this comment

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

Would there be enough benefit to magic static-ify all of these winrt::box_value(L"<resource name>")?

Copy link
Member

Choose a reason for hiding this comment

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

hmm... The strings also seem to be used below in _ClearTabBackgroundColor. Maybe we should static-ify the strings themselves? Idk if/when it's worth it though 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

meh we maybe could. This is all copypasta from TerminalTab and this hasn't ever seemed like an issue before.

@github-actions

This comment has been minimized.

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

👍👍

@carlos-zamora carlos-zamora added the Needs-Second It's a PR that needs another sign-off label Aug 30, 2022
@ghost ghost requested review from DHowett, PankajBhojwani and lhecker August 30, 2022 20:24
return std::nullopt;
}

void TabBase::ThemeColor(const winrt::Microsoft::Terminal::Settings::Model::ThemeColor& focused,
Copy link
Member Author

Choose a reason for hiding this comment

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

note to reviewers: This mostly just came from TerminalTab.cpp so go ahead and hit that . and open the two SxS
image

Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
@github-actions

This comment has been minimized.

[11:48 AM] Leonard Hecker
of course not - it's "alpha A inversed"

[11:49 AM] Leonard Hecker
why is that so hard to understand /s lmao
@zadjii-msft zadjii-msft merged commit f07b9e1 into main Aug 31, 2022
@zadjii-msft zadjii-msft deleted the dev/migrie/b/13684-inactiveTabBg branch August 31, 2022 17:48
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

👍🏻

@ghost ghost removed the Needs-Second It's a PR that needs another sign-off label Aug 31, 2022
ghost pushed a commit that referenced this pull request Sep 9, 2022
The color of inactive tab text is incorrect since #13689 due to the introduction
of `til::color::layer_over` which incorrectly calculated the RGB values.

## Validation Steps Performed
* Added unit tests ✅

Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
@ghost
Copy link

ghost commented Sep 13, 2022

🎉Windows Terminal Preview v1.16.252 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Theming Anything related to the theming of elements of the window Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Issue-Task It's a feature request, but it doesn't really need a major design. Priority-3 A description (P3) Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inactive tab BG color (tab.inactiveBackground) Light tab color causes unreadably dark foreground (text) color when the tab is not focused

4 participants