Skip to content

Commit

Permalink
wow
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Apr 26, 2022
1 parent fe26114 commit 7fcfda3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/cascadia/TerminalApp/AppLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace winrt::TerminalApp::implementation
// It's not enough to set the theme on the dialog alone.
auto themingLambda{ [this](const Windows::Foundation::IInspectable& sender, const RoutedEventArgs&) {
auto theme{ _settings.GlobalSettings().CurrentTheme() };
auto requestedTheme{ theme.RequestedTheme() };
auto requestedTheme{ theme.Window().RequestedTheme() };
auto element{ sender.try_as<winrt::Windows::UI::Xaml::FrameworkElement>() };
while (element)
{
Expand Down Expand Up @@ -744,7 +744,7 @@ namespace winrt::TerminalApp::implementation
LoadSettings();
}

return _settings.GlobalSettings().CurrentTheme().RequestedTheme();
return _settings.GlobalSettings().CurrentTheme().Window().RequestedTheme();
}

bool AppLogic::GetShowTabsInTitlebar()
Expand Down Expand Up @@ -965,7 +965,7 @@ namespace winrt::TerminalApp::implementation

void AppLogic::_RefreshThemeRoutine()
{
_ApplyTheme(_settings.GlobalSettings().CurrentTheme().RequestedTheme());
_ApplyTheme(_settings.GlobalSettings().CurrentTheme().Window().RequestedTheme());
}

// Function Description:
Expand Down
5 changes: 3 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3441,7 +3441,7 @@ namespace winrt::TerminalApp::implementation
void TerminalPage::_UpdateTeachingTipTheme(winrt::Windows::UI::Xaml::FrameworkElement element)
{
auto theme{ _settings.GlobalSettings().CurrentTheme() };
auto requestedTheme{ theme.RequestedTheme() };
auto requestedTheme{ theme.Window().RequestedTheme() };
while (element)
{
element.RequestedTheme(requestedTheme);
Expand Down Expand Up @@ -3971,8 +3971,9 @@ namespace winrt::TerminalApp::implementation

TitlebarBrush(acrylicBrush);
}
else if (const auto tabRowBg = theme.TabRowBackground())
else if (theme.TabRow() && theme.TabRow().Background())
{
const auto tabRowBg = theme.TabRow().Background();
switch (tabRowBg.ColorType())
{
case ThemeColorType::Accent:
Expand Down
58 changes: 28 additions & 30 deletions src/cascadia/TerminalSettingsModel/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ static constexpr std::string_view NameKey{ "name" };
static constexpr std::string_view WindowKey{ "window" };
static constexpr std::string_view TabRowKey{ "tabRow" };

ThemeColor::ThemeColor() noexcept
{
}

winrt::Microsoft::Terminal::Settings::Model::ThemeColor ThemeColor::FromColor(const winrt::Microsoft::Terminal::Core::Color& coreColor) noexcept
{
auto result = winrt::make_self<implementation::ThemeColor>();
Expand All @@ -48,34 +44,35 @@ winrt::Microsoft::Terminal::Settings::Model::ThemeColor ThemeColor::FromAccent()
#define THEME_SETTINGS_TO_JSON(type, name, jsonKey, ...) \
JsonUtils::SetValueForKey(json, jsonKey, val.name());

#define THEME_OBJECT_CONVERTER(projected, impl, name, macro) \
template<> \
struct ::Microsoft::Terminal::Settings::Model::JsonUtils::ConversionTrait<projected> \
{ \
projected FromJson(const Json::Value& json) \
{ \
auto result = winrt::make_self<impl>(); \
macro(THEME_SETTINGS_FROM_JSON) return *result; \
} \
\
bool CanConvert(const Json::Value& json) \
{ \
return json.isObject(); \
} \
\
Json::Value ToJson(const projected& val) \
{ \
Json::Value json{ Json::ValueType::objectValue }; \
macro(THEME_SETTINGS_TO_JSON) return json; \
} \
\
std::string TypeDescription() const \
{ \
return "name (You should never see this)"; \
} \
#define THEME_OBJECT_CONVERTER(nameSpace, name, macro) \
template<> \
struct ::Microsoft::Terminal::Settings::Model::JsonUtils::ConversionTrait<nameSpace::name> \
{ \
nameSpace::name FromJson(const Json::Value& json) \
{ \
auto result = winrt::make_self<nameSpace::implementation::name>(); \
macro(THEME_SETTINGS_FROM_JSON) return *result; \
} \
\
bool CanConvert(const Json::Value& json) \
{ \
return json.isObject(); \
} \
\
Json::Value ToJson(const nameSpace::name& val) \
{ \
Json::Value json{ Json::ValueType::objectValue }; \
macro(THEME_SETTINGS_TO_JSON) return json; \
} \
\
std::string TypeDescription() const \
{ \
return "name (You should never see this)"; \
} \
};

THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model::WindowTheme, winrt::Microsoft::Terminal::Settings::Model::implementation::WindowTheme, WindowTheme, MTSM_THEME_WINDOW_SETTINGS);
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, WindowTheme, MTSM_THEME_WINDOW_SETTINGS);
THEME_OBJECT_CONVERTER(winrt::Microsoft::Terminal::Settings::Model, TabRowTheme, MTSM_THEME_TABROW_SETTINGS);

#undef THEME_SETTINGS_FROM_JSON
#undef THEME_SETTINGS_TO_JSON
Expand Down Expand Up @@ -137,6 +134,7 @@ void Theme::LayerJson(const Json::Value& json)
JsonUtils::GetValueForKey(json, NameKey, _Name);

JsonUtils::GetValueForKey(json, WindowKey, _Window);
JsonUtils::GetValueForKey(json, TabRowKey, _TabRow);
// if (auto window{ json[JsonKey(WindowKey)] })
// {

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalSettingsModel/Theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
struct ThemeColor : ThemeColorT<ThemeColor>
{
public:
ThemeColor() noexcept;
ThemeColor() noexcept = default;
static winrt::Microsoft::Terminal::Settings::Model::ThemeColor FromColor(const winrt::Microsoft::Terminal::Core::Color& coreColor) noexcept;
static winrt::Microsoft::Terminal::Settings::Model::ThemeColor FromAccent() noexcept;

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/Theme.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Microsoft.Terminal.Settings.Model

runtimeclass ThemeColor
{
ThemeColor();
static ThemeColor FromColor(Microsoft.Terminal.Core.Color color);
static ThemeColor FromAccent();

Expand Down

1 comment on commit 7fcfda3

@github-actions

This comment was marked as outdated.

Please sign in to comment.