Work on boundaries for dragging windows

This commit is contained in:
2026-04-06 00:52:09 +01:00
parent ed28af8d11
commit 1f52c4b588
9 changed files with 17 additions and 20 deletions
+4 -9
View File
@@ -132,15 +132,10 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
setPixelOffsetBounded :: Config -> Point2 -> LDParams -> LDParams
setPixelOffsetBounded cfig (V2 x y) ldp = ldp & ldpPos . spPixelOff .~ V2 x' y'
where
-- (V2 xmin ymax, V2 xmax ymin) = ldpRect cfig ldp
h = fromIntegral $ cfig ^. windowX
w = fromIntegral $ cfig ^. windowY
V2 ax ay = -V2 w h + ldp ^. ldpPos . spScreenOff * V2 w h
x' = min w $ max 1 x
y' = y
boundPixelOffset :: Config -> Point2 -> Point2 -> Point2 -> Point2
boundPixelOffset cfig nw se p = p
h = fromIntegral $ cfig ^. windowY
w = fromIntegral $ cfig ^. windowX
x' = min (w - (1+10*ldp ^?! ldpSize . _Just . _x . to fromIntegral)) $ max 1 x
y' = max (1+20*(ldp^.ldpVerticalGap + ldp^?!ldpSize._Just._y.to fromIntegral)-h) y
--leftHeldPosShift :: World -> Point2
--leftHeldPosShift w = fromMaybe 0 $ do
+1 -1
View File
@@ -90,7 +90,7 @@ ldpSelection cfig ldp (V2 _ y)
ygap = ldp ^. ldpVerticalGap
yoff = ygap + 20 * ldp ^. ldpScale
top :: Float
top = fromIntegral winy * (ldp ^. ldpPos . spScreenOff . _y) + ldp ^. ldpPos . spPixelOff . _y
top = fromIntegral winy * (ldp ^. ldpPos . spScreenOff . _y - 0.5) + ldp ^. ldpPos . spPixelOff . _y
yupper = floor $ (top - (y + ygap)) / yoff
ylower = ceiling ((top - y) / yoff) - 1