From c619485bb60885b0e47a34bccc14d1ec7aacac6d Mon Sep 17 00:00:00 2001 From: dotmg Date: Wed, 23 Jul 2025 19:52:09 +0200 Subject: [PATCH] Underline : first fix for discontinued lines --- .../mg/dot/feufaro/solfa/TimeUnitObject.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt index ece0d19..b90b542 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt @@ -230,6 +230,7 @@ fun TimeUnitComposable( gridColumnCount: Int ) { val col = if (tuo.getNum() % 2 == 0) Color(0xff, 0xfa, 0xf7) else Color(0xfb, 0xf3, 0xff) + val currentDensity = LocalDensity.current Column( modifier = Modifier .background(col) @@ -339,14 +340,23 @@ fun TimeUnitComposable( var textLayoutResult: TextLayoutResult? by remember { mutableStateOf(null) } Box (modifier = Modifier.fillMaxWidth() .drawBehind { - tuo.annotations().mapNotNull { ta -> - ta.underlineSpec.mapNotNull { us -> + tuo.annotations().map { ta -> + ta.underlineSpec.map { us -> var xStart = 0f val separatorLength = if (tuo.sep0 in listOf(":", "!")) 1 else 0 + val leftMarginUnderlineDp = when (tuo.sep0) { + "/" -> 8.dp + "|" -> 5.dp + else -> 0.dp + } + val leftMarginUnderline = with(currentDensity) { + leftMarginUnderlineDp.toPx() + } if (us.x > -1) { val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0 - val globalStartIndex = lineGlobalStartOffset + us.x + separatorLength + val globalStartIndex = lineGlobalStartOffset + us.x xStart = textLayoutResult?.getCursorRect(globalStartIndex)?.left ?: 0f + xStart -= leftMarginUnderline } var xEnd = size.width if (us.y > -1 ) {