Compare commits

..

No commits in common. "c6cae93dffcf2ca24d7f3ef13827deb8b9198d02" and "14c27b541a7532cd4af3f212031716158148a296" have entirely different histories.

4 changed files with 30 additions and 146 deletions

View file

@ -780,12 +780,9 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
editState: TUOEditState
): String {
/* On ne modifie pas le template tant que les notes ne sont pas modifiées
* Et tant qu'un marker est ajouter
* Ou une séparateur de mesure est ajouter */
* Et tant qu'une marker est ajouter */
val notesByVoice = editState.notesByVoice
val originalNotes = editState.originalNotes
val separat = editState.sep
val originalSeparat = editState.originalSep
var anyNoteModified = false
for (voiceNum in 0..3) {
val newNot = notesByVoice[voiceNum] ?: ""
@ -796,9 +793,6 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
break
}
}
if((originalSeparat != separat)) {
anyNoteModified = true
}
if (!anyNoteModified && newMarkerValue.isEmpty()) {
println("Aucune modification détectée, on retourne le template original.")
return templateLine
@ -891,7 +885,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
}
}
val rawProcessed = separat + leadingCloseParentheses + newMarkerValue + existingMarker + adjustedTemplate
val rawProcessed = leadingCloseParentheses + newMarkerValue + existingMarker + adjustedTemplate
var cleanedProcessed = rawProcessed
while (cleanedProcessed.contains("((") || cleanedProcessed.contains("))")) {
@ -975,14 +969,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
// currentLogicalIdx, rawBlockText, actionTaken, compactedBlock.toString()))
resultBody.append(compactedBlock)
if (i < body.length) {
// println("$currentLogicalIdx == ${targetPointer - 1} && ($separat) && ${body[i]} in separators")
if (currentLogicalIdx == (targetPointer-1) && separat.isEmpty() && body[i] in separators) {
resultBody.append('|')
} else {
resultBody.append(body[i])
}
}
if (i < body.length) resultBody.append(body[i])
currentBlock.clear()
currentLogicalIdx++

View file

@ -11,7 +11,11 @@ import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowForward
import androidx.compose.material.icons.filled.*
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.KeyboardDoubleArrowLeft
import androidx.compose.material.icons.filled.KeyboardDoubleArrowRight
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
@ -19,11 +23,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.*
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupProperties
@ -58,14 +63,10 @@ fun TUODetailDialog(
}
var templateFragment by remember { mutableStateOf(editState.templateFragment) }
var newSep by remember { mutableStateOf(editState.sep) }
var marker by remember { mutableStateOf(editState.marker) }
val initialSep = remember { editState.sep }
val initialMarker = remember { editState.marker }
var canAddSep = mutableStateOf(false)
LaunchedEffect(notes.toMap()) {
val tempState = TUOEditState(
tuoIndex = editState.tuoIndex,
@ -236,62 +237,7 @@ fun TUODetailDialog(
.verticalScroll(rememberScrollState())
) {
// --- SECTION TEMPLATE ---
Row(horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically) {
if(globalIndex != 0) {
Column(
modifier = Modifier.width(20.dp)
) {
val isSeparator = (newSep.isNotEmpty() || canAddSep.value) && newSep == "/"
val tooltipText = if (isSeparator) {
"Enlever la barre de mesure"
} else {
"Ajouter une barre de mesure"
}
TooltipBox(
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
tooltip = {
PlainTooltip(
containerColor = Color.DarkGray,
contentColor = Color.White
) {
Text(text = tooltipText, fontSize = 12.sp)
}
},
state = rememberTooltipState()
) {
if(isSeparator) {
IconButton(
modifier = Modifier.size(20.dp),
onClick = {
canAddSep.value = false
newSep = ""
}) {
Text(
text = "/",
color = Color.Cyan,
fontSize = 18.sp,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center
)
}
} else {
IconButton(
modifier = Modifier.size(20.dp),
onClick = {
canAddSep.value = true
newSep = "/"
}) {
Icon(
imageVector = Icons.Default.Add,
tint = Color.Cyan,
contentDescription = null
)
}
}
}
}
}
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Column(
modifier = Modifier.weight(1f)
) {
@ -457,8 +403,6 @@ fun TUODetailDialog(
templateFragment = templateFragment,
/* On ne ré-insere pas la même marker*/
marker = if(marker != initialMarker) marker else "",
originalSep = initialSep,
sep = if(newSep != initialSep) newSep else ""
)
onSave(state)
},
@ -476,7 +420,7 @@ fun TUODetailDialog(
}
}
}
private fun transformMusicalInput(input: String): String {
fun transformMusicalInput(input: String): String {
return input.lowercase()
.replace(";", "• ,")
.replace(".", "")

View file

@ -8,7 +8,5 @@ data class TUOEditState(
val originalLyricsByStanza: MutableMap<Int, String> = mutableMapOf(),
val templateFragment: String = "",
val marker: String = "",
val silentDuration: String = "-1",
val originalSep: String = " ",
val sep: String = " "
val silentDuration: String = "-1"
)

View file

@ -6,9 +6,7 @@ import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.focusable
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsHoveredAsState
@ -18,9 +16,11 @@ import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.Undo
import androidx.compose.material.icons.filled.ArrowBackIosNew
import androidx.compose.material.icons.filled.Build
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Description
import androidx.compose.material.icons.filled.KeyboardDoubleArrowLeft
import androidx.compose.material.icons.filled.Save
import androidx.compose.material3.*
import androidx.compose.runtime.*
@ -28,8 +28,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
@ -38,7 +36,6 @@ import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.*
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
@ -268,9 +265,7 @@ fun TimeUnitComposable(
tuo: TimeUnitObject,
stanzaNumber: Int,
gridColumnCount: Int,
gridActive: Boolean,
isCurrentBlock: Boolean = false,
parentFocusRequester: FocusRequester? = null
gridActive: Boolean
) {
val col = if (tuo.getNum() % 2 == 0) Color(0xff, 0xfa, 0xf7) else Color(0xfb, 0xf3, 0xff)
val currentDensity = LocalDensity.current
@ -279,8 +274,6 @@ fun TimeUnitComposable(
targetValue = if (gridActive) Color.Cyan.copy(alpha = 0.5f) else col,
animationSpec = tween(durationMillis = 100) // Très court pour rester réactif
)
val focusRequesters = remember { List(4) { FocusRequester() } }
Column(
modifier = Modifier
.background(animatedColor)
@ -576,9 +569,6 @@ fun LazyVerticalGridTUO(
var selectedIndex by remember { mutableStateOf(-1) }
val regexMeasure = Regex("(\\d)/\\d").find(viewModel.measure)
val focusRequester = remember { FocusRequester() }
var selectedGridIndex by remember { mutableStateOf(0) }
LaunchedEffect(tuoList) {
showContextualMenu = false
showEditDialog = false
@ -590,21 +580,13 @@ fun LazyVerticalGridTUO(
val editMode by sharedScreenModel.modeEditor.collectAsState()
val focusManager = LocalFocusManager.current
Column(
modifier = Modifier
.fillMaxWidth()
.onSizeChanged { size ->
onGridWidthMeasured(size.width)
}
.focusRequester(focusRequester)
.focusable()
) {
LaunchedEffect(editMode) {
if (editMode) {
focusRequester.requestFocus()
}
}
val density = LocalDensity.current
val horizontalArrangementSpacing: Dp = 0.dp
val columnGroupString = regexMeasure?.groupValues?.get(1) ?: "1"
@ -783,7 +765,6 @@ fun LazyVerticalGridTUO(
measureTUOs.forEachIndexed { indexInMeasure, oneTUO ->
val globalIndex = (measureIndex * gridColumnCount) + indexInMeasure
val isActive = (globalIndex == activeRowIndex)
val isSelectedByKeyboard = (globalIndex == selectedGridIndex)
val myTimestamp = sharedScreenModel.tuoTimestamps.value.getOrElse(globalIndex) { 0L }
var menuOffset by remember { mutableStateOf(Offset.Zero) }
@ -793,11 +774,6 @@ fun LazyVerticalGridTUO(
key(oneTUO.numBlock) {
Box(modifier = Modifier
.width(gridWidthDp / gridColumnCount)
.border(
width = if (isSelectedByKeyboard && editMode) 2.dp else 0.dp,
color = if (isSelectedByKeyboard && editMode) Color(0xFF9C27B0) else Color.Transparent,
shape = RoundedCornerShape(4.dp)
)
.background(
if (isHovered) Color.Black.copy(alpha = 0.05f) else Color.Transparent,
RoundedCornerShape(4.dp)
@ -811,7 +787,6 @@ fun LazyVerticalGridTUO(
detectTapGestures(
onTap = { offset ->
if(editMode) {
selectedGridIndex = globalIndex
menuOffset = offset
selectedTUO = oneTUO
selectedIndex = globalIndex
@ -827,9 +802,7 @@ fun LazyVerticalGridTUO(
tuo = oneTUO,
stanzaNumber = currentStanza,
gridColumnCount = gridColumnCount,
gridActive = isActive,
isCurrentBlock = isSelectedByKeyboard && editMode,
parentFocusRequester = focusRequester
gridActive = isActive
)
if (showContextualMenu && selectedIndex == globalIndex) {
@ -904,8 +877,7 @@ fun LazyVerticalGridTUO(
oneTUO.pTemplate.markerToString().takeIf { it.isNotBlank() },
oneTUO.hasHairPin()?.toString()?.takeIf { it.isNotBlank() }
).joinToString(" "),
silentDuration = blankPrefix,
sep = oneTUO.sep0
silentDuration = blankPrefix
)
TUODetailDialog(
editState = editState,
@ -1451,20 +1423,3 @@ fun autoFixNote(rawNote: String, template: String): String {
// println("on a RES ${finalResult}")
return finalResult
}
private fun transformMusicalInput(input: String): String {
return input.lowercase()
.replace(";", "• ,")
.replace(".", "")
.replace("-", "")
.replace("(?<=[a-z])[']".toRegex(), "¹")
.replace("(?<=[a-z])[,]".toRegex(), "")
.replace("¹¹", "²")
.replace("¹'", "²")
.replace("²¹", "³")
.replace("²'", "³")
.replace("₁,", "")
.replace("₁₁", "")
.replace("₂,", "")
.replace("₂₁", "")
.replace("'", "¹")
}