Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement background image over acrylic or solid color #1107

Merged
merged 7 commits into from
Jul 10, 2019

Conversation

Summon528
Copy link
Contributor

@Summon528 Summon528 commented Jun 2, 2019

Summary of the Pull Request

Implement acrylic over background image. Also make backgroundImageOpacity works with respect to the profile's background color

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

Introduce a new root Element that holds the original container and a background image. The root element's background sits behind _bgImageLayer and is responsible for acrylic and solid background.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might also conflict with some work being done in #1092, as a heads up

src/cascadia/TerminalControl/TermControl.h Outdated Show resolved Hide resolved
@@ -312,9 +326,10 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
}
else if (!_settings.BackgroundImage().empty())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this will update the background image+acrylic scenario properly - looks like it'll only update the acrylic in that scenario

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will only update the acrylic in this scenario, however, it is intended to do that. This function is for background color only and whenever acrylic is enabled we don't actually draw the solid background layer, we apply the color as acrylic's tint whether or not background image is set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the logic is just acrylic or not. It becomes a bit confusing because of this workaround.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm more thinking: what happens when you change the background image url for a profile that has a background image+acrylic? Does the image change appropriately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it changes appropriately, although the code for it is around L251 not here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. Does the alpha for the DX renderer ever need to be non-zero?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify my previous response:

  • In all cases, the background is drawn in Xaml space by the brush.
  • In every case except a solid-color background (with no other modifications), the DX rendering drawing anything over it is erroneous.
  • Even in the solid-color background case, the brush drawing the background (as opposed to the DX renderer) is necessary because the DX renderer doesn't draw to the entire window area.

So I'm not sure there's a good reason to have the DX renderer aware of any sort of background information, since it can't "help".

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT Jun 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this specific case (Windows Terminal)1, I'm entirely inclined to agree. The default background doesn't need an alpha. @miniksa nominally owns the DX renderer, so he likely has a stronger opinion here.

[1] dxrenderer can be used by conhost, too, and conhost has a slightly different set of rendering requirements

src/cascadia/TerminalControl/TermControl.cpp Outdated Show resolved Hide resolved
@DHowett-MSFT
Copy link
Contributor

This is interesting, and I never thought about how a user might want a background image with acrylic on top of it. I expected this:

tuxfront

but I never expected this:

tuxback

I'm wondering if it's more reasonable to support the first one (_root => acrylic brush, _backgroundLayer => image brush) because the second one can easily be done with some image manipulation (and it's a lot more performant because the application doesn't need to constantly blur the same static image)?

@Summon528
Copy link
Contributor Author

Summon528 commented Jun 4, 2019

The fact that we can set a gif as our background makes some sense for the second case but I agree that we should have a more robust spec. Also to support the first case you mention we need to have a setting for image alignment too.

Edit: Actually, blurring a gif is also a relatively easy task. So I am probably inclined to agree with the image on top of acrylic. Exposing the whole background stack to setting seem way overkill IMO.

@mdtauk
Copy link

mdtauk commented Jun 4, 2019

When the idea of a Background Image was suggested, My first thought went to the Mail App, and how the sidebar will blur the background image you pick.
image

@Summon528
Copy link
Contributor Author

That's because they display blurred background and unblurred background in different part simultaneously though. We only display one version of the image at a time, so you can head toward Photoshop and blur the image in 5 seconds if you really want blurry background

@DHowett-MSFT
Copy link
Contributor

Edit: Actually, blurring a gif is also a relatively easy task. So I am probably inclined to agree with the image on top of acrylic. Exposing the whole background stack to setting seem way overkill IMO.

Sounds great to me. I'd love to accept a pull request that put the background on top of the acrylic!

@Summon528
Copy link
Contributor Author

Sounds great to me. I'd love to accept a pull request that put the background on top of the acrylic!

Roger that, I've updated this PR to enable background on top of the acrylic 😄

@DHowett-MSFT
Copy link
Contributor

Wow, I never realized that this got updated. So sorry. Force pushes don't send e-mails to the team!

@DHowett-MSFT DHowett-MSFT added the Needs-Attention The core contributors need to come back around and look at this ASAP. label Jul 1, 2019
@DHowett-MSFT
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@DHowett-MSFT
Copy link
Contributor

This now puts the background on top of the acrylic, yes? Should we update the title?

@Summon528 Summon528 changed the title Implement acrylic over background image Implement background image over acrylic or solid color Jul 2, 2019
@Summon528
Copy link
Contributor Author

This now puts the background on top of the acrylic, yes? Should we update the title?

Yes we should 😄

@Summon528
Copy link
Contributor Author

This solution, unfortunately, causes the image to shift if padding is set, I propose #1778 to fix that

Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this.

@DHowett-MSFT
Copy link
Contributor

This has two approvals and 7 successful checks, so I'm going to merge it. @Summon528 thanks for bearing with us and working on this feature!

@DHowett-MSFT DHowett-MSFT merged commit 3ce53ad into microsoft:master Jul 10, 2019
mcpiroman pushed a commit to mcpiroman/terminal that referenced this pull request Jul 23, 2019
@ghost
Copy link

ghost commented Aug 3, 2019

🎉Windows Terminal Preview v0.3.2142.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Attention The core contributors need to come back around and look at this ASAP.
Projects
None yet
6 participants