Allow dragging of selected items in inventory

This commit is contained in:
2024-10-20 11:32:37 +01:00
parent 8b6f5529ff
commit f6e32ff6ef
7 changed files with 259 additions and 158 deletions
+29
View File
@@ -9,6 +9,8 @@ module Dodge.SelectionSections (
inverseSelSecYint,
posSelSecYint,
inverseSelNumPos,
inverseSelBoundaryUp,
inverseSelBoundaryDown,
) where
import Control.Monad
@@ -186,5 +188,32 @@ inverseSelNumPos ::
inverseSelNumPos cfig ldp sss (V2 x y) =
inverseSelSecYintXPosCheck cfig ldp x (posSelSecYint cfig ldp y) sss
inverseSelBoundaryUp ::
Configuration ->
ListDisplayParams ->
SelectionSections a ->
Point2 ->
Maybe (Int,Int)
inverseSelBoundaryUp cfig ldp sss (V2 _ y) = do
sel <- inverseSelSecYint (posSelSecYint cfig ldp y) sss
let mselup = inverseSelSecYint (posSelSecYint cfig ldp y - 1) sss
if Just sel == mselup
then return $ sel & _2 +~ 1
else return $ sel
inverseSelBoundaryDown ::
Configuration ->
ListDisplayParams ->
SelectionSections a ->
Point2 ->
Maybe (Int,Int)
inverseSelBoundaryDown cfig ldp sss (V2 _ y) = do
sel <- inverseSelSecYint (posSelSecYint cfig ldp y) sss
let mseldown = inverseSelSecYint (posSelSecYint cfig ldp y + 1) sss
if Just sel == mseldown
then return $ sel & _2 -~ 1
else return sel
--getIthPos :: Int -> IM.IntMap (SelectionItem a) -> Int
--getIthPos i sm = sum . fmap _siHeight . fst $ IM.split i sm