This says there's only one build error in Terminal.Control.Lib but that can't be right

This commit is contained in:
Mike Griese 2021-09-28 11:36:21 -05:00
parent 7fc2f10bbd
commit c7536edfa8
2 changed files with 63 additions and 56 deletions

View file

@ -50,7 +50,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
TermControl::TermControl(IControlSettings settings,
TerminalConnection::ITerminalConnection connection) :
_settings{ settings },
_settings{ winrt::make_self<ControlSettings>(settings, nullptr) },
_isInternalScrollBarUpdate{ false },
_autoScrollVelocity{ 0 },
_autoScrollingPointerPoint{ std::nullopt },
@ -244,19 +244,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_UpdateSettingsFromUIThread(_settings);
auto appearance = _settings.try_as<IControlAppearance>();
if (!_focused && _UnfocusedAppearance)
{
appearance = _UnfocusedAppearance;
}
_UpdateAppearanceFromUIThread(appearance);
_UpdateAppearanceFromUIThread(_focused ? _settings->FocusedAppearance() : _settings->UnfocusedAppearance());
}
// Method Description:
// - Dispatches a call to the UI thread and updates the appearance
// Arguments:
// - newAppearance: the new appearance to set
winrt::fire_and_forget TermControl::UpdateAppearance(const IControlAppearance newAppearance)
winrt::fire_and_forget TermControl::UpdateAppearance(winrt::com_ptr<ControlAppearance> newAppearance)
{
// Dispatch a call to the UI thread
co_await winrt::resume_foreground(Dispatcher());
@ -272,17 +267,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - INVARIANT: This method must be called from the UI thread.
// Arguments:
// - newSettings: the new settings to set
void TermControl::_UpdateSettingsFromUIThread(IControlSettings newSettings)
void TermControl::_UpdateSettingsFromUIThread(winrt::com_ptr<ControlSettings> newSettings)
{
if (_IsClosing())
{
return;
}
_core.UpdateSettings(_settings);
_core.UpdateSettings(newSettings); // TODO!
// Update our control settings
_ApplyUISettings(_settings);
_ApplyUISettings(newSettings);
}
// Method Description:
@ -290,16 +285,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - INVARIANT: This method must be called from the UI thread.
// Arguments:
// - newAppearance: the new appearance to set
void TermControl::_UpdateAppearanceFromUIThread(IControlAppearance newAppearance)
void TermControl::_UpdateAppearanceFromUIThread(winrt::com_ptr<ControlAppearance> newAppearance)
{
if (_IsClosing())
{
return;
}
if (!newAppearance.BackgroundImage().empty())
if (!newAppearance->BackgroundImage().empty())
{
Windows::Foundation::Uri imageUri{ newAppearance.BackgroundImage() };
Windows::Foundation::Uri imageUri{ newAppearance->BackgroundImage() };
// Check if the image brush is already pointing to the image
// in the modified settings; if it isn't (or isn't there),
@ -319,10 +314,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
// Apply stretch, opacity and alignment settings
BackgroundImage().Stretch(newAppearance.BackgroundImageStretchMode());
BackgroundImage().Opacity(newAppearance.BackgroundImageOpacity());
BackgroundImage().HorizontalAlignment(newAppearance.BackgroundImageHorizontalAlignment());
BackgroundImage().VerticalAlignment(newAppearance.BackgroundImageVerticalAlignment());
BackgroundImage().Stretch(newAppearance->BackgroundImageStretchMode());
BackgroundImage().Opacity(newAppearance->BackgroundImageOpacity());
BackgroundImage().HorizontalAlignment(newAppearance->BackgroundImageHorizontalAlignment());
BackgroundImage().VerticalAlignment(newAppearance->BackgroundImageVerticalAlignment());
}
else
{
@ -330,15 +325,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
// Update our control settings
const auto bg = newAppearance.DefaultBackground();
const auto bg = newAppearance->DefaultBackground();
_changeBackgroundColor(bg);
// Set TSF Foreground
Media::SolidColorBrush foregroundBrush{};
foregroundBrush.Color(static_cast<til::color>(newAppearance.DefaultForeground()));
foregroundBrush.Color(static_cast<til::color>(newAppearance->DefaultForeground()));
TSFInputControl().Foreground(foregroundBrush);
_core.UpdateAppearance(newAppearance);
_core.UpdateAppearance(newAppearance.try_as<IControlAppearance>());
}
// Method Description:
@ -373,21 +368,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - <none>
// Return Value:
// - <none>
void TermControl::_ApplyUISettings(const IControlSettings& newSettings)
void TermControl::_ApplyUISettings(const winrt::com_ptr<ControlSettings>& newSettings)
{
_InitializeBackgroundBrush();
const auto bg = newSettings.DefaultBackground();
const auto bg = newSettings->FocusedAppearance()->DefaultBackground();
_changeBackgroundColor(bg);
// Apply padding as swapChainPanel's margin
const auto newMargin = ParseThicknessFromPadding(newSettings.Padding());
const auto newMargin = ParseThicknessFromPadding(newSettings->Padding());
SwapChainPanel().Margin(newMargin);
TSFInputControl().Margin(newMargin);
// Apply settings for scrollbar
if (newSettings.ScrollState() == ScrollbarState::Hidden)
if (newSettings->ScrollState() == ScrollbarState::Hidden)
{
// In the scenario where the user has turned off the OS setting to automatically hide scrollbars, the
// Terminal scrollbar would still be visible; so, we need to set the control's visibility accordingly to
@ -415,7 +410,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Method Description:
// - Set up each layer's brush used to display the control's background.
// - Respects the settings for acrylic, background image and opacity from
// _settings.
// _settings->
// * If acrylic is not enabled, setup a solid color background, otherwise
// use bgcolor as acrylic's tint
// - Avoids image flickering and acrylic brush redraw if settings are changed
@ -429,7 +424,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void TermControl::_InitializeBackgroundBrush()
{
auto appearance = _settings.try_as<IControlAppearance>();
if (_settings.UseAcrylic())
if (_settings->UseAcrylic())
{
// See if we've already got an acrylic background brush
// to avoid the flicker when setting up a new one
@ -444,7 +439,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// see GH#1082: Initialize background color so we don't get a
// fade/flash when _BackgroundColorChanged is called
auto bgColor = til::color{ _settings.DefaultBackground() }.with_alpha(0xff);
auto bgColor = til::color{ _settings->FocusedAppearance()->DefaultBackground() }.with_alpha(0xff);
acrylic.FallbackColor(bgColor);
acrylic.TintColor(bgColor);
@ -598,7 +593,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) == hr)
{
message = { fmt::format(std::wstring_view{ RS_(L"PixelShaderNotFound") },
_settings.PixelShaderPath()) };
(_focused ? _settings->FocusedAppearance() : _settings->UnfocusedAppearance())->PixelShaderPath()) };
}
else if (D2DERR_SHADER_COMPILE_FAILED == hr)
{
@ -720,7 +715,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
// Now that the renderer is set up, update the appearance for initialization
_UpdateAppearanceFromUIThread(_settings);
_UpdateAppearanceFromUIThread(_settings->FocusedAppearance());
_initializedTerminal = true;
@ -792,7 +787,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// This is required as part of GH#638.
// Or do so for alt+space; only send to terminal when explicitly unbound
// That is part of #GH7125
auto bindings{ _settings.KeyBindings() };
auto bindings{ _settings->KeyBindings() };
bool isUnbound = false;
const KeyChord kc = {
modifiers.IsCtrlPressed(),
@ -937,7 +932,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - modifiers: The ControlKeyStates representing the modifier key states.
bool TermControl::_TryHandleKeyBinding(const WORD vkey, const WORD scanCode, ::Microsoft::Terminal::Core::ControlKeyStates modifiers) const
{
auto bindings = _settings.KeyBindings();
auto bindings = _settings->KeyBindings();
if (!bindings)
{
return false;
@ -1116,7 +1111,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const auto pixelPosition = _toTerminalOrigin(cursorPosition);
const auto type = ptr.PointerDeviceType();
if (!_focused && _settings.FocusFollowMouse())
if (!_focused && _settings->FocusFollowMouse())
{
_FocusFollowMouseRequestedHandlers(*this, nullptr);
}
@ -1284,7 +1279,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// - Called in response to the core's TransparencyChanged event. We'll use
// this to update our background brush.
// - The Core should have already updated the TintOpacity and UseAcrylic
// properties in the _settings.
// properties in the _settings->
// Arguments:
// - <unused>
// Return Value:
@ -1296,7 +1291,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
try
{
_InitializeBackgroundBrush();
const auto bg = _settings.DefaultBackground();
const auto bg = _settings->FocusedAppearance()->DefaultBackground();
_changeBackgroundColor(bg);
}
CATCH_LOG();
@ -1507,9 +1502,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Only update the appearance here if an unfocused config exists -
// if an unfocused config does not exist then we never would have switched
// appearances anyway so there's no need to switch back upon gaining focus
if (_UnfocusedAppearance)
if (_settings->UnfocusedAppearance())
{
UpdateAppearance(_settings);
UpdateAppearance(_settings->FocusedAppearance());
}
}
@ -1551,9 +1546,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// Check if there is an unfocused config we should set the appearance to
// upon losing focus
if (_UnfocusedAppearance)
if (_settings->UnfocusedAppearance())
{
UpdateAppearance(_UnfocusedAppearance);
UpdateAppearance(_settings->UnfocusedAppearance());
}
}
@ -1702,7 +1697,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
hstring TermControl::GetProfileName() const
{
return _settings.ProfileName();
return _settings->ProfileName();
}
hstring TermControl::WorkingDirectory() const
@ -1920,7 +1915,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
double width = fontSize.Width;
double height = fontSize.Height;
// Reserve additional space if scrollbar is intended to be visible
if (_settings.ScrollState() == ScrollbarState::Visible)
if (_settings->ScrollState() == ScrollbarState::Visible)
{
width += ScrollBar().ActualWidth();
}
@ -1942,11 +1937,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
const double scaleFactor = DisplayInformation::GetForCurrentView().RawPixelsPerViewPixel();
const auto dpi = ::base::saturated_cast<uint32_t>(USER_DEFAULT_SCREEN_DPI * scaleFactor);
return GetProposedDimensions(minSize,
_settings.FontSize(),
_settings.FontWeight(),
_settings.FontFace(),
_settings.ScrollState(),
_settings.Padding(),
_settings->FontSize(),
_settings->FontWeight(),
_settings->FontFace(),
_settings->ScrollState(),
_settings->Padding(),
dpi);
}
}
@ -1969,7 +1964,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
padding.Left + padding.Right :
padding.Top + padding.Bottom);
if (widthOrHeight && _settings.ScrollState() == ScrollbarState::Visible)
if (widthOrHeight && _settings->ScrollState() == ScrollbarState::Visible)
{
nonTerminalArea += gsl::narrow_cast<float>(ScrollBar().ActualWidth());
}
@ -2362,12 +2357,23 @@ namespace winrt::Microsoft::Terminal::Control::implementation
IControlSettings TermControl::Settings() const
{
return _settings;
return _settings.try_as<IControlSettings>();
}
void TermControl::Settings(IControlSettings newSettings)
{
_settings = newSettings;
DebugBreak();
_settings = winrt::make_self<ControlSettings>(newSettings, nullptr);
}
IControlAppearance TermControl::UnfocusedAppearance() const
{
return *_settings->UnfocusedAppearance();
}
void TermControl::UnfocusedAppearance(IControlAppearance newAppearance)
{
_settings = winrt::make_self<ControlSettings>(_settings, newAppearance);
}
Windows::Foundation::IReference<winrt::Windows::UI::Color> TermControl::TabColor() noexcept

View file

@ -15,6 +15,7 @@
#include "SearchBoxControl.h"
#include "ControlInteractivity.h"
#include "ControlSettings.h"
namespace Microsoft::Console::VirtualTerminal
{
@ -28,7 +29,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
TermControl(IControlSettings settings, TerminalConnection::ITerminalConnection connection);
winrt::fire_and_forget UpdateSettings();
winrt::fire_and_forget UpdateAppearance(const IControlAppearance newAppearance);
hstring GetProfileName() const;
@ -90,6 +90,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
IControlSettings Settings() const;
void Settings(IControlSettings newSettings);
IControlAppearance UnfocusedAppearance() const;
void UnfocusedAppearance(IControlAppearance newSettings);
static Windows::Foundation::Size GetProposedDimensions(IControlSettings const& settings, const uint32_t dpi);
static Windows::Foundation::Size GetProposedDimensions(const winrt::Windows::Foundation::Size& initialSizeInChars,
@ -133,8 +135,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
TYPED_EVENT(WarningBell, IInspectable, IInspectable);
// clang-format on
WINRT_PROPERTY(IControlAppearance, UnfocusedAppearance);
private:
friend struct TermControlT<TermControl>; // friend our parent so it can bind private event handlers
@ -152,7 +152,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
winrt::com_ptr<SearchBoxControl> _searchBox;
IControlSettings _settings;
winrt::com_ptr<ControlSettings> _settings{ nullptr };
bool _closing{ false };
bool _focused{ false };
bool _initializedTerminal{ false };
@ -199,9 +199,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return _closing;
}
void _UpdateSettingsFromUIThread(IControlSettings newSettings);
void _UpdateAppearanceFromUIThread(IControlAppearance newAppearance);
void _ApplyUISettings(const IControlSettings&);
void _UpdateSettingsFromUIThread(winrt::com_ptr<ControlSettings> newSettings);
void _UpdateAppearanceFromUIThread(winrt::com_ptr<ControlAppearance> newAppearance);
void _ApplyUISettings(const winrt::com_ptr<ControlSettings>& newSettings);
winrt::fire_and_forget UpdateAppearance(winrt::com_ptr<ControlAppearance> newAppearance);
void _InitializeBackgroundBrush();
void _BackgroundColorChangedHandler(const IInspectable& sender, const IInspectable& args);