Compare commits

..

No commits in common. "607e7c675d4085898b96b004abfa6547e8fb0307" and "d015b9b606a44df8271c608bbbae68c5a979e013" have entirely different histories.

4 changed files with 15 additions and 27 deletions

View file

@ -4,7 +4,7 @@ import com.russhwolf.settings.Settings
import com.russhwolf.settings.set
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import mg.dot.feufaro.WindowState
import androidx.compose.ui.window.WindowState
expect class SaveSettings() {
val settings: Settings

View file

@ -118,6 +118,7 @@ class SharedScreenModel() : ScreenModel {
private val _isPlayMid = MutableStateFlow(false)
val isPlayMid = _isPlayMid.asStateFlow()
private var midiFile = "whawyd3.mid"
fun loadNewSong(newMidiFile: String) {
_mediaPlayer?.stop()
@ -125,10 +126,9 @@ class SharedScreenModel() : ScreenModel {
_isPlay.value = false
_currentPos.value = 0f
_mediaPlayer = MediaPlayer(filename = newMidiFile, onFinished = {
// _isPos.value = true
// _isPlay.value = false
_isPos.value = true
_isPlay.value = false
_currentPos.value = 0f
seekTo(0f)
println("fin de lecture du Midi $newMidiFile")
})
println("New media Player crée $newMidiFile")

View file

@ -2,10 +2,10 @@ package mg.dot.feufaro
import com.russhwolf.settings.Settings
import com.russhwolf.settings.set
import androidx.compose.ui.window.WindowState
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.dp
import mg.dot.feufaro.WindowState
actual class SaveSettings actual constructor() {
actual val settings: Settings = Settings()
@ -29,17 +29,18 @@ actual class SaveSettings actual constructor() {
actual fun loadWindowState(): WindowState {
val bounds = loadWindowBounds()
return WindowState(bounds[0], bounds[1],
bounds[2], bounds[3]
return WindowState(
size = DpSize(bounds[0].dp, bounds[1].dp),
position = WindowPosition(bounds[2].dp, bounds[3].dp)
)
}
actual fun saveWindowState(state: WindowState) {
saveWindowBounds(
state.width,
state.height,
state.x,
state.y
state.size.width.value.toInt(),
state.size.height.value.toInt(),
state.position.x.value.toInt(),
state.position.y.value.toInt()
)
}
}

View file

@ -1,4 +1,3 @@
@file:JvmName("MainKt")
package mg.dot.feufaro
import androidx.compose.runtime.DisposableEffect
@ -10,7 +9,6 @@ import androidx.compose.ui.window.Window
import androidx.compose.ui.window.WindowPosition
import androidx.compose.ui.window.application
import androidx.compose.ui.window.rememberWindowState
//import androidx.compose.ui.window.rememberWindowState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -21,7 +19,6 @@ import org.koin.compose.KoinContext
import org.koin.core.context.GlobalContext.startKoin
import org.koin.core.context.KoinContext
import org.koin.core.logger.Level
import mg.dot.feufaro.WindowState as MyWindowState
fun main() = application {
@ -35,14 +32,10 @@ fun main() = application {
println("FileRepository initialized for Desktop: $fileRepository")
val stateManager = remember { SaveSettings() }
val saved: MyWindowState = stateManager.loadWindowState()
val composeWindowState = rememberWindowState(
position = WindowPosition(saved.x.dp, saved.y.dp),
size = DpSize(saved.width.dp, saved.height.dp)
)
val windowState = remember { stateManager.loadWindowState() }
Window(
state = composeWindowState,
state = windowState,
onCloseRequest = {
exitApplication();
},
@ -53,13 +46,7 @@ fun main() = application {
}
DisposableEffect(Unit){
onDispose {
val stateToSave = MyWindowState(
x = composeWindowState.position.x.value.toInt(),
y = composeWindowState.position.y.value.toInt(),
width = composeWindowState.size.width.value.toInt(),
height = composeWindowState.size.height.value.toInt()
)
stateManager.saveWindowState(stateToSave)
stateManager.saveWindowState(windowState)
}
}
}