This almost works for previewing, but I fudged something up with the backgrounds and now they're totally transparent
This commit is contained in:
parent
e3a50cfdee
commit
916096643e
|
@ -94,7 +94,10 @@ namespace winrt::TerminalApp::implementation
|
|||
// the preview color changes, we only need to be able to restore the last one.
|
||||
_restorePreviewFuncs.clear();
|
||||
|
||||
_ApplyToActiveControls([&](const auto& /*control*/) {
|
||||
_ApplyToActiveControls([&](const auto& control) {
|
||||
auto originalScheme{ control.ColorScheme() };
|
||||
control.ColorScheme(scheme.ToCoreScheme());
|
||||
|
||||
// // Get the settings of the focused control and stash them
|
||||
// const auto& controlSettings = control.Settings().as<TerminalSettings>();
|
||||
// // Make sure to recurse up to the root - if you're doing
|
||||
|
@ -118,32 +121,33 @@ namespace winrt::TerminalApp::implementation
|
|||
// control.UpdateControlSettings(controlSettings);
|
||||
|
||||
// // Take a copy of the inputs, since they are pointers anyways.
|
||||
// _restorePreviewFuncs.emplace_back([=]() {
|
||||
// //// Get the runtime settings of the focused control
|
||||
// //const auto& controlSettings{ control.Settings().as<TerminalSettings>() };
|
||||
_restorePreviewFuncs.emplace_back([=]() {
|
||||
control.ColorScheme(originalScheme);
|
||||
//// Get the runtime settings of the focused control
|
||||
//const auto& controlSettings{ control.Settings().as<TerminalSettings>() };
|
||||
|
||||
// //// Get the control's root settings, the ones that we actually
|
||||
// //// assigned to it.
|
||||
// //auto parentSettings{ controlSettings.GetParent() };
|
||||
// //while (parentSettings.GetParent() != nullptr)
|
||||
// //{
|
||||
// // parentSettings = parentSettings.GetParent();
|
||||
// //}
|
||||
//// Get the control's root settings, the ones that we actually
|
||||
//// assigned to it.
|
||||
//auto parentSettings{ controlSettings.GetParent() };
|
||||
//while (parentSettings.GetParent() != nullptr)
|
||||
//{
|
||||
// parentSettings = parentSettings.GetParent();
|
||||
//}
|
||||
|
||||
// //// If the root settings are the same as the ones we stashed,
|
||||
// //// then reset the parent of the runtime settings to the stashed
|
||||
// //// settings. This condition might be false if the settings
|
||||
// //// hot-reloaded while the palette was open. In that case, we
|
||||
// //// don't want to reset the settings to what they were _before_
|
||||
// //// the hot-reload.
|
||||
// //if (originalSettings == parentSettings)
|
||||
// //{
|
||||
// // // Set the original settings as the parent of the control's settings
|
||||
// // control.Settings().as<TerminalSettings>().SetParent(originalSettings);
|
||||
// //}
|
||||
//// If the root settings are the same as the ones we stashed,
|
||||
//// then reset the parent of the runtime settings to the stashed
|
||||
//// settings. This condition might be false if the settings
|
||||
//// hot-reloaded while the palette was open. In that case, we
|
||||
//// don't want to reset the settings to what they were _before_
|
||||
//// the hot-reload.
|
||||
//if (originalSettings == parentSettings)
|
||||
//{
|
||||
// // Set the original settings as the parent of the control's settings
|
||||
// control.Settings().as<TerminalSettings>().SetParent(originalSettings);
|
||||
//}
|
||||
|
||||
// control.UpdateControlSettings(control.Settings());
|
||||
// });
|
||||
// control.UpdateControlSettings(control.Settings());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -452,30 +452,30 @@ namespace winrt::TerminalApp::implementation
|
|||
if (const auto scheme = _settings.GlobalSettings().ColorSchemes().TryLookup(realArgs.SchemeName()))
|
||||
{
|
||||
const auto res = _ApplyToActiveControls([&](auto& control) {
|
||||
Core::Scheme coreScheme{};
|
||||
// Core::Scheme coreScheme{};
|
||||
|
||||
coreScheme.Foreground = scheme.Foreground();
|
||||
coreScheme.Background = scheme.Background();
|
||||
coreScheme.CursorColor = scheme.CursorColor();
|
||||
coreScheme.SelectionBackground = scheme.SelectionBackground();
|
||||
coreScheme.Black = scheme.Table()[0];
|
||||
coreScheme.Red = scheme.Table()[1];
|
||||
coreScheme.Green = scheme.Table()[2];
|
||||
coreScheme.Yellow = scheme.Table()[3];
|
||||
coreScheme.Blue = scheme.Table()[4];
|
||||
coreScheme.Purple = scheme.Table()[5];
|
||||
coreScheme.Cyan = scheme.Table()[6];
|
||||
coreScheme.White = scheme.Table()[7];
|
||||
coreScheme.BrightBlack = scheme.Table()[8];
|
||||
coreScheme.BrightRed = scheme.Table()[9];
|
||||
coreScheme.BrightGreen = scheme.Table()[10];
|
||||
coreScheme.BrightYellow = scheme.Table()[11];
|
||||
coreScheme.BrightBlue = scheme.Table()[12];
|
||||
coreScheme.BrightPurple = scheme.Table()[13];
|
||||
coreScheme.BrightCyan = scheme.Table()[14];
|
||||
coreScheme.BrightWhite = scheme.Table()[15];
|
||||
// coreScheme.Foreground = scheme.Foreground();
|
||||
// coreScheme.Background = scheme.Background();
|
||||
// coreScheme.CursorColor = scheme.CursorColor();
|
||||
// coreScheme.SelectionBackground = scheme.SelectionBackground();
|
||||
// coreScheme.Black = scheme.Table()[0];
|
||||
// coreScheme.Red = scheme.Table()[1];
|
||||
// coreScheme.Green = scheme.Table()[2];
|
||||
// coreScheme.Yellow = scheme.Table()[3];
|
||||
// coreScheme.Blue = scheme.Table()[4];
|
||||
// coreScheme.Purple = scheme.Table()[5];
|
||||
// coreScheme.Cyan = scheme.Table()[6];
|
||||
// coreScheme.White = scheme.Table()[7];
|
||||
// coreScheme.BrightBlack = scheme.Table()[8];
|
||||
// coreScheme.BrightRed = scheme.Table()[9];
|
||||
// coreScheme.BrightGreen = scheme.Table()[10];
|
||||
// coreScheme.BrightYellow = scheme.Table()[11];
|
||||
// coreScheme.BrightBlue = scheme.Table()[12];
|
||||
// coreScheme.BrightPurple = scheme.Table()[13];
|
||||
// coreScheme.BrightCyan = scheme.Table()[14];
|
||||
// coreScheme.BrightWhite = scheme.Table()[15];
|
||||
|
||||
control.ColorScheme(coreScheme);
|
||||
control.ColorScheme(scheme.ToCoreScheme());
|
||||
//// Start by getting the current settings of the control
|
||||
//auto controlSettings = control.Settings().as<TerminalSettings>();
|
||||
//auto parentSettings = controlSettings;
|
||||
|
|
|
@ -1606,21 +1606,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return s;
|
||||
}
|
||||
|
||||
void ControlCore::ColorScheme(Core::Scheme scheme) const noexcept
|
||||
void ControlCore::ColorScheme(Core::Scheme scheme)
|
||||
{
|
||||
_terminal->ApplyScheme(scheme);
|
||||
|
||||
_settings->FocusedAppearance()->DefaultForeground(scheme.Foreground);
|
||||
_settings->FocusedAppearance()->DefaultBackground(scheme.Background);
|
||||
// Set the default background as transparent to prevent the
|
||||
// DX layer from overwriting the background image or acrylic effect
|
||||
til::color newBackgroundColor{ scheme.Background };
|
||||
// _settings->FocusedAppearance()->DefaultBackground(newBackgroundColor.with_alpha(0));
|
||||
_settings->FocusedAppearance()->DefaultBackground(newBackgroundColor);
|
||||
_settings->FocusedAppearance()->CursorColor(scheme.CursorColor);
|
||||
_settings->FocusedAppearance()->SelectionBackground(scheme.SelectionBackground);
|
||||
|
||||
// // _defaultFg = colorScheme.Foreground;
|
||||
// // // Set the default background as transparent to prevent the
|
||||
// // // DX layer from overwriting the background image or acrylic effect
|
||||
// // til::color newBackgroundColor{ colorScheme.Background };
|
||||
// // _defaultBg = newBackgroundColor.with_alpha(0);
|
||||
|
||||
_settings->FocusedAppearance()->SetColorTableEntry(0, scheme.Black);
|
||||
_settings->FocusedAppearance()->SetColorTableEntry(1, scheme.Red);
|
||||
_settings->FocusedAppearance()->SetColorTableEntry(2, scheme.Green);
|
||||
|
@ -1638,8 +1634,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_settings->FocusedAppearance()->SetColorTableEntry(14, scheme.BrightCyan);
|
||||
_settings->FocusedAppearance()->SetColorTableEntry(15, scheme.BrightWhite);
|
||||
|
||||
// _buffer->GetCursor().SetColor(til::color{ colorScheme.CursorColor });
|
||||
_terminal->ApplyScheme(scheme);
|
||||
|
||||
_renderer->TriggerRedrawAll();
|
||||
_BackgroundColorChangedHandlers(*this, nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
Control::IControlAppearance FocusedAppearance() const { return *_settings->FocusedAppearance(); };
|
||||
Control::IControlAppearance UnfocusedAppearance() const { return *_settings->UnfocusedAppearance(); };
|
||||
winrt::Microsoft::Terminal::Core::Scheme ColorScheme() const noexcept;
|
||||
void ColorScheme(winrt::Microsoft::Terminal::Core::Scheme scheme) const noexcept;
|
||||
void ColorScheme(winrt::Microsoft::Terminal::Core::Scheme scheme);
|
||||
|
||||
void SizeChanged(const double width, const double height);
|
||||
void ScaleChanged(const double scale);
|
||||
|
|
|
@ -478,7 +478,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
const IInspectable& /*args*/)
|
||||
{
|
||||
til::color newBgColor{ _core.BackgroundColor() };
|
||||
_changeBackgroundColor(newBgColor);
|
||||
_changeBackgroundColor(newBgColor.with_alpha(1));
|
||||
}
|
||||
|
||||
winrt::fire_and_forget TermControl::_changeBackgroundColor(const til::color bg)
|
||||
|
|
|
@ -147,3 +147,30 @@ void ColorScheme::SetColorTableEntry(uint8_t index, const Core::Color& value) no
|
|||
THROW_HR_IF(E_INVALIDARG, index >= _table.size());
|
||||
_table[index] = value;
|
||||
}
|
||||
|
||||
winrt::Microsoft::Terminal::Core::Scheme ColorScheme::ToCoreScheme() const noexcept
|
||||
{
|
||||
winrt::Microsoft::Terminal::Core::Scheme coreScheme{};
|
||||
|
||||
coreScheme.Foreground = Foreground();
|
||||
coreScheme.Background = Background();
|
||||
coreScheme.CursorColor = CursorColor();
|
||||
coreScheme.SelectionBackground = SelectionBackground();
|
||||
coreScheme.Black = Table()[0];
|
||||
coreScheme.Red = Table()[1];
|
||||
coreScheme.Green = Table()[2];
|
||||
coreScheme.Yellow = Table()[3];
|
||||
coreScheme.Blue = Table()[4];
|
||||
coreScheme.Purple = Table()[5];
|
||||
coreScheme.Cyan = Table()[6];
|
||||
coreScheme.White = Table()[7];
|
||||
coreScheme.BrightBlack = Table()[8];
|
||||
coreScheme.BrightRed = Table()[9];
|
||||
coreScheme.BrightGreen = Table()[10];
|
||||
coreScheme.BrightYellow = Table()[11];
|
||||
coreScheme.BrightBlue = Table()[12];
|
||||
coreScheme.BrightPurple = Table()[13];
|
||||
coreScheme.BrightCyan = Table()[14];
|
||||
coreScheme.BrightWhite = Table()[15];
|
||||
return coreScheme;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
static com_ptr<ColorScheme> FromJson(const Json::Value& json);
|
||||
Json::Value ToJson() const;
|
||||
|
||||
winrt::Microsoft::Terminal::Core::Scheme ToCoreScheme() const noexcept;
|
||||
|
||||
com_array<Core::Color> Table() const noexcept;
|
||||
void SetColorTableEntry(uint8_t index, const Core::Color& value) noexcept;
|
||||
|
||||
|
|
|
@ -19,5 +19,7 @@ namespace Microsoft.Terminal.Settings.Model
|
|||
// we expose the getter as a function.
|
||||
Microsoft.Terminal.Core.Color[] Table();
|
||||
void SetColorTableEntry(UInt8 index, Microsoft.Terminal.Core.Color value);
|
||||
|
||||
Microsoft.Terminal.Core.Scheme ToCoreScheme();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue