make this a macro in case we want to reuse this

This commit is contained in:
Mike Griese 2021-09-23 15:45:25 -05:00
parent 43ec102343
commit dad065e0fe
5 changed files with 23 additions and 6 deletions

View file

@ -435,14 +435,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}
auto newOpacity = std::clamp(_settings.Opacity() + adjustment,
auto newOpacity = std::clamp(Opacity() + adjustment,
0.0,
1.0);
// GH#5098: Inform the engine of the new opacity of the default text background.
SetBackgroundOpacity(::base::saturated_cast<float>(newOpacity));
_settings.Opacity(newOpacity);
Opacity(newOpacity);
auto eventArgs = winrt::make_self<TransparencyChangedEventArgs>(newOpacity);
_TransparencyChangedHandlers(*this, *eventArgs);
@ -569,6 +569,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_settings = settings;
_runtimeOpacity = std::nullopt;
// Initialize our font information.
const auto fontFace = _settings.FontFace();
const short fontHeight = ::base::saturated_cast<short>(_settings.FontSize());

View file

@ -30,6 +30,14 @@ namespace ControlUnitTests
class ControlInteractivityTests;
};
#define RUNTIME_SETTING(type, name, setting) \
private: \
std::optional<type> _runtime##name{ std::nullopt }; \
void name(const type newValue) { _runtime##name = newValue; } \
\
public: \
type name() const { return _runtime##name ? *_runtime##name : setting; }
namespace winrt::Microsoft::Terminal::Control::implementation
{
struct ControlCore : ControlCoreT<ControlCore>
@ -149,6 +157,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
hstring ReadEntireBuffer() const;
RUNTIME_SETTING(double, Opacity, _settings.Opacity());
// -------------------------------- WinRT Events ---------------------------------
// clang-format off
WINRT_CALLBACK(FontSizeChanged, Control::FontSizeChangedEventArgs);

View file

@ -47,6 +47,7 @@ namespace Microsoft.Terminal.Control
Windows.Foundation.Size FontSize { get; };
String FontFaceName { get; };
UInt16 FontWeight { get; };
Double Opacity { get; };
Boolean TrySendKeyEvent(Int16 vkey,
Int16 scanCode,

View file

@ -450,7 +450,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
acrylic.TintColor(bgColor);
// Apply brush settings
acrylic.TintOpacity(appearance.Opacity());
acrylic.TintOpacity(_core.Opacity());
// Apply brush to control if it's not already there
if (RootGrid().Background() != acrylic)
@ -459,16 +459,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
// GH#5098: Inform the engine of the new opacity of the default text background.
_core.SetBackgroundOpacity(::base::saturated_cast<float>(appearance.Opacity()));
_core.SetBackgroundOpacity(::base::saturated_cast<float>(_core.Opacity()));
}
else
{
Media::SolidColorBrush solidColor{};
solidColor.Opacity(_settings.Opacity());
solidColor.Opacity(_core.Opacity());
RootGrid().Background(solidColor);
// GH#5098: Inform the engine of the new opacity of the default text background.
_core.SetBackgroundOpacity(appearance.Opacity());
_core.SetBackgroundOpacity(_core.Opacity());
}
}

View file

@ -35,5 +35,9 @@ namespace Microsoft.Terminal.Settings.Model
void ApplyColorScheme(ColorScheme scheme);
ColorScheme AppliedColorScheme;
String Commandline { set; };
String StartingDirectory { set; };
String EnvironmentVariables { set; };
};
}