diff --git a/src/cascadia/TerminalControl/ControlCore.cpp b/src/cascadia/TerminalControl/ControlCore.cpp index 3a28f6766..8784a2add 100644 --- a/src/cascadia/TerminalControl/ControlCore.cpp +++ b/src/cascadia/TerminalControl/ControlCore.cpp @@ -244,7 +244,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation LOG_IF_FAILED(_renderEngine->SetWindowSize({ viewInPixels.Width(), viewInPixels.Height() })); // Update DxEngine's SelectionBackground - _renderEngine->SetSelectionBackground(til::color{ _settings->FocusedAppearance()->SelectionBackground() }); + _renderEngine->SetSelectionBackground(til::color{ _settings->SelectionBackground() }); const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels); const auto width = vp.Width(); @@ -267,11 +267,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation // We do this after we initially set the swapchain so as to avoid unnecessary callbacks (and locking problems) _renderEngine->SetCallback(std::bind(&ControlCore::_renderEngineSwapChainChanged, this)); - _renderEngine->SetRetroTerminalEffect(_settings->FocusedAppearance()->RetroTerminalEffect()); - _renderEngine->SetPixelShaderPath(_settings->FocusedAppearance()->PixelShaderPath()); + _renderEngine->SetRetroTerminalEffect(_settings->RetroTerminalEffect()); + _renderEngine->SetPixelShaderPath(_settings->PixelShaderPath()); _renderEngine->SetForceFullRepaintRendering(_settings->ForceFullRepaintRendering()); _renderEngine->SetSoftwareRendering(_settings->SoftwareRendering()); - _renderEngine->SetIntenseIsBold(_settings->FocusedAppearance()->IntenseIsBold()); + _renderEngine->SetIntenseIsBold(_settings->IntenseIsBold()); _updateAntiAliasingMode(_renderEngine.get()); @@ -475,7 +475,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // specify a custom pixel shader, manually enable the legacy retro // effect first. This will ensure that a toggle off->on will still work, // even if they currently have retro effect off. - if (_settings->FocusedAppearance()->PixelShaderPath().empty() && !_renderEngine->GetRetroTerminalEffect()) + if (_settings->PixelShaderPath().empty() && !_renderEngine->GetRetroTerminalEffect()) { // SetRetroTerminalEffect to true will enable the effect. In this // case, the shader effect will already be disabled (because neither @@ -597,7 +597,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation // GH#11285 - If the user is on Windows 10, and they wanted opacity, but // didn't explicitly request acrylic, then opt them in to acrylic. // On Windows 11+, this isn't needed, because we can have vintage opacity. - if (!IsVintageOpacityAvailable() && _settings->FocusedAppearance()->Opacity() < 1.0 && !_settings->UseAcrylic()) + if (!IsVintageOpacityAvailable() && _settings->Opacity() < 1.0 && !_settings->UseAcrylic()) { _runtimeUseAcrylic = true; } @@ -660,7 +660,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation _renderEngine->SetSelectionBackground(til::color{ newAppearance->SelectionBackground() }); _renderEngine->SetRetroTerminalEffect(newAppearance->RetroTerminalEffect()); _renderEngine->SetPixelShaderPath(newAppearance->PixelShaderPath()); - _renderEngine->SetIntenseIsBold(newAppearance->IntenseIsBold()); + _renderEngine->SetIntenseIsBold(_settings->IntenseIsBold()); _renderer->TriggerRedrawAll(); } } @@ -993,7 +993,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation TextBuffer::GenHTML(bufferData, _actualFont.GetUnscaledSize().Y, _actualFont.GetFaceName(), - til::color{ _settings->FocusedAppearance()->DefaultBackground() }) : + til::color{ _settings->DefaultBackground() }) : ""; // convert to RTF format @@ -1001,7 +1001,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation TextBuffer::GenRTF(bufferData, _actualFont.GetUnscaledSize().Y, _actualFont.GetFaceName(), - til::color{ _settings->FocusedAppearance()->DefaultBackground() }) : + til::color{ _settings->DefaultBackground() }) : ""; if (!_settings->CopyOnSelect()) diff --git a/src/cascadia/TerminalControl/ControlCore.h b/src/cascadia/TerminalControl/ControlCore.h index 76eec84d1..fc9d6afeb 100644 --- a/src/cascadia/TerminalControl/ControlCore.h +++ b/src/cascadia/TerminalControl/ControlCore.h @@ -170,7 +170,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation static bool IsVintageOpacityAvailable() noexcept; - RUNTIME_SETTING(double, Opacity, _settings->FocusedAppearance()->Opacity()); + RUNTIME_SETTING(double, Opacity, _settings->Opacity()); RUNTIME_SETTING(bool, UseAcrylic, _settings->UseAcrylic()); // -------------------------------- WinRT Events --------------------------------- diff --git a/src/cascadia/TerminalControl/ControlSettings.h b/src/cascadia/TerminalControl/ControlSettings.h index 57184564b..6dc9a1f63 100644 --- a/src/cascadia/TerminalControl/ControlSettings.h +++ b/src/cascadia/TerminalControl/ControlSettings.h @@ -15,7 +15,7 @@ using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap + struct ControlSettings : public winrt::implements { // Getters and setters for each *Setting member. We're not using // WINRT_PROPERTY for these, because they actually exist inside the @@ -53,7 +53,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation winrt::com_ptr FocusedAppearance() { return _focusedAppearance; } bool HasUnfocusedAppearance() { return _hasUnfocusedAppearance; } - // NOTABLY: ControlSettings is not an Appearance. Make sure to get the - // Appearance you actually want out of it. + // Getters and setters for each Appearance member. We're not using + // WINRT_PROPERTY for these, because they actually exist inside the + // _focusedAppearance member. We don't need to reserve another member to + // hold them. + // + // The Appearance members (including GetColorTableEntry below) are used + // when this ControlSettings is cast to a IControlAppearance or + // ICoreAppearance. In those cases, we'll always return the Focused + // appearance's version of the member. Callers who care about which + // appearance is being used should be more careful. Fortunately, this + // situation is generally only used when a control is first created, or + // when calling UpdateSettings. +#define APPEARANCE_GEN(type, name, ...) \ + type name() const noexcept { return _focusedAppearance->name(); } \ + void name(const type& value) noexcept { _focusedAppearance->name(value); } + + CORE_APPEARANCE_SETTINGS(APPEARANCE_GEN) + CONTROL_APPEARANCE_SETTINGS(APPEARANCE_GEN) +#undef APPEARANCE_GEN + + winrt::Microsoft::Terminal::Core::Color GetColorTableEntry(int32_t index) noexcept + { + return _focusedAppearance->GetColorTableEntry(index); + } }; }