JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.73k stars 1.14k forks source link

How can I add a round corner to a window when its `undecorated` attribute was set to `true`? #2433

Open SpaceXC opened 1 year ago

SpaceXC commented 1 year ago

I don't want the white bar on the top of the window, so I set undecorated to true and add a customized close and minimize button to the top of the window. But I want my window to be round-cornered and I want to add the system-followed close and minimize button like this

image

How can I do that? Thanks a lot (XD

tangshimin commented 1 year ago

related issue https://github.com/JetBrains/compose-jb/issues/877

SpaceXC commented 1 year ago

Thanks for answering, but I would like to add more margin like chrome, currently the toolbar is too close to the window edge. Also, how can I implement this on Windows?

image
guiyanakuang commented 8 months ago

@SpaceXC You can do this by adding addComponentListener

    Window(onCloseRequest = ::exitApplication,
        undecorated = true) {

        window.addComponentListener(object : java.awt.event.ComponentAdapter() {
            override fun componentResized(e: java.awt.event.ComponentEvent?) {
                window.shape = RoundRectangle2D.Double(
                    0.0,
                    0.0,
                    window.width.toDouble(),
                    window.height.toDouble(),
                    30.0,
                    30.0
                )

            }
        })

        App()
    }
SpaceXC commented 8 months ago

@guiyanakuang thanks! I'll try that out!