Compare commits

...

4 Commits

Author SHA1 Message Date
Mike Griese
ffc78620e6 take this 🗡️ 2023-08-23 14:08:59 -05:00
Jaswir
d0d2493e12 Update src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw
Accepted Mike's suggestion comment for translators + value more consistent with codebase

Co-authored-by: Mike Griese <migrie@microsoft.com>
2023-08-15 20:17:24 +02:00
Jaswir Raghoe
f8b1d32d37 Run Code Formatting 2023-07-20 11:11:07 +02:00
Jaswir Raghoe
4f36417b57 Rebase 2531 Add a key binding to set or toggle acrylic to Master 2023-07-20 11:06:43 +02:00
11 changed files with 67 additions and 13 deletions

View File

@@ -1178,6 +1178,15 @@ namespace winrt::TerminalApp::implementation
}
}
void TerminalPage::_HandleToggleAcrylic(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
const auto res = _ApplyToActiveControls([&](auto& control) {
control.ToggleAcrylic();
});
args.Handled(res);
}
void TerminalPage::_HandleSelectAll(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{

View File

@@ -684,7 +684,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_runtimeOpacity = newOpacity;
// Manually turn off acrylic if they turn off transparency.
_runtimeUseAcrylic = newOpacity < 1.0 && _settings->UseAcrylic();
// _runtimeUseAcrylic = newOpacity < 1.0 && _acrylicToggle;
// Update the renderer as well. It might need to fall back from
// cleartype -> grayscale if the BG is transparent / acrylic.
@@ -698,6 +698,26 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_TransparencyChangedHandlers(*this, *eventArgs);
}
void ControlCore::ToggleAcrylic()
{
// Don't Toggle Acrylic if they have transparency turned off
if (Opacity() < 1.0)
{
UseAcrylic(!UseAcrylic());
}
// Update the renderer as well. It might need to fall back from
// cleartype -> grayscale if the BG is transparent / acrylic.
if (_renderEngine)
{
_renderEngine->EnableTransparentBackground(_isBackgroundTransparent());
_renderer->NotifyPaintFrame();
}
auto eventArgs = winrt::make_self<TransparencyChangedEventArgs>(0.0);
_TransparencyChangedHandlers(*this, *eventArgs);
}
void ControlCore::ToggleShaderEffects()
{
const auto path = _settings->PixelShaderPath();

View File

@@ -218,6 +218,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void AdjustOpacity(const double opacity, const bool relative);
void ToggleAcrylic();
void WindowVisibilityChanged(const bool showOrHide);
uint64_t OwningHwnd();

View File

@@ -138,6 +138,7 @@ namespace Microsoft.Terminal.Control
String ReadEntireBuffer();
void AdjustOpacity(Double Opacity, Boolean relative);
void ToggleAcrylic();
void WindowVisibilityChanged(Boolean showOrHide);
void ColorSelection(SelectionColor fg, SelectionColor bg, Microsoft.Terminal.Core.MatchMode matchMode);

View File

@@ -678,7 +678,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// GH#11743: Make sure to use the Core's current UseAcrylic value, not
// the one from the settings. The Core's runtime UseAcrylic may have
// changed from what was in the original settings.
if (_core.UseAcrylic() && !transparentBg)
//
// Don't use acrylic even if the user asked for it, if we're fully opaque
if (_core.UseAcrylic() && !transparentBg && _core.Opacity() < 1.0)
{
// See if we've already got an acrylic background brush
// to avoid the flicker when setting up a new one
@@ -3392,6 +3394,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_core.AdjustOpacity(opacity, relative);
}
void TermControl::ToggleAcrylic()
{
_core.ToggleAcrylic();
}
// - You'd think this should just be "Opacity", but UIElement already
// defines an "Opacity", which we're actually not setting at all. We're
// not overriding or changing _that_ value. Callers that want the opacity

View File

@@ -146,6 +146,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void AdjustOpacity(const double opacity, const bool relative);
void ToggleAcrylic();
bool RawWriteKeyEvent(const WORD vkey, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers, const bool keyDown);
bool RawWriteChar(const wchar_t character, const WORD scanCode, const winrt::Microsoft::Terminal::Core::ControlKeyStates modifiers);
void RawWriteString(const winrt::hstring& text);

View File

@@ -111,6 +111,8 @@ namespace Microsoft.Terminal.Control
void AdjustOpacity(Double Opacity, Boolean relative);
void ToggleAcrylic();
// You'd think this should just be "Opacity", but UIElement already
// defines an "Opacity", which we're actually not setting at all. We're
// not overriding or changing _that_ value. Callers that want the

View File

@@ -82,6 +82,7 @@ static constexpr std::string_view ClearBufferKey{ "clearBuffer" };
static constexpr std::string_view MultipleActionsKey{ "multipleActions" };
static constexpr std::string_view QuitKey{ "quit" };
static constexpr std::string_view AdjustOpacityKey{ "adjustOpacity" };
static constexpr std::string_view ToggleAcrylicKey{ "toggleAcrylic" };
static constexpr std::string_view RestoreLastClosedKey{ "restoreLastClosed" };
static constexpr std::string_view SelectAllKey{ "selectAll" };
static constexpr std::string_view SelectCommandKey{ "selectCommand" };
@@ -414,6 +415,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{ ShortcutAction::MultipleActions, MustGenerate },
{ ShortcutAction::Quit, RS_(L"QuitCommandKey") },
{ ShortcutAction::AdjustOpacity, MustGenerate },
{ ShortcutAction::ToggleAcrylic, RS_(L"ToggleAcrylicCommandKey") },
{ ShortcutAction::RestoreLastClosed, RS_(L"RestoreLastClosedCommandKey") },
{ ShortcutAction::SelectCommand, MustGenerate },
{ ShortcutAction::SelectOutput, MustGenerate },

View File

@@ -95,6 +95,7 @@
ON_ALL_ACTIONS(MultipleActions) \
ON_ALL_ACTIONS(Quit) \
ON_ALL_ACTIONS(AdjustOpacity) \
ON_ALL_ACTIONS(ToggleAcrylic) \
ON_ALL_ACTIONS(RestoreLastClosed) \
ON_ALL_ACTIONS(SelectAll) \
ON_ALL_ACTIONS(SelectCommand) \

View File

@@ -571,6 +571,10 @@
<value>Set background opacity to {0}%</value>
<comment>A command to change how transparent the background of the window is</comment>
</data>
<data name="ToggleAcrylicCommandKey" xml:space="preserve">
<value>Toggle acrylic</value>
<comment>A command to toggle whether the "acrylic" window effect is enabled or not. "Acrylic" is a Microsoft-specific term: https://docs.microsoft.com/en-us/windows/apps/design/style/acrylic</comment>
</data>
<data name="RestoreLastClosedCommandKey" xml:space="preserve">
<value>Restore the last closed pane or tab</value>
</data>

View File

@@ -487,6 +487,21 @@
{ "command": "resetFontSize", "keys": "ctrl+0" },
{ "command": "resetFontSize", "keys": "ctrl+numpad_0" },
// Transparency Effects
{
"name": { "key": "SetOpacityParentCommandName" },
"commands": [
{ "command": { "action": "adjustOpacity", "opacity": 0, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 25, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 50, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 75, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 100, "relative": false } }
]
},
{ "command": "toggleAcrylic", "keys": "ctrl+space" },
// Other commands
{
// Select color scheme...
@@ -539,16 +554,5 @@
}
]
},
{
// Set opacity...
"name": { "key": "SetOpacityParentCommandName" },
"commands": [
{ "command": { "action": "adjustOpacity", "opacity": 0, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 25, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 50, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 75, "relative": false } },
{ "command": { "action": "adjustOpacity", "opacity": 100, "relative": false } }
]
}
]
}