mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-08 17:46:05 +00:00
a lot of the theme moving to be per-window-name
This commit is contained in:
@@ -19,7 +19,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// 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();
|
||||
_requestedTheme = settings.GlobalSettings().CurrentTheme(settings.WindowSettingsDefaults()).RequestedTheme();
|
||||
}
|
||||
|
||||
void SettingsPaneContent::UpdateSettings(const CascadiaSettings& settings)
|
||||
@@ -27,7 +27,7 @@ namespace winrt::TerminalApp::implementation
|
||||
ASSERT_UI_THREAD();
|
||||
_sui.UpdateSettings(settings);
|
||||
|
||||
_requestedTheme = settings.GlobalSettings().CurrentTheme().RequestedTheme();
|
||||
_requestedTheme = settings.GlobalSettings().CurrentTheme(settings.WindowSettingsDefaults()).RequestedTheme();
|
||||
}
|
||||
|
||||
winrt::Windows::UI::Xaml::FrameworkElement SettingsPaneContent::GetRoot()
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace winrt::TerminalApp::implementation
|
||||
{
|
||||
static const auto key = winrt::box_value(L"SettingsUiTabBrush");
|
||||
return ThemeLookup(WUX::Application::Current().Resources(),
|
||||
_settings.GlobalSettings().CurrentTheme().RequestedTheme(),
|
||||
_settings.GlobalSettings().CurrentTheme(_settings.WindowSettingsDefaults()).RequestedTheme(),
|
||||
key)
|
||||
.try_as<winrt::WUX::Media::Brush>();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "Utils.h"
|
||||
#include "../../types/inc/ColorFix.hpp"
|
||||
|
||||
#include <ThrottledFunc.h>
|
||||
|
||||
using namespace winrt;
|
||||
using namespace winrt::Windows::UI::Xaml;
|
||||
using namespace winrt::Windows::UI::Core;
|
||||
|
||||
@@ -239,7 +239,7 @@ namespace winrt::TerminalApp::implementation
|
||||
if (const auto content{ tab.GetActiveContent() })
|
||||
{
|
||||
const auto& icon{ content.Icon() };
|
||||
const auto theme = _settings.GlobalSettings().CurrentTheme();
|
||||
const auto theme = _settings.GlobalSettings().CurrentTheme(_currentWindowSettings());
|
||||
const auto iconStyle = (theme && theme.Tab()) ? theme.Tab().IconStyle() : IconStyle::Default;
|
||||
|
||||
tab.UpdateIcon(icon, iconStyle);
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
// Initialize the state of the CloseButtonOverlayMode property of
|
||||
// our TabView, to match the tab.showCloseButton property in the theme.
|
||||
if (const auto theme = _settings.GlobalSettings().CurrentTheme())
|
||||
if (const auto theme = _settings.GlobalSettings().CurrentTheme(_currentWindowSettings()))
|
||||
{
|
||||
const auto visibility = theme.Tab() ? theme.Tab().ShowCloseButton() : Settings::Model::TabCloseButtonVisibility::Always;
|
||||
|
||||
@@ -4082,7 +4082,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// our TabView, to match the tab.showCloseButton property in the theme.
|
||||
//
|
||||
// Also update every tab's individual IsClosable to match the same property.
|
||||
const auto theme = _settings.GlobalSettings().CurrentTheme();
|
||||
const auto theme = _settings.GlobalSettings().CurrentTheme(_currentWindowSettings());
|
||||
const auto visibility = (theme && theme.Tab()) ?
|
||||
theme.Tab().ShowCloseButton() :
|
||||
Settings::Model::TabCloseButtonVisibility::Always;
|
||||
@@ -4696,7 +4696,7 @@ namespace winrt::TerminalApp::implementation
|
||||
// - <none>
|
||||
void TerminalPage::_UpdateTeachingTipTheme(winrt::Windows::UI::Xaml::FrameworkElement element)
|
||||
{
|
||||
auto theme{ _settings.GlobalSettings().CurrentTheme() };
|
||||
auto theme{ _settings.GlobalSettings().CurrentTheme(_currentWindowSettings()) };
|
||||
auto requestedTheme{ theme.RequestedTheme() };
|
||||
while (element)
|
||||
{
|
||||
@@ -5070,7 +5070,7 @@ namespace winrt::TerminalApp::implementation
|
||||
return;
|
||||
}
|
||||
|
||||
const auto theme = _settings.GlobalSettings().CurrentTheme();
|
||||
const auto theme = _settings.GlobalSettings().CurrentTheme(_currentWindowSettings());
|
||||
auto requestedTheme{ theme.RequestedTheme() };
|
||||
|
||||
{
|
||||
|
||||
@@ -303,7 +303,7 @@ namespace winrt::TerminalApp::implementation
|
||||
|
||||
Microsoft::Terminal::Settings::Model::Theme TerminalWindow::Theme()
|
||||
{
|
||||
return _settings.GlobalSettings().CurrentTheme();
|
||||
return _settings.GlobalSettings().CurrentTheme(_currentWindowSettings());
|
||||
}
|
||||
|
||||
// WinUI can't show 2 dialogs simultaneously. Yes, really. If you do, you get an exception.
|
||||
@@ -380,7 +380,7 @@ namespace winrt::TerminalApp::implementation
|
||||
auto themingLambda{ [weak](const Windows::Foundation::IInspectable& sender, const RoutedEventArgs&) {
|
||||
if (const auto strong = weak.get())
|
||||
{
|
||||
auto theme{ strong->_settings.GlobalSettings().CurrentTheme() };
|
||||
auto theme{ strong->_settings.GlobalSettings().CurrentTheme(strong->_currentWindowSettings()) };
|
||||
auto requestedTheme{ theme.RequestedTheme() };
|
||||
auto element{ sender.try_as<winrt::Windows::UI::Xaml::FrameworkElement>() };
|
||||
while (element)
|
||||
|
||||
@@ -96,6 +96,7 @@ namespace TerminalApp
|
||||
TaskbarState TaskbarState{ get; };
|
||||
Windows.UI.Xaml.Media.Brush TitlebarBrush { get; };
|
||||
Windows.UI.Xaml.Media.Brush FrameBrush { get; };
|
||||
Microsoft.Terminal.Settings.Model.Theme Theme { get; };
|
||||
void WindowActivated(Boolean activated);
|
||||
|
||||
Boolean GetMinimizeToNotificationArea();
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace winrt::Microsoft::Terminal::Settings
|
||||
const auto windowSettings = appSettings.WindowSettingsDefaults();
|
||||
settings->_ApplyProfileSettings(profile);
|
||||
settings->_ApplyGlobalSettings(windowSettings);
|
||||
settings->_ApplyAppearanceSettings(profile.DefaultAppearance(), globals.ColorSchemes(), globals.CurrentTheme());
|
||||
settings->_ApplyAppearanceSettings(profile.DefaultAppearance(), globals.ColorSchemes(), globals.CurrentTheme(windowSettings));
|
||||
|
||||
return settings;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace winrt::Microsoft::Terminal::Settings
|
||||
const auto globals = appSettings.GlobalSettings();
|
||||
child = winrt::make_self<TerminalSettings>();
|
||||
child->_parent = settings->get_strong();
|
||||
child->_ApplyAppearanceSettings(unfocusedAppearance, globals.ColorSchemes(), globals.CurrentTheme());
|
||||
child->_ApplyAppearanceSettings(unfocusedAppearance, globals.ColorSchemes(), globals.CurrentTheme(appSettings.WindowSettingsDefaults()));
|
||||
}
|
||||
|
||||
return TerminalSettingsCreateResult{ settings.get(), child.get() };
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
winrt::Windows::Foundation::IInspectable GlobalAppearanceViewModel::CurrentTheme()
|
||||
{
|
||||
return _GlobalSettings.CurrentTheme();
|
||||
return _GlobalSettings.CurrentTheme(_WindowSettings);
|
||||
}
|
||||
|
||||
// Get the name out of the newly selected item, stash that as the Theme name
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
// GH#19927 - Theme the search box's internal popup now that the
|
||||
// visual tree is ready and control templates are applied
|
||||
const auto theme = _settingsSource.GlobalSettings().CurrentTheme();
|
||||
const auto theme = _settingsSource.GlobalSettings().CurrentTheme(_settingsSource.WindowSettingsDefaults());
|
||||
const auto hasThemeForSettings{ theme.Settings() != nullptr };
|
||||
const auto requestedTheme = hasThemeForSettings ? theme.Settings().RequestedTheme() : theme.RequestedTheme();
|
||||
_setThemeOnPopups(SettingsSearchBox(), requestedTheme);
|
||||
@@ -1149,7 +1149,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
}
|
||||
}
|
||||
|
||||
const auto theme = _settingsSource.GlobalSettings().CurrentTheme();
|
||||
const auto theme = _settingsSource.GlobalSettings().CurrentTheme(_settingsSource.WindowSettingsDefaults());
|
||||
const auto hasThemeForSettings{ theme.Settings() != nullptr };
|
||||
const auto appTheme = theme.RequestedTheme();
|
||||
const auto requestedTheme = (hasThemeForSettings) ? theme.Settings().RequestedTheme() : appTheme;
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
|
||||
Windows::UI::Color ProfileViewModel::TabThemeColorPreview() const
|
||||
{
|
||||
const auto currentTheme = _appSettings.GlobalSettings().CurrentTheme();
|
||||
const auto currentTheme = _appSettings.GlobalSettings().CurrentTheme(_appSettings.WindowSettingsDefaults());
|
||||
if (const auto tabTheme = currentTheme.Tab())
|
||||
{
|
||||
// theme.tab.background: theme color must be evaluated
|
||||
|
||||
@@ -1316,7 +1316,7 @@ void CascadiaSettings::_researchOnLoad()
|
||||
{
|
||||
// ----------------------------- RE: Themes ----------------------------
|
||||
const auto numThemes = GlobalSettings().Themes().Size();
|
||||
const auto themeInUse = GlobalSettings().CurrentTheme().Name();
|
||||
const auto themeInUse = GlobalSettings().CurrentTheme(WindowSettingsDefaults()).Name();
|
||||
const auto changedTheme = _globals->HasTheme();
|
||||
|
||||
// system: 0
|
||||
|
||||
@@ -367,19 +367,25 @@ bool GlobalAppSettings::FixupsAppliedDuringLoad()
|
||||
return _fixupsAppliedDuringLoad || _actionMap->FixupsAppliedDuringLoad();
|
||||
}
|
||||
|
||||
winrt::Microsoft::Terminal::Settings::Model::Theme GlobalAppSettings::CurrentTheme() noexcept
|
||||
winrt::Microsoft::Terminal::Settings::Model::Theme GlobalAppSettings::CurrentTheme(const Model::WindowSettings& window) noexcept
|
||||
{
|
||||
auto requestedTheme = Model::Theme::IsSystemInDarkTheme() ?
|
||||
winrt::Windows::UI::Xaml::ElementTheme::Dark :
|
||||
winrt::Windows::UI::Xaml::ElementTheme::Light;
|
||||
|
||||
const auto themePair = window ? window.Theme() : nullptr;
|
||||
if (!themePair)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
switch (requestedTheme)
|
||||
{
|
||||
case winrt::Windows::UI::Xaml::ElementTheme::Light:
|
||||
return _themes.TryLookup(Theme().LightName());
|
||||
return _themes.TryLookup(themePair.LightName());
|
||||
|
||||
case winrt::Windows::UI::Xaml::ElementTheme::Dark:
|
||||
return _themes.TryLookup(Theme().DarkName());
|
||||
return _themes.TryLookup(themePair.DarkName());
|
||||
|
||||
case winrt::Windows::UI::Xaml::ElementTheme::Default:
|
||||
default:
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
|
||||
Windows::Foundation::Collections::IMapView<hstring, Model::Theme> Themes() noexcept;
|
||||
void AddTheme(const Model::Theme& theme);
|
||||
Model::Theme CurrentTheme() noexcept;
|
||||
Model::Theme CurrentTheme(const Model::WindowSettings& window) noexcept;
|
||||
bool ShouldUsePersistedLayout() const;
|
||||
|
||||
void ExpandCommands(const Windows::Foundation::Collections::IVectorView<Model::Profile>& profiles,
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
// ---- Themes ----
|
||||
Windows.Foundation.Collections.IMapView<String, Theme> Themes();
|
||||
void AddTheme(Theme theme);
|
||||
Theme CurrentTheme { get; };
|
||||
Theme CurrentTheme(WindowSettings window);
|
||||
|
||||
Boolean ShouldUsePersistedLayout();
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ namespace SettingsModelUnitTests
|
||||
|
||||
const auto activeProfiles = settings->ActiveProfiles();
|
||||
const auto colorSchemes = settings->GlobalSettings().ColorSchemes();
|
||||
const auto currentTheme = settings->GlobalSettings().CurrentTheme();
|
||||
const auto currentTheme = settings->GlobalSettings().CurrentTheme(settings->WindowSettingsDefaults());
|
||||
const auto terminalSettings0 = createTerminalSettings(activeProfiles.GetAt(0), colorSchemes, currentTheme);
|
||||
const auto terminalSettings1 = createTerminalSettings(activeProfiles.GetAt(1), colorSchemes, currentTheme);
|
||||
const auto terminalSettings2 = createTerminalSettings(activeProfiles.GetAt(2), colorSchemes, currentTheme);
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace SettingsModelUnitTests
|
||||
VERIFY_IS_NULL(bar.TabRow().Background());
|
||||
}
|
||||
|
||||
const auto currentTheme{ settings->GlobalSettings().CurrentTheme() };
|
||||
const auto currentTheme{ settings->GlobalSettings().CurrentTheme(settings->WindowSettingsDefaults()) };
|
||||
VERIFY_IS_NOT_NULL(currentTheme);
|
||||
VERIFY_ARE_EQUAL(L"system", currentTheme.Name());
|
||||
}
|
||||
|
||||
@@ -934,7 +934,7 @@ void _frameColorHelper(const HWND h, const COLORREF color)
|
||||
|
||||
void AppHost::_updateTheme()
|
||||
{
|
||||
auto theme = _appLogic.Settings().GlobalSettings().CurrentTheme();
|
||||
auto theme = _windowLogic.Theme();
|
||||
|
||||
_window->OnApplicationThemeChanged(theme.RequestedTheme());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user