Compare commits
No commits in common. "607e7c675d4085898b96b004abfa6547e8fb0307" and "d015b9b606a44df8271c608bbbae68c5a979e013" have entirely different histories.
607e7c675d
...
d015b9b606
4 changed files with 15 additions and 27 deletions
|
|
@ -4,7 +4,7 @@ import com.russhwolf.settings.Settings
|
||||||
import com.russhwolf.settings.set
|
import com.russhwolf.settings.set
|
||||||
import androidx.compose.ui.unit.DpSize
|
import androidx.compose.ui.unit.DpSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import mg.dot.feufaro.WindowState
|
import androidx.compose.ui.window.WindowState
|
||||||
|
|
||||||
expect class SaveSettings() {
|
expect class SaveSettings() {
|
||||||
val settings: Settings
|
val settings: Settings
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ class SharedScreenModel() : ScreenModel {
|
||||||
private val _isPlayMid = MutableStateFlow(false)
|
private val _isPlayMid = MutableStateFlow(false)
|
||||||
val isPlayMid = _isPlayMid.asStateFlow()
|
val isPlayMid = _isPlayMid.asStateFlow()
|
||||||
|
|
||||||
|
private var midiFile = "whawyd3.mid"
|
||||||
|
|
||||||
fun loadNewSong(newMidiFile: String) {
|
fun loadNewSong(newMidiFile: String) {
|
||||||
_mediaPlayer?.stop()
|
_mediaPlayer?.stop()
|
||||||
|
|
@ -125,10 +126,9 @@ class SharedScreenModel() : ScreenModel {
|
||||||
_isPlay.value = false
|
_isPlay.value = false
|
||||||
_currentPos.value = 0f
|
_currentPos.value = 0f
|
||||||
_mediaPlayer = MediaPlayer(filename = newMidiFile, onFinished = {
|
_mediaPlayer = MediaPlayer(filename = newMidiFile, onFinished = {
|
||||||
// _isPos.value = true
|
_isPos.value = true
|
||||||
// _isPlay.value = false
|
_isPlay.value = false
|
||||||
_currentPos.value = 0f
|
_currentPos.value = 0f
|
||||||
seekTo(0f)
|
|
||||||
println("fin de lecture du Midi $newMidiFile")
|
println("fin de lecture du Midi $newMidiFile")
|
||||||
})
|
})
|
||||||
println("New media Player crée $newMidiFile")
|
println("New media Player crée $newMidiFile")
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ package mg.dot.feufaro
|
||||||
|
|
||||||
import com.russhwolf.settings.Settings
|
import com.russhwolf.settings.Settings
|
||||||
import com.russhwolf.settings.set
|
import com.russhwolf.settings.set
|
||||||
|
import androidx.compose.ui.window.WindowState
|
||||||
import androidx.compose.ui.window.WindowPosition
|
import androidx.compose.ui.window.WindowPosition
|
||||||
import androidx.compose.ui.unit.DpSize
|
import androidx.compose.ui.unit.DpSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import mg.dot.feufaro.WindowState
|
|
||||||
|
|
||||||
actual class SaveSettings actual constructor() {
|
actual class SaveSettings actual constructor() {
|
||||||
actual val settings: Settings = Settings()
|
actual val settings: Settings = Settings()
|
||||||
|
|
@ -29,17 +29,18 @@ actual class SaveSettings actual constructor() {
|
||||||
|
|
||||||
actual fun loadWindowState(): WindowState {
|
actual fun loadWindowState(): WindowState {
|
||||||
val bounds = loadWindowBounds()
|
val bounds = loadWindowBounds()
|
||||||
return WindowState(bounds[0], bounds[1],
|
return WindowState(
|
||||||
bounds[2], bounds[3]
|
size = DpSize(bounds[0].dp, bounds[1].dp),
|
||||||
|
position = WindowPosition(bounds[2].dp, bounds[3].dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
actual fun saveWindowState(state: WindowState) {
|
actual fun saveWindowState(state: WindowState) {
|
||||||
saveWindowBounds(
|
saveWindowBounds(
|
||||||
state.width,
|
state.size.width.value.toInt(),
|
||||||
state.height,
|
state.size.height.value.toInt(),
|
||||||
state.x,
|
state.position.x.value.toInt(),
|
||||||
state.y
|
state.position.y.value.toInt()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
@file:JvmName("MainKt")
|
|
||||||
package mg.dot.feufaro
|
package mg.dot.feufaro
|
||||||
|
|
||||||
import androidx.compose.runtime.DisposableEffect
|
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.WindowPosition
|
||||||
import androidx.compose.ui.window.application
|
import androidx.compose.ui.window.application
|
||||||
import androidx.compose.ui.window.rememberWindowState
|
import androidx.compose.ui.window.rememberWindowState
|
||||||
//import androidx.compose.ui.window.rememberWindowState
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
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.GlobalContext.startKoin
|
||||||
import org.koin.core.context.KoinContext
|
import org.koin.core.context.KoinContext
|
||||||
import org.koin.core.logger.Level
|
import org.koin.core.logger.Level
|
||||||
import mg.dot.feufaro.WindowState as MyWindowState
|
|
||||||
|
|
||||||
|
|
||||||
fun main() = application {
|
fun main() = application {
|
||||||
|
|
@ -35,14 +32,10 @@ fun main() = application {
|
||||||
println("FileRepository initialized for Desktop: $fileRepository")
|
println("FileRepository initialized for Desktop: $fileRepository")
|
||||||
|
|
||||||
val stateManager = remember { SaveSettings() }
|
val stateManager = remember { SaveSettings() }
|
||||||
val saved: MyWindowState = stateManager.loadWindowState()
|
val windowState = remember { stateManager.loadWindowState() }
|
||||||
val composeWindowState = rememberWindowState(
|
|
||||||
position = WindowPosition(saved.x.dp, saved.y.dp),
|
|
||||||
size = DpSize(saved.width.dp, saved.height.dp)
|
|
||||||
)
|
|
||||||
|
|
||||||
Window(
|
Window(
|
||||||
state = composeWindowState,
|
state = windowState,
|
||||||
onCloseRequest = {
|
onCloseRequest = {
|
||||||
exitApplication();
|
exitApplication();
|
||||||
},
|
},
|
||||||
|
|
@ -53,13 +46,7 @@ fun main() = application {
|
||||||
}
|
}
|
||||||
DisposableEffect(Unit){
|
DisposableEffect(Unit){
|
||||||
onDispose {
|
onDispose {
|
||||||
val stateToSave = MyWindowState(
|
stateManager.saveWindowState(windowState)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue