From 86b4fb56cc0bdea93511928777b0e376f7523151 Mon Sep 17 00:00:00 2001 From: pdlla Date: Sat, 9 Dec 2023 18:07:52 -0800 Subject: [PATCH] -selecting multiple items in layers and click on on should select that one item, but right now it gose into rename mode --- TODO.txt | 5 +-- .../Flow/Controller/Manipulator/Layers.hs | 16 +++++++--- .../Flow/Controller/Manipulator/LayersSpec.hs | 31 +++++++++++++++++++ test/Potato/Flow/GoatTester.hs | 15 +++++++++ 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/TODO.txt b/TODO.txt index a5ed4598..11a7f298 100644 --- a/TODO.txt +++ b/TODO.txt @@ -279,9 +279,10 @@ DONE-handlers should return preview action -the trick is if you drag the last element in a folder to the spot below it, you need exception case to move it outside of the folder rather than as the next sibling to itself since that doesn't do anything DONE-currently not possible to drag below a folder if the folder is thet last sibling :( -not sure if there's a way around this :( - DONE-DO THIS you might want to consider doing the thing where dragging to the right side of a folder puts it underneath, otherwise it's always a sibling + DONE-DO THIS you might want to consider doing the thing where dragging to the right side of a folder puts it underneath, otherwise it's always a SiblingPosition + DONE-selecting multiple items in layers and click on on should select that one item, but right now it gose into rename mode -shift select in layers please ;__; - -selecting multiple items in layers and click on on should select that one item, but right now it gose into rename mode + -selecting multiple items and hitting new folder should put those items in folder maybe -hide stuff -moving an element into a hidden folder does not hide it right away (ignore this for release) diff --git a/src/Potato/Flow/Controller/Manipulator/Layers.hs b/src/Potato/Flow/Controller/Manipulator/Layers.hs index 6c392266..c9801191 100644 --- a/src/Potato/Flow/Controller/Manipulator/Layers.hs +++ b/src/Potato/Flow/Controller/Manipulator/Layers.hs @@ -254,6 +254,7 @@ instance PotatoHandler LayersHandler where } (MouseDragState_Up, LDS_Selecting leposdown) -> r where + -- TODO do proper shift selecting shift = elem KeyModifier_Shift _mouseDrag_modifiers sowl = _layerEntry_superOwl $ Seq.index lentries leposdown r = Just $ def { @@ -272,11 +273,16 @@ instance PotatoHandler LayersHandler where -- TODO great place for TZ.selectAll when you add selection capability into TZ zipper = TZ.fromText $ hasOwlItem_name downsowl - r = Just $ setHandlerOnly LayersRenameHandler { - _layersRenameHandler_original = resetLayersHandler lh - , _layersRenameHandler_renaming = downsowl - , _layersRenameHandler_index = lepos - , _layersRenameHandler_zipper = zipper + r = if Seq.length (unSuperOwlParliament selection) == 1 + then Just $ setHandlerOnly LayersRenameHandler { + _layersRenameHandler_original = resetLayersHandler lh + , _layersRenameHandler_renaming = downsowl + , _layersRenameHandler_index = lepos + , _layersRenameHandler_zipper = zipper + } + else Just $ def { + _potatoHandlerOutput_nextHandler = Just $ SomePotatoHandler (resetLayersHandler lh) + , _potatoHandlerOutput_action = HOA_Select False (SuperOwlParliament $ Seq.singleton downsowl) } diff --git a/test/Potato/Flow/Controller/Manipulator/LayersSpec.hs b/test/Potato/Flow/Controller/Manipulator/LayersSpec.hs index a8edd4cb..02992e6e 100644 --- a/test/Potato/Flow/Controller/Manipulator/LayersSpec.hs +++ b/test/Potato/Flow/Controller/Manipulator/LayersSpec.hs @@ -17,6 +17,7 @@ import Potato.Flow.Controller.Manipulator.TestHelpers import qualified Data.List as L import qualified Data.Sequence as Seq +import Control.Monad (forM_) someFolderName :: Text @@ -82,6 +83,35 @@ create_select_test = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do layerMouseDownUp (5,0) verifyFolderSelected someFolderName +shift_select_test :: Spec +shift_select_test = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do + + let xoff = 10 + + setMarker "draw several boxes" + forM_ [0..9] $ \_ -> drawCanvasBox (0, 0, 100, 100) + verifyOwlCount 10 + pressEscape + verifySelectionCount 0 + + setMarker "shift select some stuff" + forM_ [0..9] $ \n -> layerMouseDownUpWithModifier (xoff, n) KeyModifier_Shift + verifySelectionCount 10 + + setMarker "shift unselect stuff" + layerMouseDownUpWithModifier (xoff, 5) KeyModifier_Shift + verifySelectionCount 9 + layerMouseDownUpWithModifier (xoff, 8) KeyModifier_Shift + verifySelectionCount 8 + + setMarker "regular select one already selected element" + layerMouseDownUp (xoff, 2) + verifySelectionCount 1 + + setMarker "deselect everything" + pressEscape + verifySelectionCount 0 + rename_focus_clickCanvas_test :: Spec rename_focus_clickCanvas_test = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do @@ -418,6 +448,7 @@ spec :: Spec spec = do describe "Layers" $ do describe "create_select_test" $ create_select_test + describe "shift_select_test" $ shift_select_test describe "rename_focus_clickCanvas_test" $ rename_focus_clickCanvas_test describe "rename_focus_setFocus_test canvas" $ rename_focus_setFocus_test GoatFocusedArea_Canvas describe "rename_focus_setFocus_test other" $ rename_focus_setFocus_test GoatFocusedArea_Other diff --git a/test/Potato/Flow/GoatTester.hs b/test/Potato/Flow/GoatTester.hs index 5dd7f6bd..4dd3b3d1 100644 --- a/test/Potato/Flow/GoatTester.hs +++ b/test/Potato/Flow/GoatTester.hs @@ -238,6 +238,19 @@ layerMouseDownUp (x,y) = do layerMouseDown (x,y) layerMouseUp (x,y) + +layerMouseDownWithModifier :: (Monad m) => (Int, Int) -> KeyModifier -> GoatTesterT m () +layerMouseDownWithModifier (x,y) modifier = mouse False False [modifier] MouseButton_Left (V2 x y) + +layerMouseUpWithModifier :: (Monad m) => (Int, Int) -> KeyModifier -> GoatTesterT m () +layerMouseUpWithModifier (x,y) modifier = mouse False True [modifier] MouseButton_Left (V2 x y) + +layerMouseDownUpWithModifier :: (Monad m) => (Int, Int) -> KeyModifier -> GoatTesterT m () +layerMouseDownUpWithModifier (x,y) modifier = do + layerMouseDownWithModifier (x,y) modifier + layerMouseUpWithModifier (x,y) modifier + + data LayerMouseOp = LMO_Collapse | LMO_Hide | LMO_Lock | LMO_Normal | LMO_DropInFolder Int -- desired position relative to depth deriving (Show, Eq) @@ -271,6 +284,8 @@ layerMouseDownUpRel op y depth = do layerMouseUpRel op y depth + + pressKeyboardKey :: (Monad m) => KeyboardKey -> GoatTesterT m () pressKeyboardKey k = runEndo $ endoGoatCmdKeyboard (KeyboardData k [])