Skip to content

Commit

Permalink
Fix the tab color, part III (#11413)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zadjii-msft authored Oct 5, 2021
1 parent 3f1befb commit 6295c8c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 6295c8c

Please sign in to comment.