feat(ui/jvm): support system scaling
This commit is contained in:
parent
8e02b98c51
commit
fe46a32eba
1 changed files with 16 additions and 1 deletions
|
|
@ -1,14 +1,29 @@
|
|||
package moe.lava.neon
|
||||
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.window.Window
|
||||
import androidx.compose.ui.window.application
|
||||
import moe.lava.neon.ui.App
|
||||
|
||||
// The UI is designed with touchscreens in mind; on desktop elements may look gigantic
|
||||
// So scale them down a bit
|
||||
const val scaleFactor = 0.75f
|
||||
|
||||
fun main() = application {
|
||||
Window(
|
||||
onCloseRequest = ::exitApplication,
|
||||
title = "Neon",
|
||||
) {
|
||||
App()
|
||||
val systemScale = System.getenv("GDK_SCALE")?.toFloatOrNull() ?: 1f
|
||||
val systemDpiScale = System.getenv("GDK_DPI_SCALE")?.toFloatOrNull() ?: 1f
|
||||
val density = Density(
|
||||
density = LocalDensity.current.density * systemScale * scaleFactor,
|
||||
fontScale = systemDpiScale
|
||||
)
|
||||
CompositionLocalProvider(LocalDensity provides density) {
|
||||
App()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue