In the chess game I wrote above I have the issue t...
# compose-desktop
p
In the chess game I wrote above I have the issue that when I drag the chess figures they are drawn below the chess tiles when I move them either right or to the bottom (only while dragging). Is it possible that these issues come from the desktop port? Is desktop compose using something different under the hood and to debug such things should I run it on android? Or do they share such fundamentals and its more likely either a usage error or an upstream compose bug?
i
Is it possible that these issues come from the desktop port?
Yes, it is possible. On the lower level we use different code (Canvas and layer manipulation).
should I run it on android
It is hard to say if the bug is in the common-compose or the desktop-compose without some example. If it reproduces on android then bug is in the common-compose (probably). Do you draw all tiles first before drawing figures? Or is Modifier.zIndex used?
a
without more than the gif to go on, it looks like you're removing cells from the rows but nothing is adding them back, so you're getting one less cell in the row every time something moves
you probably want to set that space to a blank rather than remove it entirely
p
No I didn't draw all the tiles before drawing the figures. Currently it looks like this. I assumed it was a zordering issue. But if I take this commit: https://github.com/PaulWoitaschek/Chess/blob/707c8bf88789908f1f0544b8d04180df0e6fb346/src/main/kotlin/chess/app.kt And set the zIndex:
Copy code
diff --git a/src/main/kotlin/chess/app.kt b/src/main/kotlin/chess/app.kt
index b37c318..b020af3 100644
--- a/src/main/kotlin/chess/app.kt
+++ b/src/main/kotlin/chess/app.kt
@@ -19,6 +19,7 @@ import androidx.compose.ui.res.vectorXmlResource
 import androidx.compose.ui.unit.IntOffset
 import androidx.compose.ui.unit.IntSize
 import androidx.compose.ui.unit.dp
+import androidx.compose.ui.zIndex
 import kotlin.math.roundToInt
 
 
@@ -100,6 +101,7 @@ fun BoxScope.ChessPieceImage(
         val value = offset.value
         IntOffset(value.x.roundToInt(), value.y.roundToInt())
       }
+      .zIndex(if (offset.value == Offset.Zero) 0F else 1F)
   )
 }
Then the tiles don't move on drag at all.
i
Probably all works as expected: figures are drawn inside a tile, so the next drawn tile will overlap previous tiles (and figures in them).
zIndex
changes order only for the children of the same parent, so it will not help. So you need to draw all tiles before figures.
p
Do you have a clue why everything is so tiny? The buttons feel like 12dp
i
Do you have a clue why everything is so tiny? The buttons feel like 12dp
Is it Linux with 200% scale? If so, it will be fixed soon (Compose doesn't scale properly in some distributions of Linux https://github.com/JetBrains/compose-jb/issues/188)
p
Yes indeed! It's arch on gnome
(on a 4k 15 Inch Screen)