Add Transpose to C btn on key tools
This commit is contained in:
parent
93797089d8
commit
89d0b850f8
2 changed files with 130 additions and 90 deletions
|
|
@ -63,11 +63,8 @@ class Transpose {
|
|||
val totalAlter = interval + currentModulationInterval
|
||||
|
||||
val transposedBody = NOTE_UNIT_REGEX.replace(remaining) { matchResult ->
|
||||
val noteCore = matchResult.groupValues[1]
|
||||
val octave = matchResult.groupValues[2]
|
||||
|
||||
val transposedCore = transpose(note = noteCore, fromKey = "C", toKey = "C", alter = totalAlter)
|
||||
transposedCore + octave
|
||||
val fullNote = matchResult.value
|
||||
transpose(note = fullNote, fromKey = "C", toKey = "C", alter = totalAlter)
|
||||
}
|
||||
|
||||
val result = separators + transposedBody
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package mg.dot.feufaro.ui
|
|||
|
||||
import SharedScreenModel
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.*
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
|
|
@ -107,6 +106,11 @@ fun MainScreenWithDrawer(
|
|||
}
|
||||
}
|
||||
val isEditMode by sharedScreenModel.modeEditor.collectAsState()
|
||||
LaunchedEffect(isEditMode) {
|
||||
if(isEditMode) {
|
||||
drawerState.close()
|
||||
}
|
||||
}
|
||||
val currentActiveFilePath = sharedScreenModel.activeFilePath.value
|
||||
val fileName = currentActiveFilePath.substringAfterLast('/')
|
||||
|
||||
|
|
@ -238,22 +242,47 @@ fun MainScreenWithDrawer(
|
|||
val isPendingChange = tempInterval != appliedInterval
|
||||
val isCurrentlyTransposed = appliedInterval != 0
|
||||
|
||||
Box(
|
||||
modifier = Modifier.padding(end = 16.dp),
|
||||
contentAlignment = Alignment.TopEnd
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
AnimatedVisibility(
|
||||
visible = isEyeVisible,
|
||||
enter = expandHorizontally(expandFrom = Alignment.End) + fadeIn(tween(300)),
|
||||
exit = shrinkHorizontally(shrinkTowards = Alignment.End) + fadeOut(tween(300))
|
||||
Text(
|
||||
text = tempUiKey,
|
||||
fontSize = 25.sp,
|
||||
fontWeight = FontWeight.Black,
|
||||
textAlign = TextAlign.Center,
|
||||
color = if (isCurrentlyTransposed && !isPendingChange) Color(0xFFFFD700) else Color.White,
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null
|
||||
) {
|
||||
isEyeVisible = !isEyeVisible
|
||||
}
|
||||
.width(45.dp)
|
||||
)
|
||||
}
|
||||
|
||||
DropdownMenu(
|
||||
expanded = isEyeVisible,
|
||||
onDismissRequest = { isEyeVisible = false },
|
||||
containerColor = Color(0xFF2C3135).copy(alpha = 0.75f),
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
modifier = Modifier.padding(12.dp)
|
||||
) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
/* < = > */
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
modifier = Modifier
|
||||
.padding(end = 8.dp)
|
||||
.background(Color.White.copy(alpha = 0.15f), RoundedCornerShape(50))
|
||||
.padding(horizontal = 4.dp)
|
||||
modifier = Modifier.padding(horizontal = 4.dp)
|
||||
) {
|
||||
/* < */
|
||||
val currentIndex = keysOrder.indexOf(tempUiKey).takeIf { it != -1 } ?: 0
|
||||
|
|
@ -278,7 +307,7 @@ fun MainScreenWithDrawer(
|
|||
|
||||
val centralIcon = if (isPendingChange) Icons.Filled.Check else Icons.Filled.SwapHoriz
|
||||
val centralTint = if (isPendingChange) Color(0xFFFFD700) else Color.White
|
||||
val tooltipText = if (isPendingChange) "Transposer en $tempUiKey" else if (isCurrentlyTransposed) "Revenir au ($songKey)" else "Transposer"
|
||||
val tooltipText = if (isPendingChange) "Transposer en $tempUiKey" else if (isCurrentlyTransposed) "Revenir en $songKey" else "Transposer"
|
||||
|
||||
TooltipBox(
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
|
|
@ -327,25 +356,39 @@ fun MainScreenWithDrawer(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
text = tempUiKey,
|
||||
fontSize = 25.sp,
|
||||
fontWeight = FontWeight.Black,
|
||||
textAlign = TextAlign.Center,
|
||||
color = if (isCurrentlyTransposed && !isPendingChange) Color(0xFFFFD700) else Color.White,
|
||||
modifier = Modifier
|
||||
.clickable(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null
|
||||
val cIndex = keysOrder.indexOf("C")
|
||||
val intervalToC = if (cIndex != -1) cIndex - songKeyIndex else 0
|
||||
|
||||
TooltipBox(
|
||||
positionProvider = TooltipDefaults.rememberPlainTooltipPositionProvider(),
|
||||
tooltip = {
|
||||
PlainTooltip(containerColor = Color.DarkGray, contentColor = Color.White) { Text(text = "Transposer en Do (C)", fontSize = 12.sp) }
|
||||
},
|
||||
state = rememberTooltipState()
|
||||
) {
|
||||
isEyeVisible = !isEyeVisible
|
||||
}
|
||||
.padding(end = 16.dp)
|
||||
.width(45.dp)
|
||||
OutlinedButton(
|
||||
onClick = {
|
||||
tempInterval = intervalToC
|
||||
sharedScreenModel.setTranspositionInterval(intervalToC)
|
||||
solfaScreenModel.loadFromFile(sharedScreenModel.activeFilePath.value)
|
||||
isEyeVisible = false
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth().height(36.dp),
|
||||
shape = RoundedCornerShape(8.dp),
|
||||
border = BorderStroke(1.dp, Color(0xFFFFD700).copy(alpha = 0.5f)),
|
||||
colors = ButtonDefaults.outlinedButtonColors(contentColor = Color(0xFFFFD700))
|
||||
) {
|
||||
Text(
|
||||
text = "Transposer en C",
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, colors = TopAppBarColors(
|
||||
containerColor = MaterialTheme.colorScheme.primary,
|
||||
titleContentColor = MaterialTheme.colorScheme.onPrimary,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue