Skip to content

Commit

Permalink
Simplify _BackgroundColorChanged()
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyTseng authored and CodyTseng committed Jun 12, 2019
1 parent 23e6b4c commit b09b765
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,11 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// Apply stretch and opacity settings
_bgImageLayer.Stretch(_settings.BackgroundImageStretchMode());
_bgImageLayer.Opacity(_settings.BackgroundImageOpacity());

}
else
{
_bgImageLayer.Source(nullptr);
}

}

// Method Description:
Expand All @@ -306,38 +304,19 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
bgColor.B = B;
bgColor.A = 255;

if (_settings.UseAcrylic())
if (auto acrylic = _root.Background().try_as<Media::AcrylicBrush>())
{
if (auto acrylic = _root.Background().try_as<Media::AcrylicBrush>())
{
acrylic.FallbackColor(bgColor);
acrylic.TintColor(bgColor);
}

// If we're acrylic, we want to make sure that the default BG color
// is transparent, so we can see the acrylic effect on text with the
// default BG color.
_settings.DefaultBackground(ARGB(0, R, G, B));
acrylic.FallbackColor(bgColor);
acrylic.TintColor(bgColor);
}
else if (!_settings.BackgroundImage().empty())
else if (auto solidColor = _root.Background().try_as<Media::SolidColorBrush>())
{
if (auto solidColor = _root.Background().try_as<Media::SolidColorBrush>())
{
solidColor.Color(bgColor);
}
// Set the default background as transparent to prevent the
// DX layer from overwriting the background image
_settings.DefaultBackground(ARGB(0, R, G, B));
solidColor.Color(bgColor);
}
else
{
if (auto solidColor = _root.Background().try_as<Media::SolidColorBrush>())
{
solidColor.Color(bgColor);
}

_settings.DefaultBackground(RGB(R, G, B));
}
// Set the default background as transparent to prevent the
// DX layer from overwriting the background image or acrylic effect
_settings.DefaultBackground(ARGB(0, R, G, B));
});
}

Expand Down

0 comments on commit b09b765

Please sign in to comment.