mirror of
https://github.com/microsoft/terminal.git
synced 2026-11-16 09:20:53 +00:00
comments galore
This commit is contained in:
@@ -37,6 +37,8 @@ namespace winrt::TerminalApp::implementation
|
||||
auto settingsUI{ Content().as<MainPage>() };
|
||||
settingsUI.UpdateSettings(settings);
|
||||
|
||||
// Stash away the current requested theme of the app. We'll need that in
|
||||
// _BackgroundBrush() to do a theme-aware resource lookup
|
||||
_requestedTheme = settings.GlobalSettings().CurrentTheme().RequestedTheme();
|
||||
}
|
||||
|
||||
@@ -110,12 +112,13 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
winrt::Windows::UI::Xaml::Media::Brush SettingsTab::_BackgroundBrush()
|
||||
{
|
||||
// // TODO! convert to a resource lookup
|
||||
// static Media::SolidColorBrush campbellBg{ winrt::Windows::UI::Color{ 0xff, 0x0c, 0x0c, 0x0c } };
|
||||
// return campbellBg;
|
||||
|
||||
// Look up the color we should use for the settings tab item from our
|
||||
// resources. This should only be used for when "terminalBackground" is
|
||||
// requested.
|
||||
static const auto key = winrt::box_value(L"SettingsUiTabBrush");
|
||||
// return Application::Current().Resources().TryLookup(key).try_as<winrt::Windows::UI::Xaml::Media::Brush>();
|
||||
// You can't just do a Application::Current().Resources().TryLookup
|
||||
// lookup, cause the app theme never changes! Do the hacky version
|
||||
// instead.
|
||||
return ThemeLookup(Application::Current().Resources(), _requestedTheme, key).try_as<winrt::Windows::UI::Xaml::Media::Brush>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4105,62 +4105,6 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
const auto res = Application::Current().Resources();
|
||||
|
||||
// XAML Hacks:
|
||||
//
|
||||
// the App is always in the OS theme, so the
|
||||
// App::Current().Resources() lookup will always get the value for the
|
||||
// OS theme, not the requested theme.
|
||||
//
|
||||
// This helper allows us to instead lookup the value of a resource
|
||||
// specified by `key` for the given `requestedTheme`, from the
|
||||
// dictionaries in App.xaml. Make sure the value is actually there!
|
||||
// Otherwise this'll throw like any other Lookup for a resource that
|
||||
// isn't there.
|
||||
// static const auto lookup = [](auto& res, auto& requestedTheme, auto& key) {
|
||||
// // You want the Default version of the resource? Great, the App is
|
||||
// // always in the OS theme. Just look it up and be done.
|
||||
// if (requestedTheme == ElementTheme::Default)
|
||||
// {
|
||||
// return res.Lookup(key);
|
||||
// }
|
||||
// static const auto lightKey = winrt::box_value(L"Light");
|
||||
// static const auto darkKey = winrt::box_value(L"Dark");
|
||||
// // There isn't an ElementTheme::HighContrast.
|
||||
|
||||
// auto requestedThemeKey = requestedTheme == ElementTheme::Dark ? darkKey : lightKey;
|
||||
// for (const auto& dictionary : res.MergedDictionaries())
|
||||
// {
|
||||
// // Don't look in the MUX resources. They come first. A person
|
||||
// // with more patience than me may find a way to look through our
|
||||
// // dictionaries first, then the MUX ones, but that's not needed
|
||||
// // currently
|
||||
// if (dictionary.Source())
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// // Look through the theme dictionaries we defined:
|
||||
// for (const auto& [dictionaryKey, dict] : dictionary.ThemeDictionaries())
|
||||
// {
|
||||
// // Does the key for this dict match the theme we're looking for?
|
||||
// if (winrt::unbox_value<winrt::hstring>(dictionaryKey) !=
|
||||
// winrt::unbox_value<winrt::hstring>(requestedThemeKey))
|
||||
// {
|
||||
// // No? skip it.
|
||||
// continue;
|
||||
// }
|
||||
// // Look for the requested resource in this dict.
|
||||
// const auto themeDictionary = dict.as<winrt::Windows::UI::Xaml::ResourceDictionary>();
|
||||
// if (themeDictionary.HasKey(key))
|
||||
// {
|
||||
// return themeDictionary.Lookup(key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // We didn't find it in the requested dict, fall back to the default dictionary.
|
||||
// return res.Lookup(key);
|
||||
// };
|
||||
|
||||
// Use our helper to lookup the theme-aware version of the resource.
|
||||
const auto tabViewBackgroundKey = winrt::box_value(L"TabViewBackground");
|
||||
const auto backgroundSolidBrush = ThemeLookup(res, requestedTheme, tabViewBackgroundKey).as<Media::SolidColorBrush>();
|
||||
@@ -4210,7 +4154,10 @@ namespace winrt::TerminalApp::implementation
|
||||
_tabRow.Background(TitlebarBrush());
|
||||
}
|
||||
|
||||
// Second: Update the colors of our individual TabViewItems. This applies tab.background to the tabs via TerminalTab::ThemeColor
|
||||
// Second: Update the colors of our individual TabViewItems. This
|
||||
// applies tab.background to the tabs via TerminalTab::ThemeColor.
|
||||
//
|
||||
// Do this second, so that we already know the bgColor of the titlebar.
|
||||
{
|
||||
auto tabBackground = theme.Tab() ? theme.Tab().Background() : nullptr;
|
||||
auto tabUnfocusedBackground = theme.Tab() ? theme.Tab().UnfocusedBackground() : nullptr;
|
||||
@@ -4218,10 +4165,7 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
winrt::com_ptr<TabBase> tabImpl;
|
||||
tabImpl.copy_from(winrt::get_self<TabBase>(tab));
|
||||
// if (const auto& terminalTabImpl{ _GetTerminalTabImpl(tab) })
|
||||
// {
|
||||
tabImpl->ThemeColor(tabBackground, tabUnfocusedBackground, bgColor);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,19 @@ winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> SaveFilePicker(HWND
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::hstring> OpenImagePicker(HWND parentHwnd);
|
||||
|
||||
#ifdef WINRT_Windows_UI_Xaml_H
|
||||
|
||||
// Only compile me if Windows.UI.Xaml is already included.
|
||||
//
|
||||
// XAML Hacks:
|
||||
//
|
||||
// the App is always in the OS theme, so the
|
||||
// App::Current().Resources() lookup will always get the value for the
|
||||
// OS theme, not the requested theme.
|
||||
//
|
||||
// This helper allows us to instead lookup the value of a resource
|
||||
// specified by `key` for the given `requestedTheme`, from the
|
||||
// dictionaries in App.xaml. Make sure the value is actually there!
|
||||
// Otherwise this'll throw like any other Lookup for a resource that
|
||||
// isn't there.
|
||||
winrt::Windows::Foundation::IInspectable ThemeLookup(const auto& res,
|
||||
const winrt::Windows::UI::Xaml::ElementTheme& requestedTheme,
|
||||
const winrt::Windows::Foundation::IInspectable& key)
|
||||
|
||||
Reference in New Issue
Block a user