Fixed: underlines
This commit is contained in:
parent
c619485bb6
commit
0941cc674c
3 changed files with 23 additions and 10 deletions
|
|
@ -6,7 +6,8 @@ enum class LineType {
|
|||
}
|
||||
class UnderlineSpec (
|
||||
var x: Int,
|
||||
val lineType: LineType
|
||||
val lineType: LineType,
|
||||
val isNewParen: Boolean = false
|
||||
) {
|
||||
var y: Int = -1
|
||||
var okX = false
|
||||
|
|
@ -30,9 +31,10 @@ class AnnotatedTUO (originalString: String, val voiceNumber: Int){
|
|||
while (inRoundParen.size <= voiceNumber) {
|
||||
inRoundParen.add(false)
|
||||
}
|
||||
val newParen = value && !inRoundParen[voiceNumber]
|
||||
inRoundParen[voiceNumber] = value
|
||||
if (value) {
|
||||
underlineSpec.add(UnderlineSpec(x, LineType.ROUND))
|
||||
underlineSpec.add(UnderlineSpec(x, LineType.ROUND, newParen))
|
||||
} else {
|
||||
underlineSpec.lastOrNull()?.y = x
|
||||
}
|
||||
|
|
@ -49,9 +51,10 @@ class AnnotatedTUO (originalString: String, val voiceNumber: Int){
|
|||
while (inSquareParen.size <= voiceNumber) {
|
||||
inSquareParen.add(false)
|
||||
}
|
||||
val newParen = value && !inSquareParen[voiceNumber]
|
||||
inSquareParen[voiceNumber] = value
|
||||
if (value) {
|
||||
underlineSpec.add(UnderlineSpec(x, LineType.SQUARE))
|
||||
underlineSpec.add(UnderlineSpec(x, LineType.SQUARE, newParen))
|
||||
} else {
|
||||
underlineSpec.lastOrNull()?.y = x
|
||||
}
|
||||
|
|
@ -60,10 +63,10 @@ class AnnotatedTUO (originalString: String, val voiceNumber: Int){
|
|||
var x = -1
|
||||
if (voiceNumber > 0) {
|
||||
if (inRoundParen.size > voiceNumber && inRoundParen[voiceNumber]) {
|
||||
underlineSpec.add(UnderlineSpec(0, LineType.ROUND))
|
||||
underlineSpec.add(UnderlineSpec(-1, LineType.ROUND))
|
||||
}
|
||||
if (inSquareParen.size > voiceNumber && inSquareParen[voiceNumber]) {
|
||||
underlineSpec.add(UnderlineSpec(0, LineType.SQUARE))
|
||||
underlineSpec.add(UnderlineSpec(-1, LineType.SQUARE))
|
||||
}
|
||||
originalString.toCharArray().forEach {
|
||||
when (it) {
|
||||
|
|
@ -75,7 +78,7 @@ class AnnotatedTUO (originalString: String, val voiceNumber: Int){
|
|||
else -> {
|
||||
x++
|
||||
finalText += it
|
||||
if (it in listOf('d', 'r', 'm', 'f', 's', 'l', 't')) {
|
||||
if (it in listOf('d', 'r', 'm', 'f', 's', 'l', 't', '-', '―')) {
|
||||
val lastUnderLineSpec = underlineSpec.lastOrNull()
|
||||
if (lastUnderLineSpec?.okX == false) {
|
||||
lastUnderLineSpec.okX = true
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
val REGEX_VOWELS_STAGE3 = Regex("_([\\?\\!:,;\\.»\\)]+)")
|
||||
val REGEX_MALAGASY_MN = Regex("([aeio])_([nm])([tdjkbp])")
|
||||
val REGEX_MALAGASY_MN_STAGE2 = Regex("_([mn])-")
|
||||
val REGEX_PAREN_RECURSIVE = Regex("(\\([^\\(\\)]*)\\(([^\\)]*)\\)")
|
||||
}
|
||||
var nextTIndex: Int = -1
|
||||
var nextNIndex: Int = -1
|
||||
|
|
@ -151,6 +152,9 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
}
|
||||
private fun rearrangeNote(noteString: String, infiniteIter: Int = 0): String {
|
||||
var result: String = noteString
|
||||
result = result .replace(REGEX_PAREN_RECURSIVE, "$1$2")
|
||||
result = result .replace(REGEX_PAREN_RECURSIVE, "$1$2")
|
||||
result = result .replace(REGEX_PAREN_RECURSIVE, "$1$2")
|
||||
result = result .replace(REGEX_SHIFT_PAREN_UPWARD, "$2$1")
|
||||
result = result .replace(REGEX_SHIFT_PAREN_DOWNWARD, "$2$1")
|
||||
result = result .replace(REGEX_COLLAPSE_PARENS_OPEN, "$1")
|
||||
|
|
@ -228,10 +232,14 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
|||
replacement = if (noteCharIterator.hasNext()) noteCharIterator.next() else 'd'
|
||||
firstInLoop = false
|
||||
}
|
||||
if (replacement == '(') {
|
||||
result += replacement
|
||||
replacement = if (noteCharIterator.hasNext()) noteCharIterator.next() else 'd'
|
||||
}
|
||||
for (repetition in 0 until 6) {
|
||||
result += replacement
|
||||
replacement = if (noteCharIterator.hasNext()) noteCharIterator.next() else 'd'
|
||||
if (replacement in setOf('d', 'r', 'm', 'f', 's', 'l', 't' , 'z',
|
||||
if (replacement in setOf('d', 'r', 'm', 'f', 's', 'l', 't' , 'z', '(',
|
||||
'D', 'R', 'M', 'F', 'S', 'L', 'T', '-', 'Z')) {
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -345,8 +345,8 @@ fun TimeUnitComposable(
|
|||
var xStart = 0f
|
||||
val separatorLength = if (tuo.sep0 in listOf(":", "!")) 1 else 0
|
||||
val leftMarginUnderlineDp = when (tuo.sep0) {
|
||||
"/" -> 8.dp
|
||||
"|" -> 5.dp
|
||||
"!" -> 8.dp
|
||||
":" -> 3.dp
|
||||
else -> 0.dp
|
||||
}
|
||||
val leftMarginUnderline = with(currentDensity) {
|
||||
|
|
@ -356,7 +356,9 @@ fun TimeUnitComposable(
|
|||
val lineGlobalStartOffset = textLayoutResult?.getLineStart(ta.voiceNumber - 1) ?: 0
|
||||
val globalStartIndex = lineGlobalStartOffset + us.x
|
||||
xStart = textLayoutResult?.getCursorRect(globalStartIndex)?.left ?: 0f
|
||||
xStart -= leftMarginUnderline
|
||||
if (us.isNewParen) {
|
||||
xStart += leftMarginUnderline
|
||||
}
|
||||
}
|
||||
var xEnd = size.width
|
||||
if (us.y > -1 ) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue