Skip to content

Commit

Permalink
meowmeowmeow
Browse files Browse the repository at this point in the history
  • Loading branch information
minimapletinytools committed Dec 25, 2023
1 parent ed69641 commit 63d6871
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
11 changes: 5 additions & 6 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ DONE-handlers should return preview action


::HIGH PRIORITY::
DONE-BUG asserting `r = fmap (\(i, sall) -> (internal_getSAutoLineLabelPosition (larlist `debugBangBang` _sAutoLineLabel_index sall) sal sall, i, sall)) sortedlls`
-repro is to make a line label with midpoint, add text between midpoint and thene delete the midpoint in either direction
DONE/IGNORE?-line labels still cropping on right side
-LHRESS_ChildSelected graphic broken during drag and just in general
-make a deep chain of folders, then in one of the folders have several children, selecting that folder will cause the folder just above it not to be LHRESS_ChildSelected
-layers improvements
Expand All @@ -295,8 +292,6 @@ DONE/IGNORE?-line labels still cropping on right side
-if both target and source of line is moved, then move midpoints as well
-fix (search comment) -- THE REASON YOU DID THIS IS TO PREVENT FULLY ATTACHED LINES FROM BEING MOVED
-line anchor handlers should not pop up until you start dragging (except in creation mode where they should show from the get go)
IGNORE-add render handler name property so you know what the render handler is from its renderhandleroutput
-add a visual anchor for the box label so you know you can add one easily

::MID PRIORITY
-file stuff
Expand Down Expand Up @@ -406,7 +401,11 @@ IGNORE-add render handler name property so you know what the render handler is f




DONE-BUG asserting `r = fmap (\(i, sall) -> (internal_getSAutoLineLabelPosition (larlist `debugBangBang` _sAutoLineLabel_index sall) sal sall, i, sall)) sortedlls`
-repro is to make a line label with midpoint, add text between midpoint and thene delete the midpoint in either direction
DONE/IGNORE?-line labels still cropping on right side
IGNORE-add render handler name property so you know what the render handler is from its renderhandleroutput
IGNORE-add a visual anchor for the box label so you know you can add one easily
DONE-add upper bounds to all packages
DONE-BUG `invalid = error "toggling of LHS_XXX_InheritTrue elements disallowed"`
-repro is make a chain of folders, select one in the middle and lock
Expand Down
2 changes: 1 addition & 1 deletion src/Potato/Flow/Controller/Handler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ instance Default LayersViewHandlerRenderOutput where
_layersViewHandlerRenderOutput_entries = Seq.empty
}

data RenderHandleColor = RHC_Default | RHC_Attachment | RHC_AttachmentHighlight deriving (Show, Eq)
data RenderHandleColor = RHC_Default | RHC_Cursor | RHC_Attachment | RHC_AttachmentHighlight deriving (Show, Eq)

-- TODO come up with better name
data RenderHandle = RenderHandle {
Expand Down
23 changes: 23 additions & 0 deletions src/Potato/Flow/Controller/Manipulator/Box.hs
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,34 @@ instance PotatoHandler BoxHandler where

pRenderHandler BoxHandler {..} PotatoHandlerInput {..} = r where
handlePoints = fmap _mouseManipulator_box . filter (\mm -> _mouseManipulator_type mm == MouseManipulatorType_Corner) $ toMouseManipulators _potatoHandlerInput_pFState _potatoHandlerInput_canvasSelection

{--
-- kind of a hack to put this here, since BoxHandler is generic, but that's how it has to be for now since BoxHandler is also kind of not generic
-- I guess in the future you might have more specific handlers for each type of owl in which case you can do the thing where the specific handler also has a ref to BoxHandler and you render both (you did this with the text handler already)
-- TODO and this is an issue becaues you don't want to show the box label handler when you are editing the box label
mBoxLabelHandler = case selectionOnlySBox _potatoHandlerInput_canvasSelection of
Nothing -> Nothing
Just sbox -> if sBoxType_hasBorder (_sBox_boxType sbox)
then if w > 1
then Just $ RenderHandle {
_renderHandle_box = LBox (V2 (x+1) y) (V2 1 1)
, _renderHandle_char = Just 'I'
, _renderHandle_color = RHC_Cursor
}
else Nothing
else Nothing
where (LBox (V2 x y) (V2 w h)) = _sBox_box sbox
mcons :: Maybe a -> [a] -> [a]
mcons ma as = maybe as (:as) ma
--}

-- TODO highlight active manipulator if active
--if (_boxHandler_active)
r = if not _boxHandler_active && boxCreationType_isCreation _boxHandler_creation
-- don't render anything if we are about to create a box
then emptyHandlerRenderOutput
--else HandlerRenderOutput (mcons mBoxLabelHandler $ fmap defaultRenderHandle handlePoints)
else HandlerRenderOutput (fmap defaultRenderHandle handlePoints)

pIsHandlerActive bh = if _boxHandler_active bh then HAS_Active_Mouse else HAS_Inactive
Expand Down
18 changes: 18 additions & 0 deletions test/Potato/Flow/Controller/Manipulator/BoxSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ verifyMostRecentlyCreatedBoxHasText mt = verifyStateObjectHasProperty "verifyMos
then Nothing
else Just $ "got text " <> show (_sBox_text sbox) <> " expected " <> t




initSimpleBox :: GoatTester ()
initSimpleBox = drawCanvasBox (0, 0, 100, 100)

Expand Down Expand Up @@ -118,6 +121,21 @@ boxtext_test = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do
verifyMostRecentlyCreatedBoxHasText (Just "meow meow meow meow")


manipulator_basic_test :: Spec
manipulator_basic_test = hSpecGoatTesterWithOwlPFState emptyOwlPFState $ do

setMarker "draw a box"
drawCanvasBox (0, 0, 100, 100)

handlers <- fmap _handlerRenderOutput_temp getHandlerRenderOutput

verifyBool "has 5 handlers" (length handlers == 5)
verifyBool "has handler at upper left corner" (any (\(RenderHandle (LBox (V2 x y) _) _ _) -> x == (-1) && y == (-1)) handlers)
--verifyBool "has handler on label" (any (\(HandlerRenderOutput (LBox (V2 x y) _) _ _) -> x == 1 && y == 0) handlers)
verifyBool "has handler on the box area" (any (\(RenderHandle (LBox (V2 x y) (V2 w h)) _ _) -> x == 1 && y == 1 && w == 98 && h == 98) handlers)



spec :: Spec
spec = do
describe "Box" $ do
Expand Down
5 changes: 5 additions & 0 deletions test/Potato/Flow/GoatTester.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ getLayersState = GoatTesterT $ do
gts <- get
return $ _goatState_layersState $ _goatTesterState_goatState gts

getHandlerRenderOutput :: (Monad m) => GoatTesterT m HandlerRenderOutput
getHandlerRenderOutput = GoatTesterT $ do
gs <- fmap _goatTesterState_goatState get
return $ pRenderHandler (_goatState_handler gs) (potatoHandlerInputFromGoatState gs)

-- operation helpers

setTool :: (Monad m) => Tool -> GoatTesterT m ()
Expand Down

0 comments on commit 63d6871

Please sign in to comment.