Skip to content

Commit

Permalink
add a scale factor to the frames identity scale
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-sts committed Jun 8, 2024
1 parent 58f4ef8 commit de20ce3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.github.palexdev.materialfx.controls.MFXContextMenu
import javafx.scene.Node
import javafx.scene.input.Clipboard
import javafx.scene.input.ClipboardContent
import javafx.stage.Screen
import org.joml.Vector2f
import org.joml.Vector2i
import solve.parsers.planes.ImagePlanesParser
Expand Down Expand Up @@ -371,7 +372,7 @@ class SceneCanvas : OpenGLCanvas() {
rowsNumber * framesSize.y + (rowsNumber - 1) * Renderer.getSpacingWidth(framesSize)
)
val framesSelectionScreenSize =
framesSelectionSize * window.camera.zoom / IdentityFramesSizeScale / window.camera.scaledZoom
framesSelectionSize * window.camera.zoom / scaledIdentityFramesSizeScale / window.camera.scaledZoom

rightLowerCornerCameraPosition = framesSelectionScreenSize - leftUpperCornerCameraPosition

Expand Down Expand Up @@ -450,7 +451,7 @@ class SceneCanvas : OpenGLCanvas() {
)
}
val getScreenScale = {
window.camera.zoom.toDouble() / IdentityFramesSizeScale
window.camera.zoom.toDouble() / scaledIdentityFramesSizeScale
}
val associationAdorner = AssociationAdorner(
framesSize.x.toDouble(),
Expand Down Expand Up @@ -484,6 +485,9 @@ class SceneCanvas : OpenGLCanvas() {
companion object {
const val IdentityFramesSizeScale = 1.605f

val scaledIdentityFramesSizeScale: Float
get() = IdentityFramesSizeScale * Screen.getPrimary().outputScaleX.toFloat()

private val landmarkInteractionMouseButton = MouseButton.Left
private val contextMenuMouseButton = MouseButton.Right

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/solve/scene/controller/SceneController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class SceneController : Controller() {
max(
installedMinScale,
sceneWidthProperty.value / ((scene.frameSize.width + SceneView.framesMargin) * columnsNumber) *
SceneCanvas.IdentityFramesSizeScale
SceneCanvas.scaledIdentityFramesSizeScale
),
DefaultMaxScale
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/solve/scene/view/SceneView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class SceneView : View() {
private var mouseScreenPoint = Vector2i()

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

override val root = canvas.canvas

Expand All @@ -41,6 +40,7 @@ class SceneView : View() {
}

private fun extrudeEventMousePosition(event: MouseEvent) : Vector2i {
val screen = Screen.getPrimary()
return Vector2i(
(event.x * screen.outputScaleX).toInt(),
(event.y * screen.outputScaleY).toInt()
Expand Down

0 comments on commit de20ce3

Please sign in to comment.