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.withContext
|
||||
import mg.dot.feufaro.ContextualMenu
|
||||
import mg.dot.feufaro.DisplayConfigManager
|
||||
import mg.dot.feufaro.FileRepository
|
||||
import mg.dot.feufaro.TUODetailDialog
|
||||
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.SolfaScreenModel
|
||||
import org.jetbrains.compose.resources.Font
|
||||
import org.koin.compose.koinInject
|
||||
import java.io.File
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
|
@ -591,6 +593,9 @@ fun LazyVerticalGridTUO(
|
|||
onGridWidthMeasured: (Int) -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val displayConfigManager = koinInject<DisplayConfigManager>()
|
||||
val currentDisplayConfig by displayConfigManager.displayConfig.collectAsState()
|
||||
|
||||
val tuoList = viewModel.tuoList
|
||||
key(tuoList) {
|
||||
|
||||
|
|
@ -657,9 +662,12 @@ fun LazyVerticalGridTUO(
|
|||
val horizontalArrangementSpacing: Dp = 0.dp
|
||||
val columnGroupString = regexMeasure?.groupValues?.get(1) ?: "1"
|
||||
val columnGroup = columnGroupString.toInt().coerceAtLeast(1)
|
||||
val customNoteStyle = MaterialTheme.typography.bodyLarge.copy(
|
||||
fontSize = currentDisplayConfig.fontSize.sp
|
||||
)
|
||||
val tuoWidthMeasure = bestTUOWidth(
|
||||
items = tuoList,
|
||||
noteStyle = MaterialTheme.typography.bodyLarge
|
||||
noteStyle = customNoteStyle
|
||||
)
|
||||
val itemMinBaseWidth = tuoWidthMeasure.width
|
||||
val optimColGrid by sharedScreenModel.getOptimColGrid().collectAsState()
|
||||
|
|
@ -704,16 +712,16 @@ fun LazyVerticalGridTUO(
|
|||
if (!tuoWidthMeasure.isReady || gridWidthDp <= 0.dp || tuoWidthMeasure.width <= 0.dp) {
|
||||
multiple
|
||||
} else {
|
||||
val rawCapacity = (gridWidthDp + 9.dp) / tuoWidthMeasure.width
|
||||
val horizontalPaddingDp = 64.dp
|
||||
val rawCapacity = (gridWidthDp - horizontalPaddingDp) / tuoWidthMeasure.width
|
||||
val rawColsInt = rawCapacity.toInt()
|
||||
val roundedToMultiple = (rawColsInt / multiple) * multiple
|
||||
// println("Largeur écran/grille : $gridWidthDp")
|
||||
// println("Largeur bloc TUO max : ${tuoWidthMeasure.width}")
|
||||
// println("Signature temps (multiple) : $multiple")
|
||||
// println("Capacité brute d'accueil : $rawCapacity blocs ($rawColsInt entiers)")
|
||||
// println("Arrondi au multiple inférieur : $roundedToMultiple colonnes")
|
||||
// println("Nombre final retenu (min $multiple) : $finalCols colonnes")
|
||||
// println("=========================")
|
||||
|
||||
// println("Largeur brute mesurée : $gridWidthDp")
|
||||
// println("Largeur bloc TUO max : ${tuoWidthMeasure.width}")
|
||||
// println("Capacité brute nette : $rawCapacity blocs (${rawCapacity.toInt()} entiers)")
|
||||
// println("Nombre de colonnes retenu : $roundedToMultiple")
|
||||
// println("=========================")
|
||||
roundedToMultiple.coerceAtLeast(multiple)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue