Skip to content

Use mica in the SUI if mica is enabled in the theme #14567

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

Merged
4 commits merged into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
21 changes: 20 additions & 1 deletion src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_settingsClone{ settings.Copy() }
{
InitializeComponent();

_updateBackgroundForMica();
_InitializeProfilesList();

_colorSchemesPageVM = winrt::make<ColorSchemesPageViewModel>(_settingsClone);
Expand Down Expand Up @@ -102,6 +102,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
_settingsSource = settings;
_settingsClone = settings.Copy();

_updateBackgroundForMica();

// Deduce information about the currently selected item
IInspectable lastBreadcrumb;
const auto size = _breadcrumbs.Size();
Expand Down Expand Up @@ -640,4 +642,21 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
return SettingsNav().Background();
}

// If the theme asks for Mica, then drop out our background, so that we
// can have mica too.
void MainPage::_updateBackgroundForMica()

{
const auto& theme = _settingsSource.GlobalSettings().CurrentTheme();

auto bgKey = (theme.Window() != nullptr && theme.Window().UseMica()) ?
L"SettingsPageMicaBackground" :
L"SettingsPageBackground";

if (auto bgColor = Resources().TryLookup(winrt::box_value(bgKey)))
{
SettingsNav().Background(winrt::WUX::Media::SolidColorBrush(winrt::unbox_value<Windows::UI::Color>(bgColor)));
}
}

}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
void _Navigate(hstring clickedItemTag, BreadcrumbSubPage subPage);
void _Navigate(const Editor::ProfileViewModel& profile, BreadcrumbSubPage subPage, const bool focusDeleteButton = false);

void _updateBackgroundForMica();

winrt::Microsoft::Terminal::Settings::Editor::ColorSchemesPageViewModel _colorSchemesPageVM{ nullptr };

Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker _profileViewModelChangedRevoker;
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,20 @@

<ResourceDictionary x:Key="Dark">
<Color x:Key="SettingsPageBackground">#282828</Color>
<Color x:Key="SettingsPageMicaBackground">#00000000</Color>
</ResourceDictionary>

<ResourceDictionary x:Key="Light">
<Color x:Key="SettingsPageBackground">#F9F9F9</Color>
<Color x:Key="SettingsPageMicaBackground">#00000000</Color>
</ResourceDictionary>

<ResourceDictionary x:Key="HighContrast">
<!-- Define resources for HighContrast mode here -->
<StaticResource x:Key="SettingsPageBackground"
ResourceKey="SystemColorWindowColorBrush" />
<StaticResource x:Key="SettingsPageMicaBackground"
ResourceKey="SystemColorWindowColorBrush" />
</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>
Expand Down