Fix the tab color, part III (#11413)

I've had a hard time with the tab colors this week.

Turns out that setting the background to nullptr will make the tabviewitem invisible to hit tests. `Transparent`, on the other hand, is totally valid, and the expected default. 

Tabs as of this commit:

![tab-color-fix-3](https://user-images.githubusercontent.com/18356694/135915272-ff90b28b-f260-493e-bf0b-3450b4702dce.gif)

## PR Checklist
* [x] Closes #11382
* [x] I work here

This low-key reverts a bit of #11369, which fixed #11294, which regressed in #11240
This commit is contained in:
Mike Griese 2021-10-05 10:28:24 -05:00 committed by GitHub
parent 3f1befb06e
commit 6295c8cc45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 9 deletions

View File

@ -1461,15 +1461,10 @@ namespace winrt::TerminalApp::implementation
// when the TabViewItem is unselected. So we still need to set the other
// properties ourselves.
//
// GH#11294: DESPITE the fact that there's a Background() API that we
// could just call like:
//
// TabViewItem().Background(deselectedTabBrush);
//
// We actually can't, because it will make the part of the tab that
// doesn't contain the text totally transparent to hit tests. So we
// actually _do_ still need to set TabViewItemHeaderBackground manually.
TabViewItem().Resources().Insert(winrt::box_value(L"TabViewItemHeaderBackground"), deselectedTabBrush);
// In GH#11294 we thought we'd still need to set
// TabViewItemHeaderBackground manually, but GH#11382 discovered that
// Background() was actually okay after all.
TabViewItem().Background(deselectedTabBrush);
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);
@ -1536,6 +1531,11 @@ namespace winrt::TerminalApp::implementation
}
}
// GH#11382 DON'T set the background to null. If you do that, then the
// tab won't be hit testable at all. Transparent, however, is a totally
// valid hit test target. That makes sense.
TabViewItem().Background(WUX::Media::SolidColorBrush{ Windows::UI::Colors::Transparent() });
_RefreshVisualState();
_colorCleared();
}