Skip to content

Commit

Permalink
Fixes the color of the dropdown arrow in weird themes (#13871)
Browse files Browse the repository at this point in the history
See also:
https://github.com/microsoft/microsoft-ui-xaml/blob/33732458ede38166f9127675898e4760c82b89bb/dev/SplitButton/SplitButton.xaml#L290-L293

We need to 
* Also set `SplitButtonForegroundSecondary` cause SplitButton's use that resource separately from the `Foreground()` property
* Manually trigger the visual state change, to refresh the brushes. We do something similar in TabBase

This is one of the bullet points in #13725
  • Loading branch information
zadjii-msft authored Aug 31, 2022
1 parent a96a5b7 commit 36f67d7
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3092,12 +3092,24 @@ namespace winrt::TerminalApp::implementation
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonBackgroundPointerOver"), backgroundHoverBrush);
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonBackgroundPressed"), backgroundPressedBrush);

// Load bearing: The SplitButton uses SplitButtonForegroundSecondary for
// the secondary button, but {TemplateBinding Foreground} for the
// primary button.
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonForeground"), foregroundBrush);
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonForegroundPointerOver"), foregroundBrush);
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonForegroundPressed"), foregroundBrush);
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonForegroundSecondary"), foregroundBrush);
_newTabButton.Resources().Insert(winrt::box_value(L"SplitButtonForegroundSecondaryPressed"), foregroundBrush);

_newTabButton.Background(backgroundBrush);
_newTabButton.Foreground(foregroundBrush);

// This is just like what we do in TabBase::_RefreshVisualState. We need
// to manually toggle the visual state, so the setters in the visual
// state group will re-apply, and set our currently selected colors in
// the resources.
VisualStateManager::GoToState(_newTabButton, L"FlyoutOpen", true);
VisualStateManager::GoToState(_newTabButton, L"Normal", true);
}

// Method Description:
Expand All @@ -3117,8 +3129,10 @@ namespace winrt::TerminalApp::implementation
L"SplitButtonBackgroundPointerOver",
L"SplitButtonBackgroundPressed",
L"SplitButtonForeground",
L"SplitButtonForegroundSecondary",
L"SplitButtonForegroundPointerOver",
L"SplitButtonForegroundPressed"
L"SplitButtonForegroundPressed",
L"SplitButtonForegroundSecondaryPressed"
};

// simply clear any of the colors in the split button's dict
Expand Down

0 comments on commit 36f67d7

Please sign in to comment.