Allow drag selecting outside of the selection section
Does not yet work outside of any selection section. Need to think about what widths are acceptable to allow for selection.
This commit is contained in:
@@ -10,6 +10,7 @@ module Dodge.SelectionSections (
|
||||
inverseSelNumPos,
|
||||
) where
|
||||
|
||||
import Dodge.Data.CardinalPoint
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Applicative
|
||||
import qualified Control.Foldl as L
|
||||
@@ -198,16 +199,18 @@ selSecYint i j sss = do
|
||||
where
|
||||
secpos = sum . fmap _ssShownLength . fst $ IM.split i sss
|
||||
|
||||
inverseSelSecYint :: Int -> IM.IntMap (SelectionSection a) -> Maybe (Int, Int)
|
||||
inverseSelSecYint yint sss = do
|
||||
((i, ss), othersss) <- IM.minViewWithKey sss
|
||||
let l = _ssShownLength ss
|
||||
if l <= yint
|
||||
then inverseSelSecYint (yint - l) othersss
|
||||
else do
|
||||
let ls = L.postscan (L.premap _siHeight L.sum) (_ssItems ss)
|
||||
(j,_) <- L.fold (L.find (\(_,x) -> x - _ssOffset ss > yint)) $ IM.toList ls
|
||||
return (i, j)
|
||||
inverseSelSecYint :: Int -> IM.IntMap (SelectionSection a) -> XInfinity (Int, Int)
|
||||
inverseSelSecYint yint sss
|
||||
| yint < 0 = NegInf
|
||||
| otherwise = fromMaybe PosInf $ do
|
||||
((i, ss), othersss) <- IM.minViewWithKey sss
|
||||
let l = _ssShownLength ss
|
||||
if l <= yint
|
||||
then return $ inverseSelSecYint (yint - l) othersss
|
||||
else do
|
||||
let ls = L.postscan (L.premap _siHeight L.sum) (_ssItems ss)
|
||||
(j,_) <- L.fold (L.find (\(_,x) -> x - _ssOffset ss > yint)) $ IM.toList ls
|
||||
return $ NonInf (i, j)
|
||||
|
||||
inverseSelSecYintXPosCheck ::
|
||||
Configuration ->
|
||||
@@ -216,8 +219,8 @@ inverseSelSecYintXPosCheck ::
|
||||
Int ->
|
||||
IM.IntMap (SelectionSection a) ->
|
||||
Maybe (Int,Int)
|
||||
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
||||
(i,j) <- inverseSelSecYint yint sss
|
||||
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
||||
(i,j) <- inverseSelSecYint yint sss ^? nonInf
|
||||
let V2 x0 _ = screenPosAbs cfig (ldp ^. ldpPos)
|
||||
sindent <- sss ^? ix i . ssIndent
|
||||
itindent <- sss ^? ix i . ssItems . ix j . siOffX
|
||||
|
||||
Reference in New Issue
Block a user