mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-06 05:34:59 +00:00
PRE-MERGE #16479 Theme for settings
This commit is contained in:
@@ -699,17 +699,23 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMicaAvailable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& theme = _settingsSource.GlobalSettings().CurrentTheme();
|
||||
const auto& requestedTheme = _settingsSource.GlobalSettings().CurrentTheme().RequestedTheme();
|
||||
const bool hasThemeForSettings{ theme.Settings() != nullptr };
|
||||
const auto& appTheme = theme.RequestedTheme();
|
||||
const auto& requestedTheme = (hasThemeForSettings) ? theme.Settings().RequestedTheme() : appTheme;
|
||||
|
||||
RequestedTheme(requestedTheme);
|
||||
|
||||
const auto bgKey = (theme.Window() != nullptr && theme.Window().UseMica()) ?
|
||||
// Mica gets it's appearance from the app's theme, not necessarily the
|
||||
// Page's theme. In the case of dark app, light settings, mica will be a
|
||||
// dark color, and the text will also be dark, making the UI _very_ hard
|
||||
// to read. (and similarly in the inverse situation).
|
||||
//
|
||||
// To mitigate this, don't set the transparent background in the case
|
||||
// that our theme is different than the app's.
|
||||
const bool actuallyUseMica = isMicaAvailable && (appTheme == requestedTheme);
|
||||
|
||||
const auto bgKey = (theme.Window() != nullptr && theme.Window().UseMica()) && actuallyUseMica ?
|
||||
L"SettingsPageMicaBackground" :
|
||||
L"SettingsPageBackground";
|
||||
|
||||
|
||||
@@ -136,9 +136,10 @@ Author(s):
|
||||
// * ForegroundKey, BackgroundKey, SelectionBackgroundKey, CursorColorKey: all optional colors
|
||||
// * Opacity: needs special parsing
|
||||
|
||||
#define MTSM_THEME_SETTINGS(X) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::WindowTheme, Window, "window", nullptr) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::TabRowTheme, TabRow, "tabRow", nullptr) \
|
||||
#define MTSM_THEME_SETTINGS(X) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::WindowTheme, Window, "window", nullptr) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::SettingsTheme, Settings, "settings", nullptr) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::TabRowTheme, TabRow, "tabRow", nullptr) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::TabTheme, Tab, "tab", nullptr)
|
||||
|
||||
#define MTSM_THEME_WINDOW_SETTINGS(X) \
|
||||
@@ -148,6 +149,9 @@ Author(s):
|
||||
X(bool, RainbowFrame, "experimental.rainbowFrame", false) \
|
||||
X(bool, UseMica, "useMica", false)
|
||||
|
||||
#define MTSM_THEME_SETTINGS_SETTINGS(X) \
|
||||
X(winrt::Windows::UI::Xaml::ElementTheme, RequestedTheme, "theme", winrt::Windows::UI::Xaml::ElementTheme::Default)
|
||||
|
||||
#define MTSM_THEME_TABROW_SETTINGS(X) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, Background, "background", nullptr) \
|
||||
X(winrt::Microsoft::Terminal::Settings::Model::ThemeColor, UnfocusedBackground, "unfocusedBackground", nullptr)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "JsonUtils.h"
|
||||
#include "TerminalSettingsSerializationHelpers.h"
|
||||
|
||||
#include "SettingsTheme.g.h"
|
||||
#include "ThemeColor.g.cpp"
|
||||
#include "WindowTheme.g.cpp"
|
||||
#include "TabRowTheme.g.cpp"
|
||||
@@ -56,6 +57,7 @@ static constexpr wchar_t RegKeyAccentColor[] = L"AccentColor";
|
||||
}
|
||||
|
||||
THEME_OBJECT(WindowTheme, MTSM_THEME_WINDOW_SETTINGS);
|
||||
THEME_OBJECT(SettingsTheme, MTSM_THEME_SETTINGS_SETTINGS);
|
||||
THEME_OBJECT(TabRowTheme, MTSM_THEME_TABROW_SETTINGS);
|
||||
THEME_OBJECT(TabTheme, MTSM_THEME_TAB_SETTINGS);
|
||||
|
||||
@@ -219,6 +221,7 @@ uint8_t ThemeColor::UnfocusedTabOpacity() const noexcept
|
||||
};
|
||||
|
||||
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, WindowTheme, MTSM_THEME_WINDOW_SETTINGS);
|
||||
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, SettingsTheme, MTSM_THEME_SETTINGS_SETTINGS);
|
||||
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, TabRowTheme, MTSM_THEME_TABROW_SETTINGS);
|
||||
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, TabTheme, MTSM_THEME_TAB_SETTINGS);
|
||||
|
||||
@@ -251,6 +254,10 @@ winrt::com_ptr<Theme> Theme::Copy() const
|
||||
{
|
||||
theme->_Tab = *winrt::get_self<implementation::TabTheme>(_Tab)->Copy();
|
||||
}
|
||||
if (_Settings)
|
||||
{
|
||||
theme->_Settings = *winrt::get_self<implementation::SettingsTheme>(_Settings)->Copy();
|
||||
}
|
||||
|
||||
return theme;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ Author(s):
|
||||
|
||||
#include "MTSMSettings.h"
|
||||
|
||||
#include "SettingsTheme.g.h"
|
||||
#include "ThemeColor.g.h"
|
||||
#include "WindowTheme.g.h"
|
||||
#include "TabRowTheme.g.h"
|
||||
@@ -81,6 +82,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
||||
};
|
||||
|
||||
THEME_OBJECT(WindowTheme, MTSM_THEME_WINDOW_SETTINGS);
|
||||
THEME_OBJECT(SettingsTheme, MTSM_THEME_SETTINGS_SETTINGS);
|
||||
THEME_OBJECT(TabRowTheme, MTSM_THEME_TABROW_SETTINGS);
|
||||
THEME_OBJECT(TabTheme, MTSM_THEME_TAB_SETTINGS);
|
||||
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
UInt8 UnfocusedTabOpacity { get; };
|
||||
}
|
||||
|
||||
runtimeclass SettingsTheme
|
||||
{
|
||||
Windows.UI.Xaml.ElementTheme RequestedTheme { get; };
|
||||
}
|
||||
|
||||
runtimeclass WindowTheme {
|
||||
Windows.UI.Xaml.ElementTheme RequestedTheme { get; };
|
||||
Boolean UseMica { get; };
|
||||
@@ -82,6 +87,9 @@ namespace Microsoft.Terminal.Settings.Model
|
||||
// window.* Namespace
|
||||
WindowTheme Window { get; };
|
||||
|
||||
// settings.* Namespace
|
||||
SettingsTheme Settings { get; };
|
||||
|
||||
// tabRow.* Namespace
|
||||
TabRowTheme TabRow { get; };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user