Skip to content

Commit

Permalink
add mouse position scale factor
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-sts committed Jun 8, 2024
1 parent f629fa5 commit 58f4ef8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ application {
"--add-opens", "javafx.graphics/javafx.scene.image=ALL-UNNAMED",
"--add-exports", "javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED",
"-Xms2g",
"-Xmx4g"
"-Xmx4g",
"-Dglass.win.uiScale=1.0",
"-Dsun.java2d.uiScale=1.0"
)
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/kotlin/solve/scene/view/SceneView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package solve.scene.view
import javafx.application.Platform
import javafx.beans.InvalidationListener
import javafx.scene.input.MouseEvent
import javafx.stage.Screen
import org.joml.Vector2i
import solve.rendering.canvas.SceneCanvas
import solve.rendering.engine.core.input.MouseButton
Expand All @@ -23,6 +24,7 @@ class SceneView : View() {
private var mouseScreenPoint = Vector2i()

private var wasMouseDragging = false
private var screen = Screen.getPrimary()

override val root = canvas.canvas

Expand All @@ -38,8 +40,12 @@ class SceneView : View() {
addBindings()
}

private fun extrudeEventMousePosition(event: MouseEvent) = Vector2i(event.x.toInt(), event.y.toInt())

private fun extrudeEventMousePosition(event: MouseEvent) : Vector2i {
return Vector2i(
(event.x * screen.outputScaleX).toInt(),
(event.y * screen.outputScaleY).toInt()
)
}
private fun addBindings() {
addSceneParamsBindings()
addSceneFramesBindings()
Expand Down

0 comments on commit 58f4ef8

Please sign in to comment.