Underline : first fix for discontinued lines

This commit is contained in:
dotmg 2025-07-23 19:52:09 +02:00
parent 23a628a8bb
commit c619485bb6

View file

@ -230,6 +230,7 @@ fun TimeUnitComposable(
gridColumnCount: Int gridColumnCount: Int
) { ) {
val col = if (tuo.getNum() % 2 == 0) Color(0xff, 0xfa, 0xf7) else Color(0xfb, 0xf3, 0xff) val col = if (tuo.getNum() % 2 == 0) Color(0xff, 0xfa, 0xf7) else Color(0xfb, 0xf3, 0xff)
val currentDensity = LocalDensity.current
Column( Column(
modifier = Modifier modifier = Modifier
.background(col) .background(col)
@ -339,14 +340,23 @@ fun TimeUnitComposable(
var textLayoutResult: TextLayoutResult? by remember { mutableStateOf(null) } var textLayoutResult: TextLayoutResult? by remember { mutableStateOf(null) }
Box (modifier = Modifier.fillMaxWidth() Box (modifier = Modifier.fillMaxWidth()
.drawBehind { .drawBehind {
tuo.annotations().mapNotNull { ta -> tuo.annotations().map { ta ->
ta.underlineSpec.mapNotNull { us -> ta.underlineSpec.map { us ->
var xStart = 0f var xStart = 0f
val separatorLength = if (tuo.sep0 in listOf(":", "!")) 1 else 0 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) { if (us.x > -1) {
val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0 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 = textLayoutResult?.getCursorRect(globalStartIndex)?.left ?: 0f
xStart -= leftMarginUnderline
} }
var xEnd = size.width var xEnd = size.width
if (us.y > -1 ) { if (us.y > -1 ) {