don't deselect selection after brush widget update

This commit is contained in:
sheaf 2024-10-19 16:14:33 +02:00
parent 5adcb34de6
commit 3fe46fc029

View file

@ -1022,9 +1022,10 @@ instance HandleAction MouseClick where
then pure Don'tModifyDoc then pure Don'tModifyDoc
else do else do
-- Clicked on an unselected point: only select that point. -- Clicked on an unselected point: only select that point.
let newDoc = set ( field' @"documentMetadata" . field' @"selectedPoints" ) let newDoc =
( StrokePoints $ Map.singleton u ( Set.singleton i ) ) set ( field' @"documentMetadata" . field' @"selectedPoints" )
doc ( StrokePoints $ Map.singleton u ( Set.singleton i ) )
doc
pure ( UpdateDoc $ UpdateDocumentTo newDoc TrivialDiff ) pure ( UpdateDoc $ UpdateDocumentTo newDoc TrivialDiff )
-- Clicked on curve: preserve old selection. -- Clicked on curve: preserve old selection.
ClickedOnCurve {} -> ClickedOnCurve {} ->
@ -1148,7 +1149,7 @@ instance HandleAction MouseRelease where
toViewport = toViewportCoordinates zoom ( viewportWidth, viewportHeight ) viewportCenter toViewport = toViewportCoordinates zoom ( viewportWidth, viewportHeight ) viewportCenter
pos :: 2 pos :: 2
pos = toViewport ( 2 x y ) pos = toViewport ( 2 x y )
STM.writeTVar mousePosTVar ( Just pos ) STM.writeTVar mousePosTVar ( Just pos )
modifiers <- STM.readTVar modifiersTVar modifiers <- STM.readTVar modifiersTVar
mbHoldPos <- STM.swapTVar mouseHoldTVar Nothing mbHoldPos <- STM.swapTVar mouseHoldTVar Nothing
@ -1211,8 +1212,13 @@ instance HandleAction MouseRelease where
Just hold Just hold
| PathMode <- mode | PathMode <- mode
, DragMoveHold { holdStartPos = pos0, dragAction } <- hold , DragMoveHold { holdStartPos = pos0, dragAction } <- hold
, not $ inPointClickRange zoom pos0 pos ->
-> let if inPointClickRange zoom pos0 pos
then
let mbDoc' = fst <$> selectAt selMode pos doc
in pure ( UpdateDoc $ UpdateDocumentTo ( fromMaybe doc mbDoc' ) TrivialDiff )
else
let
alternateMode :: Bool alternateMode :: Bool
alternateMode = any ( \case { Alt _ -> True; _ -> False } ) modifiers alternateMode = any ( \case { Alt _ -> True; _ -> False } ) modifiers
in case dragUpdate pos0 pos dragAction alternateMode doc of in case dragUpdate pos0 pos dragAction alternateMode doc of
@ -1226,12 +1232,17 @@ instance HandleAction MouseRelease where
in pure $ UpdateDoc ( UpdateDocumentTo doc' diff ) in pure $ UpdateDoc ( UpdateDocumentTo doc' diff )
Nothing -> pure Don'tModifyDoc Nothing -> pure Don'tModifyDoc
| SelectionHold pos0 <- hold | SelectionHold pos0 <- hold
, not $ inPointClickRange zoom pos0 pos -> let mbDoc'
, let mbDoc' = fst <$> selectRectangle selMode pos0 pos doc | inPointClickRange zoom pos0 pos
-> pure ( UpdateDoc $ UpdateDocumentTo ( fromMaybe doc mbDoc' ) TrivialDiff ) = fst <$> selectAt selMode pos doc
_ -> | otherwise
= fst <$> selectRectangle selMode pos0 pos doc
in pure ( UpdateDoc $ UpdateDocumentTo ( fromMaybe doc mbDoc' ) TrivialDiff )
| otherwise
-> pure Don'tModifyDoc
Nothing -> do
let mbDoc' = fst <$> selectAt selMode pos doc let mbDoc' = fst <$> selectAt selMode pos doc
in pure ( UpdateDoc $ UpdateDocumentTo ( fromMaybe doc mbDoc' ) TrivialDiff ) pure ( UpdateDoc $ UpdateDocumentTo ( fromMaybe doc mbDoc' ) TrivialDiff )
Pen -> case mode of Pen -> case mode of
PathMode -> do PathMode -> do