Skip to content

Commit

Permalink
-selecting multiple items in layers and click on on should select tha…
Browse files Browse the repository at this point in the history
…t one item, but right now it gose into rename mode
  • Loading branch information
minimapletinytools committed Dec 10, 2023
1 parent b7727ac commit 86b4fb5
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 7 deletions.
5 changes: 3 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions src/Potato/Flow/Controller/Manipulator/Layers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}


Expand Down
31 changes: 31 additions & 0 deletions test/Potato/Flow/Controller/Manipulator/LayersSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions test/Potato/Flow/GoatTester.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 [])

Expand Down

0 comments on commit 86b4fb5

Please sign in to comment.