kirill-grouchnikov / aurora

Building modern, elegant and fast desktop Compose applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Window] Add ability to set rounded corners on an undecorated Aurora window

russellbanks opened this issue · comments

In Windows 11, rounded corners for windows were introduced. Of course, with an undecorated window and the nature of Java being cross-platform, it does not inherit this functionality from the operating system.

Therefore, it would be good if, for example, there was the ability to make the corners rounded, or have the corners automatically round when on Windows 11. I imagine this could be done by allowing the window to have a certain shape (of which RoundedRectangle() could be passed) or through a parameter of roundedCorners = true. Hopefully, this would then make Aurora applications feel more native for Windows 11 whilst maintaining cross-platform functionality.

Window with rounded corners

I do not have plans to support rounded corners, any sort of translucency, drop shadows or acrylic / aero / anything similar on top-level windows.

How come - is there any reason why?

Window translucency (Aero / Acrylic on Windows, and general translucent areas on macOS) require usage of native APIs. Beyond the additional complexity required to build and test such dependencies across different OSes, there is the inescapable cost that comes with trying to keep up with the ever evolving native capabilities. See my post on this from yesterday.

These are also design trends that last for a few years, to be replaced with something different. I build Radiance and Aurora for a longer time span, and do not chase such trends.

If an interested third-party wants to provide native integration for windows-level features (such as, let's say, snap layouts on Windows 11), I will consider providing support in Aurora for configuring Aurora-provided title pane with such integration points. But I will not be in the business of chasing short term fads from OS vendors.

If an interested third-party wants to provide native integration for windows-level features (such as, let's say, snap layouts on Windows 11), I will consider providing support in Aurora for configuring Aurora-provided title pane with such integration points. But I will not be in the business of chasing short term fads from OS vendors.

Following this, could there potentially be a future integration of Aurora with Compose Window Styler?

Compose Window Styler

Is there anything that stops you from using both of these projects together today?

Is there anything that stops you from using both of these projects together today?

ComposeWindowStyler requires FrameWindowScope whereas an AuroraWindow provides AuroraWindowScope/WindowScope.

Edit: I have been able to get this working by creating an extension function:

@Composable
private fun WindowScope.WindowStyle(isDarkTheme: Boolean, backdropType: WindowBackdrop = WindowBackdrop.Mica) {
    val manager = remember { WindowManager(window as JFrame, isDarkTheme, backdropType) }

    LaunchedEffect(isDarkTheme) {
        manager.isDarkTheme = isDarkTheme
    }

    LaunchedEffect(backdropType) {
        manager.backdropType = backdropType
    }
}

Looks like that could be WindowScope instead, unless they have plans to only limit it to frames and not dialogs

Looks like that could be WindowScope instead, unless they have plans to only limit it to frames and not dialogs

I made an issue about this exact thing, and they've changed it to use WindowScope, so it will work with Aurora without any extra code needed.

Thanks. If you experiment with integrating these two projects together, please let me know if you run into anything that is blocking you on the Aurora side of things.