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

Added support for Mica Light & Dark based on Win11 #12196

Merged
merged 4 commits into from
Jul 16, 2023

Conversation

adirh3
Copy link
Contributor

@adirh3 adirh3 commented Jul 14, 2023

What does the pull request do?

Add support for Mica Light and Dark based on how it looks in Windows 11

What is the current behavior?

The Mica blur is very simple and does not allow for same feel as other Windows 11 apps.

Note

I had this implementation for a while in Fluent Search, and did not push it here as I thought Avalonia composition will eventually replace WinUI one (maybe I misunderstood).
Currently this Light/Dark is based on WindowsTransparencyLevel as it was the only way I found for end-user to be able to interact with WinUI stuff outside of program startup.
I am open for suggestions about changing it.

Light

image

Dark

image

Checklist

Breaking changes

Breaks the current Mica value for WindowsTranspencyLevel.

Obsoletions / Deprecations

Fixed issues

#10719

@Leon99
Copy link

Leon99 commented Jul 14, 2023

Looks promising, lack of proper Mica is a huge gap in Avalonia, especially on Windows 11!
Do you think it'd be possible to leave WindowsTranspencyLevel as Mica and choose the light or dark variant based on system settings?

/// </summary>
public static WindowTransparencyLevel Mica { get; } = new(nameof(Mica));
Copy link
Member

Choose a reason for hiding this comment

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

Removing this value is a breaking change and can't be accepted mid 11.x.

Would be reasonable to keep singe "Mica", but change it behavior depending on the window theme variant?
See

public unsafe void SetFrameThemeVariant(PlatformThemeVariant themeVariant)

Copy link
Contributor

Choose a reason for hiding this comment

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

Mica should automatically switch based on theme variant. I don't think there should be two entries for this and there aren't in WinUI either I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it, wrote it before ThemeVariants were available :D

@maxkatz6
Copy link
Member

did not push it here as I thought Avalonia composition will eventually replace WinUI one (maybe I misunderstood).

Avalonia compositor is not going to replace WinUI one. They work similarly, but one works on a framework level, and another works on OS level, where we can't have full control.

@robloo
Copy link
Contributor

robloo commented Jul 15, 2023

did not push it here as I thought Avalonia composition will eventually replace WinUI one (maybe I misunderstood).

Avalonia compositor is not going to replace WinUI one. They work similarly, but one works on a framework level, and another works on OS level, where we can't have full control.

Sure, don't have full control but also it will be a fully cross-platform implementation by migrating to the Avalonia one. Removing WinUI composition behind the scenes as many places as possible does actually seem like the right move in a cross-platform framework.

@maxkatz6
Copy link
Member

WinUI compositor is used onpy and only on windows. And only to prepare a surface to render into + a refresh timer.
Soon we will add Direct Composition support (one that existed before WinUI Composition) for the same goal, but support wider range or windows devices. So we could drop some old non-composition hacks. But again, it's all only about implementation details on Windows.

Avalonia compositor is well abstracted from that, and only is compositiing avalonia visuals.

@adirh3
Copy link
Contributor Author

adirh3 commented Jul 15, 2023

Looks promising, lack of proper Mica is a huge gap in Avalonia, especially on Windows 11! Do you think it'd be possible to leave WindowsTranspencyLevel as Mica and choose the light or dark variant based on system settings?

Changed it to be based on theme variant :)

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037772-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Jul 15, 2023
Merged via the queue into AvaloniaUI:master with commit 8852a6d Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants