Fix(ui): adjust grid column calculation to account for horizontal padding
This commit is contained in:
parent
7691fb981c
commit
92184a6583
1 changed files with 17 additions and 9 deletions
|
|
@ -56,6 +56,7 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import mg.dot.feufaro.ContextualMenu
|
import mg.dot.feufaro.ContextualMenu
|
||||||
|
import mg.dot.feufaro.DisplayConfigManager
|
||||||
import mg.dot.feufaro.FileRepository
|
import mg.dot.feufaro.FileRepository
|
||||||
import mg.dot.feufaro.TUODetailDialog
|
import mg.dot.feufaro.TUODetailDialog
|
||||||
import mg.dot.feufaro.data.GridTUOData
|
import mg.dot.feufaro.data.GridTUOData
|
||||||
|
|
@ -66,6 +67,7 @@ import mg.dot.feufaro.ui.rememberFileSaveLauncher
|
||||||
import mg.dot.feufaro.viewmodel.MidiMarkers
|
import mg.dot.feufaro.viewmodel.MidiMarkers
|
||||||
import mg.dot.feufaro.viewmodel.SolfaScreenModel
|
import mg.dot.feufaro.viewmodel.SolfaScreenModel
|
||||||
import org.jetbrains.compose.resources.Font
|
import org.jetbrains.compose.resources.Font
|
||||||
|
import org.koin.compose.koinInject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
@ -591,6 +593,9 @@ fun LazyVerticalGridTUO(
|
||||||
onGridWidthMeasured: (Int) -> Unit,
|
onGridWidthMeasured: (Int) -> Unit,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
|
val displayConfigManager = koinInject<DisplayConfigManager>()
|
||||||
|
val currentDisplayConfig by displayConfigManager.displayConfig.collectAsState()
|
||||||
|
|
||||||
val tuoList = viewModel.tuoList
|
val tuoList = viewModel.tuoList
|
||||||
key(tuoList) {
|
key(tuoList) {
|
||||||
|
|
||||||
|
|
@ -657,9 +662,12 @@ fun LazyVerticalGridTUO(
|
||||||
val horizontalArrangementSpacing: Dp = 0.dp
|
val horizontalArrangementSpacing: Dp = 0.dp
|
||||||
val columnGroupString = regexMeasure?.groupValues?.get(1) ?: "1"
|
val columnGroupString = regexMeasure?.groupValues?.get(1) ?: "1"
|
||||||
val columnGroup = columnGroupString.toInt().coerceAtLeast(1)
|
val columnGroup = columnGroupString.toInt().coerceAtLeast(1)
|
||||||
|
val customNoteStyle = MaterialTheme.typography.bodyLarge.copy(
|
||||||
|
fontSize = currentDisplayConfig.fontSize.sp
|
||||||
|
)
|
||||||
val tuoWidthMeasure = bestTUOWidth(
|
val tuoWidthMeasure = bestTUOWidth(
|
||||||
items = tuoList,
|
items = tuoList,
|
||||||
noteStyle = MaterialTheme.typography.bodyLarge
|
noteStyle = customNoteStyle
|
||||||
)
|
)
|
||||||
val itemMinBaseWidth = tuoWidthMeasure.width
|
val itemMinBaseWidth = tuoWidthMeasure.width
|
||||||
val optimColGrid by sharedScreenModel.getOptimColGrid().collectAsState()
|
val optimColGrid by sharedScreenModel.getOptimColGrid().collectAsState()
|
||||||
|
|
@ -704,16 +712,16 @@ fun LazyVerticalGridTUO(
|
||||||
if (!tuoWidthMeasure.isReady || gridWidthDp <= 0.dp || tuoWidthMeasure.width <= 0.dp) {
|
if (!tuoWidthMeasure.isReady || gridWidthDp <= 0.dp || tuoWidthMeasure.width <= 0.dp) {
|
||||||
multiple
|
multiple
|
||||||
} else {
|
} else {
|
||||||
val rawCapacity = (gridWidthDp + 9.dp) / tuoWidthMeasure.width
|
val horizontalPaddingDp = 64.dp
|
||||||
|
val rawCapacity = (gridWidthDp - horizontalPaddingDp) / tuoWidthMeasure.width
|
||||||
val rawColsInt = rawCapacity.toInt()
|
val rawColsInt = rawCapacity.toInt()
|
||||||
val roundedToMultiple = (rawColsInt / multiple) * multiple
|
val roundedToMultiple = (rawColsInt / multiple) * multiple
|
||||||
// println("Largeur écran/grille : $gridWidthDp")
|
|
||||||
// println("Largeur bloc TUO max : ${tuoWidthMeasure.width}")
|
// println("Largeur brute mesurée : $gridWidthDp")
|
||||||
// println("Signature temps (multiple) : $multiple")
|
// println("Largeur bloc TUO max : ${tuoWidthMeasure.width}")
|
||||||
// println("Capacité brute d'accueil : $rawCapacity blocs ($rawColsInt entiers)")
|
// println("Capacité brute nette : $rawCapacity blocs (${rawCapacity.toInt()} entiers)")
|
||||||
// println("Arrondi au multiple inférieur : $roundedToMultiple colonnes")
|
// println("Nombre de colonnes retenu : $roundedToMultiple")
|
||||||
// println("Nombre final retenu (min $multiple) : $finalCols colonnes")
|
// println("=========================")
|
||||||
// println("=========================")
|
|
||||||
roundedToMultiple.coerceAtLeast(multiple)
|
roundedToMultiple.coerceAtLeast(multiple)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue