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.95k stars 1.16k forks source link

Weird Dialog/Window border behavior #2187

Closed lucasmeneghin closed 7 months ago

lucasmeneghin commented 2 years ago
application {
    val windowState =
        rememberDialogState(height = 250.dp)
    Dialog(
        onCloseRequest = ::exitApplication,
        state = windowState,
        undecorated = true,
        transparent = true,
        resizable = false
    ) {
        Box(modifier = Modifier.fillMaxSize().border((1).dp, color = Color.Black)) {
        }
    }
}

image

If transparent = false, the lower border is there, but it is thiner.

image

transparent with height 251.dp

image

transparent = false with 251.dp

image

same with 252.dp

image

Its not specific to those values, 450 dp transparent will also not produce a lower border and etc

lizhongyue248 commented 7 months ago

Like same issue , I try to add shadow

application {
    val windowState =
        rememberDialogState(height = 250.dp)
    Dialog(
        onCloseRequest = ::exitApplication,
        state = windowState,
        undecorated = true,
        transparent = true,
        resizable = false
    ) {
        App(
            pageModifier = Modifier.fillMaxWidth()
                .shadow(20.dp, RoundedCornerShape(5.dp)),
            title = {
                WindowDraggableArea {
                    PageTitle()
                }
            }
        )
    }
}

I can‘t get shadow, and must add padding to show shaodw.

Is there any follow-up on this issue?

m-sasha commented 7 months ago

The original issue is no longer reproducible 1.6.0-rc02

@lizhongyue248 Please file a new issue, and provide a complete, minimal reproducer (the code you posted is missing the definition of App).

igordmn commented 7 months ago

It is reproducible on a non-integer system scale. On macOs it usually isn't possible to set, so it is needed to check on Windows/Linux.

Steps to reproduce:

  1. set the system scale to 125% (on Windows it is in Display settings)
  2. run the code:
    
    import androidx.compose.foundation.border
    import androidx.compose.foundation.layout.Box
    import androidx.compose.foundation.layout.fillMaxSize
    import androidx.compose.ui.Modifier
    import androidx.compose.ui.graphics.Color
    import androidx.compose.ui.unit.dp
    import androidx.compose.ui.window.singleWindowApplication

fun main() = singleWindowApplication(undecorated = true) { Box(modifier = Modifier.fillMaxSize().border((1).dp, color = Color.Red)) }


3. resize. some sizes results in a white line on the right/bottom
<img width="513" alt="image" src="https://github.com/JetBrains/compose-multiplatform/assets/5963351/dbae5ed3-1ed2-4498-8055-7846996528fc">

(in `1.6.0-rc02` the hiding isn't reproducible, only the white line)

This happens, because the system resizes the window in pixels, but AWT reports the size in int points, and loses precision. The proper fix will be to read/subscribe to the size of the window via native code.

related issue: https://github.com/JetBrains/compose-multiplatform/issues/179 (slightly different because we had overlapping with system titlebar and window border)
igordmn commented 7 months ago

Found the older issue: https://github.com/JetBrains/compose-multiplatform/issues/555. Let's keep only that issue.

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.