{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE RecursiveDo #-}
module Potato.Flow.Controller.Goat (
GoatFocusedArea(..)
, goatState_hasUnsavedChanges
, makeGoatState
, goatState_pFState
, goatState_selectedTool
, GoatState(..)
, endoGoatCmdSetDefaultParams
, endoGoatCmdMarkSaved
, endoGoatCmdSetTool
, endoGoatCmdSetDebugLabel
, endoGoatCmdSetCanvasRegionDim
, endoGoatCmdWSEvent
, endoGoatCmdNewFolder
, endoGoatCmdLoad
, endoGoatCmdSetFocusedArea
, endoGoatCmdMouse
, endoGoatCmdKeyboard
, potatoHandlerInputFromGoatState
) where
import Relude
import Potato.Data.Text.Unicode
import Potato.Flow.BroadPhase
import Potato.Flow.Configuration
import Potato.Flow.Controller.Handler
import Potato.Flow.Controller.Input
import Potato.Flow.Controller.Manipulator.Box
import Potato.Flow.Controller.Manipulator.Common
import Potato.Flow.Controller.Manipulator.Layers
import Potato.Flow.Controller.Manipulator.Line
import Potato.Flow.Controller.Manipulator.Pan
import Potato.Flow.Controller.Manipulator.Select
import Potato.Flow.Controller.OwlLayers
import Potato.Flow.Controller.Types
import Potato.Flow.Llama
import Potato.Flow.Math
import Potato.Flow.Owl
import Potato.Flow.OwlItem
import Potato.Flow.OwlState
import Potato.Flow.OwlWorkspace
import Potato.Flow.Render
import Potato.Flow.SEltMethods
import Potato.Flow.SElts
import Potato.Flow.Types
import Potato.Flow.Preview
import Potato.Flow.Methods.LlamaWorks
import Control.Exception (assert)
import Data.Default
import qualified Data.IntMap as IM
import qualified Data.IntSet as IS
import Data.Maybe
import qualified Data.Sequence as Seq
import qualified Data.Text as T
catMaybesSeq :: Seq (Maybe a) -> Seq a
catMaybesSeq :: forall a. Seq (Maybe a) -> Seq a
catMaybesSeq = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. HasCallStack => Maybe a -> a
fromJust forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> Seq a -> Seq a
Seq.filter forall a. Maybe a -> Bool
isJust
data GoatFocusedArea =
GoatFocusedArea_Layers
| GoatFocusedArea_Canvas
| GoatFocusedArea_Other
| GoatFocusedArea_None
deriving (GoatFocusedArea -> GoatFocusedArea -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GoatFocusedArea -> GoatFocusedArea -> Bool
$c/= :: GoatFocusedArea -> GoatFocusedArea -> Bool
== :: GoatFocusedArea -> GoatFocusedArea -> Bool
$c== :: GoatFocusedArea -> GoatFocusedArea -> Bool
Eq, Int -> GoatFocusedArea -> ShowS
[GoatFocusedArea] -> ShowS
GoatFocusedArea -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GoatFocusedArea] -> ShowS
$cshowList :: [GoatFocusedArea] -> ShowS
show :: GoatFocusedArea -> String
$cshow :: GoatFocusedArea -> String
showsPrec :: Int -> GoatFocusedArea -> ShowS
$cshowsPrec :: Int -> GoatFocusedArea -> ShowS
Show)
data GoatState = GoatState {
GoatState -> OwlPFWorkspace
_goatState_workspace :: OwlPFWorkspace
, GoatState -> XY
_goatState_pan :: XY
, GoatState -> Selection
_goatState_selection :: Selection
, GoatState -> CanvasSelection
_goatState_canvasSelection :: CanvasSelection
, GoatState -> BroadPhaseState
_goatState_broadPhaseState :: BroadPhaseState
, :: LayersState
, GoatState -> RenderedCanvasRegion
_goatState_renderedCanvas :: RenderedCanvasRegion
, GoatState -> RenderedCanvasRegion
_goatState_renderedSelection :: RenderedCanvasRegion
, GoatState -> SomePotatoHandler
_goatState_handler :: SomePotatoHandler
, GoatState -> SomePotatoHandler
_goatState_layersHandler :: SomePotatoHandler
, GoatState -> AttachmentMap
_goatState_attachmentMap :: AttachmentMap
, GoatState -> RenderCache
_goatState_renderCache :: RenderCache
, GoatState -> PotatoConfiguration
_goatState_configuration :: PotatoConfiguration
, GoatState -> PotatoDefaultParameters
_goatState_potatoDefaultParameters :: PotatoDefaultParameters
, GoatState -> MouseDrag
_goatState_mouseDrag :: MouseDrag
, GoatState -> XY
_goatState_screenRegion :: XY
, GoatState -> Maybe SEltTree
_goatState_clipboard :: Maybe SEltTree
, GoatState -> GoatFocusedArea
_goatState_focusedArea :: GoatFocusedArea
, GoatState -> Text
_goatState_unbrokenInput :: Text
, GoatState -> Text
_goatState_debugLabel :: Text
} deriving (Int -> GoatState -> ShowS
[GoatState] -> ShowS
GoatState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GoatState] -> ShowS
$cshowList :: [GoatState] -> ShowS
show :: GoatState -> String
$cshow :: GoatState -> String
showsPrec :: Int -> GoatState -> ShowS
$cshowsPrec :: Int -> GoatState -> ShowS
Show)
makeGoatState :: XY -> (OwlPFState, ControllerMeta) -> GoatState
makeGoatState :: XY -> (OwlPFState, ControllerMeta) -> GoatState
makeGoatState (V2 Int
screenx Int
screeny) (OwlPFState
initialstate, ControllerMeta
controllermeta) = GoatState
goat where
initialowlpfstate :: OwlPFState
initialowlpfstate = OwlPFState
initialstate
initialAsSuperOwlChanges :: IntMap (Maybe SuperOwl)
initialAsSuperOwlChanges = forall a b. (Int -> a -> b) -> IntMap a -> IntMap b
IM.mapWithKey (\Int
rid (OwlItemMeta
oem, OwlItem
oe) -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Int -> OwlItemMeta -> OwlItem -> SuperOwl
SuperOwl Int
rid OwlItemMeta
oem OwlItem
oe) forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlTree -> IntMap (OwlItemMeta, OwlItem)
_owlTree_mapping forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlPFState -> OwlTree
_owlPFState_owlTree forall a b. (a -> b) -> a -> b
$ OwlPFState
initialstate
(NeedsUpdateSet
_, BroadPhaseState
initialbp) = forall a.
HasOwlTree a =>
a
-> IntMap (Maybe SuperOwl)
-> BPTree
-> (NeedsUpdateSet, BroadPhaseState)
update_bPTree OwlPFState
initialowlpfstate IntMap (Maybe SuperOwl)
initialAsSuperOwlChanges BPTree
emptyBPTree
initiallayersstate :: LayersState
initiallayersstate = OwlPFState -> LayerMetaMap -> LayersState
makeLayersStateFromOwlPFState OwlPFState
initialowlpfstate (ControllerMeta -> LayerMetaMap
_controllerMeta_layers ControllerMeta
controllermeta)
initialCanvasBox :: LBox
initialCanvasBox = SCanvas -> LBox
_sCanvas_box forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlPFState -> SCanvas
_owlPFState_canvas forall a b. (a -> b) -> a -> b
$ OwlPFState
initialowlpfstate
initialselts :: [OwlSubItem]
initialselts = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(OwlItemMeta
_, OwlItem
oelt) -> OwlItem -> OwlSubItem
_owlItem_subItem OwlItem
oelt) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlTree -> IntMap (OwlItemMeta, OwlItem)
_owlTree_mapping forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlPFState -> OwlTree
_owlPFState_owlTree forall a b. (a -> b) -> a -> b
$ OwlPFState
initialowlpfstate
initialemptyrcr :: RenderedCanvasRegion
initialemptyrcr = LBox -> RenderedCanvasRegion
emptyRenderedCanvasRegion LBox
initialCanvasBox
initialrendercontext :: RenderContext
initialrendercontext = RenderContext {
_renderContext_owlTree :: OwlTree
_renderContext_owlTree = forall o. HasOwlTree o => o -> OwlTree
hasOwlTree_owlTree OwlPFState
initialowlpfstate
, _renderContext_layerMetaMap :: LayerMetaMap
_renderContext_layerMetaMap = LayersState -> LayerMetaMap
_layersState_meta LayersState
initiallayersstate
, _renderContext_broadPhase :: BroadPhaseState
_renderContext_broadPhase = BroadPhaseState
initialbp
, _renderContext_renderedCanvasRegion :: RenderedCanvasRegion
_renderContext_renderedCanvasRegion = RenderedCanvasRegion
initialemptyrcr
, _renderContext_cache :: RenderCache
_renderContext_cache = RenderCache
emptyRenderCache
}
initialrc :: RenderedCanvasRegion
initialrc = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion forall a b. (a -> b) -> a -> b
$ LBox -> [OwlSubItem] -> RenderContext -> RenderContext
render LBox
initialCanvasBox [OwlSubItem]
initialselts RenderContext
initialrendercontext
goat :: GoatState
goat = GoatState {
_goatState_workspace :: OwlPFWorkspace
_goatState_workspace = forall a b. (a, b) -> a
fst forall a b. (a -> b) -> a -> b
$ OwlPFState
-> OwlPFWorkspace -> (OwlPFWorkspace, IntMap (Maybe SuperOwl))
loadOwlPFStateIntoWorkspace (OwlPFState
initialstate) OwlPFWorkspace
emptyWorkspace
, _goatState_pan :: XY
_goatState_pan = ControllerMeta -> XY
_controllerMeta_pan ControllerMeta
controllermeta
, _goatState_mouseDrag :: MouseDrag
_goatState_mouseDrag = forall a. Default a => a
def
, _goatState_handler :: SomePotatoHandler
_goatState_handler = forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler EmptyHandler
EmptyHandler
, _goatState_layersHandler :: SomePotatoHandler
_goatState_layersHandler = forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler (forall a. Default a => a
def :: LayersHandler)
, _goatState_configuration :: PotatoConfiguration
_goatState_configuration = forall a. Default a => a
def
, _goatState_potatoDefaultParameters :: PotatoDefaultParameters
_goatState_potatoDefaultParameters = forall a. Default a => a
def
, _goatState_attachmentMap :: AttachmentMap
_goatState_attachmentMap = OwlTree -> AttachmentMap
owlTree_makeAttachmentMap (OwlPFState -> OwlTree
_owlPFState_owlTree OwlPFState
initialstate)
, _goatState_debugLabel :: Text
_goatState_debugLabel = Text
""
, _goatState_selection :: Selection
_goatState_selection = forall a. IsParliament a => a
isParliament_empty
, _goatState_canvasSelection :: CanvasSelection
_goatState_canvasSelection = Seq SuperOwl -> CanvasSelection
CanvasSelection forall a. Seq a
Seq.empty
, _goatState_broadPhaseState :: BroadPhaseState
_goatState_broadPhaseState = BroadPhaseState
initialbp
, _goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_renderedCanvas = RenderedCanvasRegion
initialrc
, _goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedSelection = RenderedCanvasRegion
initialemptyrcr
, _goatState_layersState :: LayersState
_goatState_layersState = LayersState
initiallayersstate
, _goatState_renderCache :: RenderCache
_goatState_renderCache = RenderCache
emptyRenderCache
, _goatState_clipboard :: Maybe SEltTree
_goatState_clipboard = forall a. Maybe a
Nothing
, _goatState_focusedArea :: GoatFocusedArea
_goatState_focusedArea = GoatFocusedArea
GoatFocusedArea_None
, _goatState_unbrokenInput :: Text
_goatState_unbrokenInput = Text
""
, _goatState_screenRegion :: XY
_goatState_screenRegion = forall a. a -> a -> V2 a
V2 Int
screenx Int
screeny forall a. Num a => a -> a -> a
- (ControllerMeta -> XY
_controllerMeta_pan ControllerMeta
controllermeta)
}
goatState_pFState :: GoatState -> OwlPFState
goatState_pFState :: GoatState -> OwlPFState
goatState_pFState = OwlPFWorkspace -> OwlPFState
_owlPFWorkspace_owlPFState forall b c a. (b -> c) -> (a -> b) -> a -> c
. GoatState -> OwlPFWorkspace
_goatState_workspace
goatState_owlTree :: GoatState -> OwlTree
goatState_owlTree :: GoatState -> OwlTree
goatState_owlTree = OwlPFState -> OwlTree
_owlPFState_owlTree forall b c a. (b -> c) -> (a -> b) -> a -> c
. GoatState -> OwlPFState
goatState_pFState
goatState_hasUnsavedChanges :: GoatState -> Bool
goatState_hasUnsavedChanges :: GoatState -> Bool
goatState_hasUnsavedChanges = LlamaStack -> Bool
llamaStack_hasUnsavedChanges forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlPFWorkspace -> LlamaStack
_owlPFWorkspace_llamaStack forall b c a. (b -> c) -> (a -> b) -> a -> c
. GoatState -> OwlPFWorkspace
_goatState_workspace
goatState_selectedTool :: GoatState -> Tool
goatState_selectedTool :: GoatState -> Tool
goatState_selectedTool = forall a. a -> Maybe a -> a
fromMaybe Tool
Tool_Select forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall h. PotatoHandler h => h -> Maybe Tool
pHandlerTool forall b c a. (b -> c) -> (a -> b) -> a -> c
. GoatState -> SomePotatoHandler
_goatState_handler
goatState_hasLocalPreview :: GoatState -> Bool
goatState_hasLocalPreview :: GoatState -> Bool
goatState_hasLocalPreview = OwlPFWorkspace -> Bool
owlPFWorkspace_hasLocalPreview forall b c a. (b -> c) -> (a -> b) -> a -> c
. GoatState -> OwlPFWorkspace
_goatState_workspace
makeHandlerFromNewTool :: GoatState -> Tool -> SomePotatoHandler
makeHandlerFromNewTool :: GoatState -> Tool -> SomePotatoHandler
makeHandlerFromNewTool GoatState{Maybe SEltTree
Text
AttachmentMap
XY
PotatoConfiguration
CanvasSelection
Selection
RenderCache
MouseDrag
OwlPFWorkspace
PotatoDefaultParameters
LayersState
BroadPhaseState
RenderedCanvasRegion
SomePotatoHandler
GoatFocusedArea
_goatState_debugLabel :: Text
_goatState_unbrokenInput :: Text
_goatState_focusedArea :: GoatFocusedArea
_goatState_clipboard :: Maybe SEltTree
_goatState_screenRegion :: XY
_goatState_mouseDrag :: MouseDrag
_goatState_potatoDefaultParameters :: PotatoDefaultParameters
_goatState_configuration :: PotatoConfiguration
_goatState_renderCache :: RenderCache
_goatState_attachmentMap :: AttachmentMap
_goatState_layersHandler :: SomePotatoHandler
_goatState_handler :: SomePotatoHandler
_goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_layersState :: LayersState
_goatState_broadPhaseState :: BroadPhaseState
_goatState_canvasSelection :: CanvasSelection
_goatState_selection :: Selection
_goatState_pan :: XY
_goatState_workspace :: OwlPFWorkspace
_goatState_debugLabel :: GoatState -> Text
_goatState_unbrokenInput :: GoatState -> Text
_goatState_focusedArea :: GoatState -> GoatFocusedArea
_goatState_clipboard :: GoatState -> Maybe SEltTree
_goatState_screenRegion :: GoatState -> XY
_goatState_mouseDrag :: GoatState -> MouseDrag
_goatState_potatoDefaultParameters :: GoatState -> PotatoDefaultParameters
_goatState_configuration :: GoatState -> PotatoConfiguration
_goatState_renderCache :: GoatState -> RenderCache
_goatState_attachmentMap :: GoatState -> AttachmentMap
_goatState_layersHandler :: GoatState -> SomePotatoHandler
_goatState_handler :: GoatState -> SomePotatoHandler
_goatState_renderedSelection :: GoatState -> RenderedCanvasRegion
_goatState_renderedCanvas :: GoatState -> RenderedCanvasRegion
_goatState_layersState :: GoatState -> LayersState
_goatState_broadPhaseState :: GoatState -> BroadPhaseState
_goatState_canvasSelection :: GoatState -> CanvasSelection
_goatState_selection :: GoatState -> Selection
_goatState_pan :: GoatState -> XY
_goatState_workspace :: GoatState -> OwlPFWorkspace
..} = \case
Tool
Tool_Box -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ forall a. Default a => a
def { _boxHandler_creation :: BoxCreationType
_boxHandler_creation = BoxCreationType
BoxCreationType_Box }
Tool
Tool_Line -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ forall a. Default a => a
def { _autoLineHandler_isCreation :: Bool
_autoLineHandler_isCreation = Bool
True }
Tool
Tool_Select -> CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
_goatState_canvasSelection
Tool
Tool_Text -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ forall a. Default a => a
def { _boxHandler_creation :: BoxCreationType
_boxHandler_creation = BoxCreationType
BoxCreationType_Text }
Tool
Tool_TextArea -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ forall a. Default a => a
def { _boxHandler_creation :: BoxCreationType
_boxHandler_creation = BoxCreationType
BoxCreationType_TextArea }
Tool
Tool_Pan -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ (forall a. Default a => a
def :: PanHandler)
makeHandlerFromSelection :: CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection :: CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
selection = case CanvasSelection -> SelectionManipulatorType
computeSelectionType CanvasSelection
selection of
SelectionManipulatorType
SMTBox -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ (forall a. Default a => a
def :: BoxHandler)
SelectionManipulatorType
SMTBoxText -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ (forall a. Default a => a
def :: BoxHandler)
SelectionManipulatorType
SMTLine -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ (forall a. Default a => a
def :: AutoLineHandler)
SelectionManipulatorType
SMTTextArea -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ (forall a. Default a => a
def :: BoxHandler)
SelectionManipulatorType
SMTBoundingBox -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler forall a b. (a -> b) -> a -> b
$ (forall a. Default a => a
def :: BoxHandler)
SelectionManipulatorType
SMTNone -> forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler EmptyHandler
EmptyHandler
maybeUpdateHandlerFromSelection :: SomePotatoHandler -> CanvasSelection -> SomePotatoHandler
maybeUpdateHandlerFromSelection :: SomePotatoHandler -> CanvasSelection -> SomePotatoHandler
maybeUpdateHandlerFromSelection SomePotatoHandler
sph CanvasSelection
selection = case SomePotatoHandler
sph of
SomePotatoHandler h
h -> if HandlerActiveState -> Bool
handlerActiveState_isActive forall a b. (a -> b) -> a -> b
$ forall h. PotatoHandler h => h -> HandlerActiveState
pIsHandlerActive h
h
then SomePotatoHandler
sph
else CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
selection
makeClipboard :: GoatState -> Maybe SEltTree
makeClipboard :: GoatState -> Maybe SEltTree
makeClipboard goatState :: GoatState
goatState@GoatState {Maybe SEltTree
Text
AttachmentMap
XY
PotatoConfiguration
CanvasSelection
Selection
RenderCache
MouseDrag
OwlPFWorkspace
PotatoDefaultParameters
LayersState
BroadPhaseState
RenderedCanvasRegion
SomePotatoHandler
GoatFocusedArea
_goatState_debugLabel :: Text
_goatState_unbrokenInput :: Text
_goatState_focusedArea :: GoatFocusedArea
_goatState_clipboard :: Maybe SEltTree
_goatState_screenRegion :: XY
_goatState_mouseDrag :: MouseDrag
_goatState_potatoDefaultParameters :: PotatoDefaultParameters
_goatState_configuration :: PotatoConfiguration
_goatState_renderCache :: RenderCache
_goatState_attachmentMap :: AttachmentMap
_goatState_layersHandler :: SomePotatoHandler
_goatState_handler :: SomePotatoHandler
_goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_layersState :: LayersState
_goatState_broadPhaseState :: BroadPhaseState
_goatState_canvasSelection :: CanvasSelection
_goatState_selection :: Selection
_goatState_pan :: XY
_goatState_workspace :: OwlPFWorkspace
_goatState_debugLabel :: GoatState -> Text
_goatState_unbrokenInput :: GoatState -> Text
_goatState_focusedArea :: GoatState -> GoatFocusedArea
_goatState_clipboard :: GoatState -> Maybe SEltTree
_goatState_screenRegion :: GoatState -> XY
_goatState_mouseDrag :: GoatState -> MouseDrag
_goatState_potatoDefaultParameters :: GoatState -> PotatoDefaultParameters
_goatState_configuration :: GoatState -> PotatoConfiguration
_goatState_renderCache :: GoatState -> RenderCache
_goatState_attachmentMap :: GoatState -> AttachmentMap
_goatState_layersHandler :: GoatState -> SomePotatoHandler
_goatState_handler :: GoatState -> SomePotatoHandler
_goatState_renderedSelection :: GoatState -> RenderedCanvasRegion
_goatState_renderedCanvas :: GoatState -> RenderedCanvasRegion
_goatState_layersState :: GoatState -> LayersState
_goatState_broadPhaseState :: GoatState -> BroadPhaseState
_goatState_canvasSelection :: GoatState -> CanvasSelection
_goatState_selection :: GoatState -> Selection
_goatState_pan :: GoatState -> XY
_goatState_workspace :: GoatState -> OwlPFWorkspace
..} = Maybe SEltTree
r where
r :: Maybe SEltTree
r = if forall a. IsParliament a => a -> Bool
isParliament_null Selection
_goatState_selection
then Maybe SEltTree
_goatState_clipboard
else forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ OwlTree -> Selection -> SEltTree
superOwlParliament_toSEltTree (GoatState -> OwlTree
goatState_owlTree GoatState
goatState) Selection
_goatState_selection
deleteSelectionEvent :: GoatState -> Maybe WSEvent
deleteSelectionEvent :: GoatState -> Maybe WSEvent
deleteSelectionEvent gs :: GoatState
gs@GoatState {Maybe SEltTree
Text
AttachmentMap
XY
PotatoConfiguration
CanvasSelection
Selection
RenderCache
MouseDrag
OwlPFWorkspace
PotatoDefaultParameters
LayersState
BroadPhaseState
RenderedCanvasRegion
SomePotatoHandler
GoatFocusedArea
_goatState_debugLabel :: Text
_goatState_unbrokenInput :: Text
_goatState_focusedArea :: GoatFocusedArea
_goatState_clipboard :: Maybe SEltTree
_goatState_screenRegion :: XY
_goatState_mouseDrag :: MouseDrag
_goatState_potatoDefaultParameters :: PotatoDefaultParameters
_goatState_configuration :: PotatoConfiguration
_goatState_renderCache :: RenderCache
_goatState_attachmentMap :: AttachmentMap
_goatState_layersHandler :: SomePotatoHandler
_goatState_handler :: SomePotatoHandler
_goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_layersState :: LayersState
_goatState_broadPhaseState :: BroadPhaseState
_goatState_canvasSelection :: CanvasSelection
_goatState_selection :: Selection
_goatState_pan :: XY
_goatState_workspace :: OwlPFWorkspace
_goatState_debugLabel :: GoatState -> Text
_goatState_unbrokenInput :: GoatState -> Text
_goatState_focusedArea :: GoatState -> GoatFocusedArea
_goatState_clipboard :: GoatState -> Maybe SEltTree
_goatState_screenRegion :: GoatState -> XY
_goatState_mouseDrag :: GoatState -> MouseDrag
_goatState_potatoDefaultParameters :: GoatState -> PotatoDefaultParameters
_goatState_configuration :: GoatState -> PotatoConfiguration
_goatState_renderCache :: GoatState -> RenderCache
_goatState_attachmentMap :: GoatState -> AttachmentMap
_goatState_layersHandler :: GoatState -> SomePotatoHandler
_goatState_handler :: GoatState -> SomePotatoHandler
_goatState_renderedSelection :: GoatState -> RenderedCanvasRegion
_goatState_renderedCanvas :: GoatState -> RenderedCanvasRegion
_goatState_layersState :: GoatState -> LayersState
_goatState_broadPhaseState :: GoatState -> BroadPhaseState
_goatState_canvasSelection :: GoatState -> CanvasSelection
_goatState_selection :: GoatState -> Selection
_goatState_pan :: GoatState -> XY
_goatState_workspace :: GoatState -> OwlPFWorkspace
..} = if forall a. IsParliament a => a -> Bool
isParliament_null Selection
_goatState_selection
then forall a. Maybe a
Nothing
else forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Shepard -> Shift -> Preview -> WSEvent
WSEApplyPreview Shepard
dummyShepard Shift
dummyShift forall a b. (a -> b) -> a -> b
$ PreviewOperation -> Llama -> Preview
Preview PreviewOperation
PO_StartAndCommit forall a b. (a -> b) -> a -> b
$ OwlPFState -> AttachmentMap -> OwlParliament -> Llama
removeEltAndUpdateAttachments_to_llama (GoatState -> OwlPFState
goatState_pFState GoatState
gs) AttachmentMap
_goatState_attachmentMap (Selection -> OwlParliament
superOwlParliament_toOwlParliament Selection
_goatState_selection)
potatoHandlerInputFromGoatState :: GoatState -> PotatoHandlerInput
potatoHandlerInputFromGoatState :: GoatState -> PotatoHandlerInput
potatoHandlerInputFromGoatState GoatState {Maybe SEltTree
Text
AttachmentMap
XY
PotatoConfiguration
CanvasSelection
Selection
RenderCache
MouseDrag
OwlPFWorkspace
PotatoDefaultParameters
LayersState
BroadPhaseState
RenderedCanvasRegion
SomePotatoHandler
GoatFocusedArea
_goatState_debugLabel :: Text
_goatState_unbrokenInput :: Text
_goatState_focusedArea :: GoatFocusedArea
_goatState_clipboard :: Maybe SEltTree
_goatState_screenRegion :: XY
_goatState_mouseDrag :: MouseDrag
_goatState_potatoDefaultParameters :: PotatoDefaultParameters
_goatState_configuration :: PotatoConfiguration
_goatState_renderCache :: RenderCache
_goatState_attachmentMap :: AttachmentMap
_goatState_layersHandler :: SomePotatoHandler
_goatState_handler :: SomePotatoHandler
_goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_layersState :: LayersState
_goatState_broadPhaseState :: BroadPhaseState
_goatState_canvasSelection :: CanvasSelection
_goatState_selection :: Selection
_goatState_pan :: XY
_goatState_workspace :: OwlPFWorkspace
_goatState_debugLabel :: GoatState -> Text
_goatState_unbrokenInput :: GoatState -> Text
_goatState_focusedArea :: GoatState -> GoatFocusedArea
_goatState_clipboard :: GoatState -> Maybe SEltTree
_goatState_screenRegion :: GoatState -> XY
_goatState_mouseDrag :: GoatState -> MouseDrag
_goatState_potatoDefaultParameters :: GoatState -> PotatoDefaultParameters
_goatState_configuration :: GoatState -> PotatoConfiguration
_goatState_renderCache :: GoatState -> RenderCache
_goatState_attachmentMap :: GoatState -> AttachmentMap
_goatState_layersHandler :: GoatState -> SomePotatoHandler
_goatState_handler :: GoatState -> SomePotatoHandler
_goatState_renderedSelection :: GoatState -> RenderedCanvasRegion
_goatState_renderedCanvas :: GoatState -> RenderedCanvasRegion
_goatState_layersState :: GoatState -> LayersState
_goatState_broadPhaseState :: GoatState -> BroadPhaseState
_goatState_canvasSelection :: GoatState -> CanvasSelection
_goatState_selection :: GoatState -> Selection
_goatState_pan :: GoatState -> XY
_goatState_workspace :: GoatState -> OwlPFWorkspace
..} = PotatoHandlerInput
r where
last_workspace :: OwlPFWorkspace
last_workspace = OwlPFWorkspace
_goatState_workspace
last_pFState :: OwlPFState
last_pFState = OwlPFWorkspace -> OwlPFState
_owlPFWorkspace_owlPFState OwlPFWorkspace
last_workspace
r :: PotatoHandlerInput
r = PotatoHandlerInput {
_potatoHandlerInput_pFState :: OwlPFState
_potatoHandlerInput_pFState = OwlPFState
last_pFState
, _potatoHandlerInput_potatoDefaultParameters :: PotatoDefaultParameters
_potatoHandlerInput_potatoDefaultParameters = PotatoDefaultParameters
_goatState_potatoDefaultParameters
, _potatoHandlerInput_broadPhase :: BroadPhaseState
_potatoHandlerInput_broadPhase = BroadPhaseState
_goatState_broadPhaseState
, _potatoHandlerInput_renderCache :: RenderCache
_potatoHandlerInput_renderCache = RenderCache
_goatState_renderCache
, _potatoHandlerInput_screenRegion :: LBox
_potatoHandlerInput_screenRegion = XY -> XY -> LBox
LBox (-XY
_goatState_pan) XY
_goatState_screenRegion
, _potatoHandlerInput_layersState :: LayersState
_potatoHandlerInput_layersState = LayersState
_goatState_layersState
, _potatoHandlerInput_selection :: Selection
_potatoHandlerInput_selection = Selection
_goatState_selection
, _potatoHandlerInput_canvasSelection :: CanvasSelection
_potatoHandlerInput_canvasSelection = CanvasSelection
_goatState_canvasSelection
}
potatoModifyKeyboardKey :: PotatoConfiguration -> Text -> KeyboardData -> Maybe KeyboardData
potatoModifyKeyboardKey :: PotatoConfiguration -> Text -> KeyboardData -> Maybe KeyboardData
potatoModifyKeyboardKey PotatoConfiguration {Bool
Maybe (Maybe Char)
Char -> Int8
_potatoConfiguration_unicodeWideCharFn :: PotatoConfiguration -> Char -> Int8
_potatoConfiguration_allowOrReplaceUnicodeWideChars :: PotatoConfiguration -> Maybe (Maybe Char)
_potatoConfiguration_allowGraphemeClusters :: PotatoConfiguration -> Bool
_potatoConfiguration_unicodeWideCharFn :: Char -> Int8
_potatoConfiguration_allowOrReplaceUnicodeWideChars :: Maybe (Maybe Char)
_potatoConfiguration_allowGraphemeClusters :: Bool
..} Text
lastUnbrokenCharacters KeyboardData
k = case KeyboardData
k of
KeyboardData (KeyboardKey_Char Char
c) [KeyModifier]
mods -> Maybe KeyboardData
r where
fulltext :: Text
fulltext = Text -> Char -> Text
T.snoc Text
lastUnbrokenCharacters Char
c
r :: Maybe KeyboardData
r = if Bool -> Bool
not Bool
_potatoConfiguration_allowGraphemeClusters Bool -> Bool -> Bool
&& Text -> Bool
endsInGraphemeCluster Text
fulltext
then forall a. Maybe a
Nothing
else case Maybe (Maybe Char)
_potatoConfiguration_allowOrReplaceUnicodeWideChars of
Maybe (Maybe Char)
Nothing -> forall a. a -> Maybe a
Just KeyboardData
k
Just Maybe Char
x -> if Char -> Int8
getCharWidth Char
c forall a. Ord a => a -> a -> Bool
> Int8
1
then forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Maybe a
Nothing (\Char
nc -> forall a. a -> Maybe a
Just (KeyboardKey -> [KeyModifier] -> KeyboardData
KeyboardData (Char -> KeyboardKey
KeyboardKey_Char Char
nc) [KeyModifier]
mods)) Maybe Char
x
else forall a. a -> Maybe a
Just KeyboardData
k
KeyboardData
_ -> forall a. a -> Maybe a
Just KeyboardData
k
endoGoatCmdSetDefaultParams :: SetPotatoDefaultParameters -> GoatState -> GoatState
endoGoatCmdSetDefaultParams :: SetPotatoDefaultParameters -> GoatState -> GoatState
endoGoatCmdSetDefaultParams SetPotatoDefaultParameters
spdp GoatState
gs = GoatState
gs {
_goatState_potatoDefaultParameters :: PotatoDefaultParameters
_goatState_potatoDefaultParameters = PotatoDefaultParameters
-> SetPotatoDefaultParameters -> PotatoDefaultParameters
potatoDefaultParameters_set (GoatState -> PotatoDefaultParameters
_goatState_potatoDefaultParameters GoatState
gs) SetPotatoDefaultParameters
spdp
}
endoGoatCmdMarkSaved :: () -> GoatState -> GoatState
endoGoatCmdMarkSaved :: () -> GoatState -> GoatState
endoGoatCmdMarkSaved ()
_ GoatState
gs = GoatState
gs {
_goatState_workspace :: OwlPFWorkspace
_goatState_workspace = OwlPFWorkspace -> OwlPFWorkspace
markWorkspaceSaved (GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
gs)
}
endoGoatCmdSetTool :: Tool -> GoatState -> GoatState
endoGoatCmdSetTool :: Tool -> GoatState -> GoatState
endoGoatCmdSetTool Tool
tool GoatState
gs = GoatState
gs {
_goatState_handler :: SomePotatoHandler
_goatState_handler = GoatState -> Tool -> SomePotatoHandler
makeHandlerFromNewTool GoatState
gs Tool
tool
}
endoGoatCmdSetDebugLabel :: Text -> GoatState -> GoatState
endoGoatCmdSetDebugLabel :: Text -> GoatState -> GoatState
endoGoatCmdSetDebugLabel Text
x GoatState
gs = GoatState
gs {
_goatState_debugLabel :: Text
_goatState_debugLabel = Text
x
}
endoGoatCmdSetCanvasRegionDim :: V2 Int -> GoatState -> GoatState
endoGoatCmdSetCanvasRegionDim :: XY -> GoatState -> GoatState
endoGoatCmdSetCanvasRegionDim XY
x GoatState
gs = GoatState
r where
gs_1 :: GoatState
gs_1 = GoatState
gs {
_goatState_screenRegion :: XY
_goatState_screenRegion = XY
x
}
r :: GoatState
r = XY -> GoatState -> GoatState
goat_setPan (GoatState -> XY
_goatState_pan GoatState
gs_1) GoatState
gs_1
endoGoatCmdWSEvent :: WSEvent -> GoatState -> GoatState
endoGoatCmdWSEvent :: WSEvent -> GoatState -> GoatState
endoGoatCmdWSEvent WSEvent
wsev GoatState
gs = WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
wsev GoatState
gs
endoGoatCmdNewFolder :: Text -> GoatState -> GoatState
endoGoatCmdNewFolder :: Text -> GoatState -> GoatState
endoGoatCmdNewFolder Text
x GoatState
gs = WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
newFolderEv GoatState
gs where
pfs :: OwlPFState
pfs = GoatState -> OwlPFState
goatState_pFState GoatState
gs
folderPos :: OwlSpot
folderPos = OwlTree -> Selection -> OwlSpot
lastPositionInSelection (OwlPFState -> OwlTree
_owlPFState_owlTree OwlPFState
pfs) (GoatState -> Selection
_goatState_selection GoatState
gs)
newFolderEv :: WSEvent
newFolderEv = Shepard -> Shift -> Preview -> WSEvent
WSEApplyPreview Shepard
dummyShepard Shift
dummyShift forall a b. (a -> b) -> a -> b
$ PreviewOperation -> Llama -> Preview
Preview PreviewOperation
PO_StartAndCommit forall a b. (a -> b) -> a -> b
$ OwlPFState -> (OwlSpot, Text) -> Llama
makeAddFolderLlama OwlPFState
pfs (OwlSpot
folderPos, Text
x)
endoGoatCmdLoad :: (SPotatoFlow, ControllerMeta) -> GoatState -> GoatState
endoGoatCmdLoad :: (SPotatoFlow, ControllerMeta) -> GoatState -> GoatState
endoGoatCmdLoad (SPotatoFlow
spf, ControllerMeta
cm) GoatState
gs = GoatState
r where
gs' :: GoatState
gs' = WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh (SPotatoFlow -> WSEvent
WSELoad SPotatoFlow
spf) GoatState
gs
r :: GoatState
r = GoatState
gs' {
_goatState_pan :: XY
_goatState_pan = ControllerMeta -> XY
_controllerMeta_pan ControllerMeta
cm
, _goatState_layersState :: LayersState
_goatState_layersState = OwlPFState -> LayerMetaMap -> LayersState
makeLayersStateFromOwlPFState (GoatState -> OwlPFState
goatState_pFState GoatState
gs') (ControllerMeta -> LayerMetaMap
_controllerMeta_layers ControllerMeta
cm)
}
endoGoatCmdSetFocusedArea :: GoatFocusedArea -> GoatState -> GoatState
endoGoatCmdSetFocusedArea :: GoatFocusedArea -> GoatState -> GoatState
endoGoatCmdSetFocusedArea GoatFocusedArea
gfa GoatState
goatState = GoatState
r where
didchange :: Bool
didchange = GoatFocusedArea
gfa forall a. Eq a => a -> a -> Bool
/= GoatState -> GoatFocusedArea
_goatState_focusedArea GoatState
goatState
goatstatewithnewfocus :: GoatState
goatstatewithnewfocus = GoatState
goatState { _goatState_focusedArea :: GoatFocusedArea
_goatState_focusedArea = GoatFocusedArea
gfa }
noactionneeded :: GoatState
noactionneeded = GoatState
goatstatewithnewfocus
potatoHandlerInput :: PotatoHandlerInput
potatoHandlerInput = GoatState -> PotatoHandlerInput
potatoHandlerInputFromGoatState GoatState
goatState
r :: GoatState
r = if Bool
didchange Bool -> Bool -> Bool
&& forall h. PotatoHandler h => h -> Text
pHandlerName (GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState) forall a. Eq a => a -> a -> Bool
== Text
handlerName_layersRename
then let
goatState_afterAction :: GoatState
goatState_afterAction = case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> KeyboardData -> Maybe PotatoHandlerOutput
pHandleKeyboard (GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState) PotatoHandlerInput
potatoHandlerInput (KeyboardKey -> [KeyModifier] -> KeyboardData
KeyboardData KeyboardKey
KeyboardKey_Return []) of
Maybe PotatoHandlerOutput
Nothing -> GoatState
noactionneeded
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processLayersHandlerOutput PotatoHandlerOutput
pho GoatState
goatstatewithnewfocus
in forall a. HasCallStack => Bool -> a -> a
assert (GoatState -> GoatFocusedArea
_goatState_focusedArea GoatState
goatState forall a. Eq a => a -> a -> Bool
== GoatFocusedArea
GoatFocusedArea_Layers) forall a b. (a -> b) -> a -> b
$ GoatState
goatState_afterAction
else GoatState
noactionneeded
endoGoatCmdMouse :: LMouseData -> GoatState -> GoatState
endoGoatCmdMouse :: LMouseData -> GoatState -> GoatState
endoGoatCmdMouse LMouseData
mouseData GoatState
goatState = forall a. String -> a -> a
trace (String
"endomouse: " forall a. Semigroup a => a -> a -> a
<> forall b a. (Show a, IsString b) => a -> b
show LMouseData
mouseData) forall a b. (a -> b) -> a -> b
$ GoatState
r where
sameSource :: Bool
sameSource = MouseDrag -> Bool
_mouseDrag_isLayerMouse (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState) forall a. Eq a => a -> a -> Bool
== LMouseData -> Bool
_lMouseData_isLayerMouse LMouseData
mouseData
mouseSourceFailure :: Bool
mouseSourceFailure = MouseDrag -> MouseDragState
_mouseDrag_state (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState) forall a. Eq a => a -> a -> Bool
/= MouseDragState
MouseDragState_Up Bool -> Bool -> Bool
&& Bool -> Bool
not Bool
sameSource
mouseDrag :: MouseDrag
mouseDrag = case MouseDrag -> MouseDragState
_mouseDrag_state (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState) of
MouseDragState
MouseDragState_Up -> LMouseData -> MouseDrag
newDrag LMouseData
mouseData
MouseDragState
MouseDragState_Cancelled -> (LMouseData -> MouseDrag -> MouseDrag
continueDrag LMouseData
mouseData (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState)) { _mouseDrag_state :: MouseDragState
_mouseDrag_state = MouseDragState
MouseDragState_Cancelled }
MouseDragState
_ -> LMouseData -> MouseDrag -> MouseDrag
continueDrag LMouseData
mouseData (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState)
canvasDrag :: RelMouseDrag
canvasDrag = OwlPFState -> XY -> MouseDrag -> RelMouseDrag
toRelMouseDrag OwlPFState
last_pFState (GoatState -> XY
_goatState_pan GoatState
goatState) MouseDrag
mouseDrag
goatState_withNewMouse :: GoatState
goatState_withNewMouse = GoatState
goatState {
_goatState_mouseDrag :: MouseDrag
_goatState_mouseDrag = MouseDrag
mouseDrag
, _goatState_focusedArea :: GoatFocusedArea
_goatState_focusedArea = if Bool
isLayerMouse then GoatFocusedArea
GoatFocusedArea_Layers else GoatFocusedArea
GoatFocusedArea_Canvas
}
noChangeOutput :: GoatState
noChangeOutput = GoatState
goatState_withNewMouse
isLayerMouse :: Bool
isLayerMouse = MouseDrag -> Bool
_mouseDrag_isLayerMouse MouseDrag
mouseDrag
potatoHandlerInput :: PotatoHandlerInput
potatoHandlerInput = GoatState -> PotatoHandlerInput
potatoHandlerInputFromGoatState GoatState
goatState_withNewMouse
last_pFState :: OwlPFState
last_pFState = GoatState -> OwlPFState
goatState_pFState GoatState
goatState_withNewMouse
handler :: SomePotatoHandler
handler = GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_withNewMouse
r :: GoatState
r = case MouseDrag -> MouseDragState
_mouseDrag_state MouseDrag
mouseDrag of
MouseDragState
_ | Bool
mouseSourceFailure -> forall a t. (HasCallStack, IsText t) => t -> a
error Text
"invalid mouse sequence due to source"
MouseDragState
MouseDragState_Cancelled -> if LMouseData -> Bool
_lMouseData_isRelease LMouseData
mouseData
then GoatState
goatState_withNewMouse { _goatState_mouseDrag :: MouseDrag
_goatState_mouseDrag = forall a. Default a => a
def }
else GoatState
noChangeOutput
MouseDragState
_ | Bool
isLayerMouse -> case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> RelMouseDrag -> Maybe PotatoHandlerOutput
pHandleMouse (GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState) PotatoHandlerInput
potatoHandlerInput (MouseDrag -> RelMouseDrag
RelMouseDrag MouseDrag
mouseDrag) of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processLayersHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withNewMouse
Maybe PotatoHandlerOutput
Nothing -> GoatState
noChangeOutput
MouseDragState
MouseDragState_Down | LMouseData -> MouseButton
_lMouseData_button LMouseData
mouseData forall a. Eq a => a -> a -> Bool
== MouseButton
MouseButton_Middle -> GoatState
r where
panhandler :: PanHandler
panhandler = forall a. Default a => a
def { _panHandler_maybePrevHandler :: Maybe SomePotatoHandler
_panHandler_maybePrevHandler = forall a. a -> Maybe a
Just (forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler SomePotatoHandler
handler) }
r :: GoatState
r = case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> RelMouseDrag -> Maybe PotatoHandlerOutput
pHandleMouse PanHandler
panhandler PotatoHandlerInput
potatoHandlerInput RelMouseDrag
canvasDrag of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withNewMouse
Maybe PotatoHandlerOutput
Nothing -> forall a t. (HasCallStack, IsText t) => t -> a
error Text
"PanHandler expected to capture mouse input"
MouseDragState
_ -> case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> RelMouseDrag -> Maybe PotatoHandlerOutput
pHandleMouse SomePotatoHandler
handler PotatoHandlerInput
potatoHandlerInput RelMouseDrag
canvasDrag of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withNewMouse
Maybe PotatoHandlerOutput
Nothing | MouseDrag -> MouseDragState
_mouseDrag_state MouseDrag
mouseDrag forall a. Eq a => a -> a -> Bool
== MouseDragState
MouseDragState_Down -> case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> RelMouseDrag -> Maybe PotatoHandlerOutput
pHandleMouse (forall a. Default a => a
def :: SelectHandler) PotatoHandlerInput
potatoHandlerInput RelMouseDrag
canvasDrag of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withNewMouse
Maybe PotatoHandlerOutput
Nothing -> forall a t. (HasCallStack, IsText t) => t -> a
error Text
"handler was expected to capture this mouse state"
Maybe PotatoHandlerOutput
Nothing -> forall a t. (HasCallStack, IsText t) => t -> a
error forall a b. (a -> b) -> a -> b
$ Text
"handler " forall a. Semigroup a => a -> a -> a
<> forall b a. (Show a, IsString b) => a -> b
show (forall h. PotatoHandler h => h -> Text
pHandlerName SomePotatoHandler
handler) forall a. Semigroup a => a -> a -> a
<> Text
"was expected to capture mouse state " forall a. Semigroup a => a -> a -> a
<> forall b a. (Show a, IsString b) => a -> b
show (MouseDrag -> MouseDragState
_mouseDrag_state MouseDrag
mouseDrag)
endoGoatCmdKeyboard :: KeyboardData -> GoatState -> GoatState
endoGoatCmdKeyboard :: KeyboardData -> GoatState -> GoatState
endoGoatCmdKeyboard KeyboardData
kbd' GoatState
goatState = GoatState
r where
last_unbrokenInput :: Text
last_unbrokenInput = GoatState -> Text
_goatState_unbrokenInput GoatState
goatState
next_unbrokenInput :: Text
next_unbrokenInput = case KeyboardData
kbd' of
KeyboardData (KeyboardKey_Char Char
c) [KeyModifier]
_ -> Text -> Char -> Text
T.snoc Text
last_unbrokenInput Char
c
KeyboardData
_ -> Text
""
mkbd :: Maybe KeyboardData
mkbd = PotatoConfiguration -> Text -> KeyboardData -> Maybe KeyboardData
potatoModifyKeyboardKey (GoatState -> PotatoConfiguration
_goatState_configuration GoatState
goatState) Text
last_unbrokenInput KeyboardData
kbd'
goatState_withKeyboard :: GoatState
goatState_withKeyboard = GoatState
goatState { _goatState_unbrokenInput :: Text
_goatState_unbrokenInput = Text
next_unbrokenInput}
potatoHandlerInput :: PotatoHandlerInput
potatoHandlerInput = GoatState -> PotatoHandlerInput
potatoHandlerInputFromGoatState GoatState
goatState_withKeyboard
last_pFState :: OwlPFState
last_pFState = GoatState -> OwlPFState
goatState_pFState GoatState
goatState_withKeyboard
handler :: SomePotatoHandler
handler = GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_withKeyboard
r :: GoatState
r = case Maybe KeyboardData
mkbd of
Maybe KeyboardData
Nothing -> GoatState
goatState_withKeyboard
Just (KeyboardData KeyboardKey
KeyboardKey_Esc [KeyModifier]
_) | MouseDrag -> Bool
mouseDrag_isActive (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState_withKeyboard) -> GoatState
r where
canceledMouse :: MouseDrag
canceledMouse = MouseDrag -> MouseDrag
cancelDrag (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState_withKeyboard)
goatState_withNewMouse :: GoatState
goatState_withNewMouse = GoatState
goatState_withKeyboard {
_goatState_mouseDrag :: MouseDrag
_goatState_mouseDrag = MouseDrag
canceledMouse
, _goatState_focusedArea :: GoatFocusedArea
_goatState_focusedArea = GoatFocusedArea
GoatFocusedArea_None
}
r :: GoatState
r = if MouseDrag -> Bool
_mouseDrag_isLayerMouse (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState_withKeyboard)
then case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> RelMouseDrag -> Maybe PotatoHandlerOutput
pHandleMouse (GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState_withKeyboard) PotatoHandlerInput
potatoHandlerInput (MouseDrag -> RelMouseDrag
RelMouseDrag MouseDrag
canceledMouse) of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processLayersHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withNewMouse
Maybe PotatoHandlerOutput
Nothing -> GoatState
goatState_withNewMouse
else case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> RelMouseDrag -> Maybe PotatoHandlerOutput
pHandleMouse SomePotatoHandler
handler PotatoHandlerInput
potatoHandlerInput (OwlPFState -> XY -> MouseDrag -> RelMouseDrag
toRelMouseDrag OwlPFState
last_pFState (GoatState -> XY
_goatState_pan GoatState
goatState_withKeyboard) MouseDrag
canceledMouse) of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withNewMouse
Maybe PotatoHandlerOutput
Nothing -> GoatState
goatState_withNewMouse
Just KeyboardData
_ | MouseDrag -> Bool
mouseDrag_isActive (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState_withKeyboard) -> GoatState
goatState_withKeyboard
Just KeyboardData
kbd ->
let
maybeHandleLayers :: Maybe GoatState
maybeHandleLayers = do
forall (f :: * -> *). Alternative f => Bool -> f ()
guard forall a b. (a -> b) -> a -> b
$ MouseDrag -> Bool
_mouseDrag_isLayerMouse (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState_withKeyboard)
PotatoHandlerOutput
pho <- forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> KeyboardData -> Maybe PotatoHandlerOutput
pHandleKeyboard (GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState_withKeyboard) PotatoHandlerInput
potatoHandlerInput KeyboardData
kbd
return $ PotatoHandlerOutput -> GoatState -> GoatState
goat_processLayersHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withKeyboard
in case Maybe GoatState
maybeHandleLayers of
Just GoatState
x -> GoatState
x
Maybe GoatState
Nothing -> case forall h.
PotatoHandler h =>
h
-> PotatoHandlerInput -> KeyboardData -> Maybe PotatoHandlerOutput
pHandleKeyboard SomePotatoHandler
handler PotatoHandlerInput
potatoHandlerInput KeyboardData
kbd of
Just PotatoHandlerOutput
pho -> PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput PotatoHandlerOutput
pho GoatState
goatState_withKeyboard
Maybe PotatoHandlerOutput
Nothing -> case KeyboardData
kbd of
KeyboardData KeyboardKey
KeyboardKey_Esc [KeyModifier]
_ -> case MouseDrag -> MouseDragState
_mouseDrag_state (GoatState -> MouseDrag
_goatState_mouseDrag GoatState
goatState_withKeyboard) of
MouseDragState
x | MouseDragState
x forall a. Eq a => a -> a -> Bool
== MouseDragState
MouseDragState_Up Bool -> Bool -> Bool
|| MouseDragState
x forall a. Eq a => a -> a -> Bool
== MouseDragState
MouseDragState_Cancelled -> Bool -> Selection -> GoatState -> GoatState
goat_setSelection Bool
False forall a. IsParliament a => a
isParliament_empty GoatState
goatState_withKeyboard
MouseDragState
_ -> GoatState
goatState_withKeyboard
KeyboardData KeyboardKey
k [] | KeyboardKey
k forall a. Eq a => a -> a -> Bool
== KeyboardKey
KeyboardKey_Delete Bool -> Bool -> Bool
|| KeyboardKey
k forall a. Eq a => a -> a -> Bool
== KeyboardKey
KeyboardKey_Backspace -> case GoatState -> Maybe WSEvent
deleteSelectionEvent GoatState
goatState_withKeyboard of
Maybe WSEvent
Nothing -> GoatState
goatState_withKeyboard
Just WSEvent
wsev -> WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
wsev GoatState
goatState_withKeyboard
KeyboardData (KeyboardKey_Char Char
'c') [KeyModifier
KeyModifier_Ctrl] -> GoatState
r where
copied :: Maybe SEltTree
copied = GoatState -> Maybe SEltTree
makeClipboard GoatState
goatState_withKeyboard
r :: GoatState
r = GoatState
goatState_withKeyboard { _goatState_clipboard :: Maybe SEltTree
_goatState_clipboard = Maybe SEltTree
copied }
KeyboardData (KeyboardKey_Char Char
'x') [KeyModifier
KeyModifier_Ctrl] -> GoatState
r where
copied :: Maybe SEltTree
copied = GoatState -> Maybe SEltTree
makeClipboard GoatState
goatState_withKeyboard
goatState_withClipboard :: GoatState
goatState_withClipboard = GoatState
goatState_withKeyboard { _goatState_clipboard :: Maybe SEltTree
_goatState_clipboard = Maybe SEltTree
copied }
r :: GoatState
r = case GoatState -> Maybe WSEvent
deleteSelectionEvent GoatState
goatState_withKeyboard of
Maybe WSEvent
Nothing -> GoatState
goatState_withClipboard
Just WSEvent
wsev -> WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
wsev GoatState
goatState_withClipboard
KeyboardData (KeyboardKey_Char Char
'v') [KeyModifier
KeyModifier_Ctrl] -> case GoatState -> Maybe SEltTree
_goatState_clipboard GoatState
goatState_withKeyboard of
Maybe SEltTree
Nothing -> GoatState
goatState_withKeyboard
Just SEltTree
stree -> GoatState
r where
offsetstree :: SEltTree
offsetstree = XY -> SEltTree -> SEltTree
offsetSEltTree (forall a. a -> a -> V2 a
V2 Int
1 Int
1) SEltTree
stree
minitree' :: OwlTree
minitree' = SEltTree -> OwlTree
owlTree_fromSEltTree SEltTree
offsetstree
maxid1 :: Int
maxid1 = OwlTree -> Int
owlTree_maxId OwlTree
minitree' forall a. Num a => a -> a -> a
+ Int
1
maxid2 :: Int
maxid2 = OwlPFState -> Int
owlPFState_nextId (OwlPFWorkspace -> OwlPFState
_owlPFWorkspace_owlPFState (GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState_withKeyboard))
minitree :: OwlTree
minitree = Int -> OwlTree -> OwlTree
owlTree_reindex (forall a. Ord a => a -> a -> a
max Int
maxid1 Int
maxid2) OwlTree
minitree'
spot :: OwlSpot
spot = OwlTree -> Selection -> OwlSpot
lastPositionInSelection (GoatState -> OwlTree
goatState_owlTree GoatState
goatState_withKeyboard) (GoatState -> Selection
_goatState_selection GoatState
goatState_withKeyboard)
treePastaEv :: WSEvent
treePastaEv = Shepard -> Shift -> Preview -> WSEvent
WSEApplyPreview Shepard
dummyShepard Shift
dummyShift forall a b. (a -> b) -> a -> b
$ PreviewOperation -> Llama -> Preview
Preview PreviewOperation
PO_StartAndCommit forall a b. (a -> b) -> a -> b
$ OwlPFCmd -> Llama
makePFCLlama forall a b. (a -> b) -> a -> b
$ (OwlTree, OwlSpot) -> OwlPFCmd
OwlPFCNewTree (OwlTree
minitree, OwlSpot
spot)
r :: GoatState
r = WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
treePastaEv (GoatState
goatState_withKeyboard { _goatState_clipboard :: Maybe SEltTree
_goatState_clipboard = forall a. a -> Maybe a
Just SEltTree
offsetstree })
KeyboardData (KeyboardKey_Char Char
'z') [KeyModifier
KeyModifier_Ctrl] -> GoatState
r where
r :: GoatState
r = WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
WSEUndo GoatState
goatState_withKeyboard
KeyboardData (KeyboardKey_Char Char
'y') [KeyModifier
KeyModifier_Ctrl] -> GoatState
r where
r :: GoatState
r = WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_Refresh WSEvent
WSERedo GoatState
goatState_withKeyboard
KeyboardData (KeyboardKey_Char Char
key) [KeyModifier]
_ -> GoatState
r where
mtool :: Maybe Tool
mtool = case Char
key of
Char
'v' -> forall a. a -> Maybe a
Just Tool
Tool_Select
Char
'p' -> forall a. a -> Maybe a
Just Tool
Tool_Pan
Char
'b' -> forall a. a -> Maybe a
Just Tool
Tool_Box
Char
'l' -> forall a. a -> Maybe a
Just Tool
Tool_Line
Char
'n' -> forall a. a -> Maybe a
Just Tool
Tool_TextArea
Char
_ -> forall a. Maybe a
Nothing
newHandler :: SomePotatoHandler
newHandler = forall b a. b -> (a -> b) -> Maybe a -> b
maybe (GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_withKeyboard) (GoatState -> Tool -> SomePotatoHandler
makeHandlerFromNewTool GoatState
goatState_withKeyboard) Maybe Tool
mtool
r :: GoatState
r = GoatState
goatState_withKeyboard { _goatState_handler :: SomePotatoHandler
_goatState_handler = SomePotatoHandler
newHandler }
KeyboardData
_ -> GoatState
goatState_withKeyboard
goat_renderCanvas_move :: RenderContext -> XY -> XY -> (RenderContext, Bool)
goat_renderCanvas_move :: RenderContext -> XY -> XY -> (RenderContext, Bool)
goat_renderCanvas_move rc :: RenderContext
rc@RenderContext {LayerMetaMap
OwlTree
RenderCache
BroadPhaseState
RenderedCanvasRegion
_renderContext_renderedCanvasRegion :: RenderedCanvasRegion
_renderContext_broadPhase :: BroadPhaseState
_renderContext_layerMetaMap :: LayerMetaMap
_renderContext_owlTree :: OwlTree
_renderContext_cache :: RenderCache
_renderContext_cache :: RenderContext -> RenderCache
_renderContext_renderedCanvasRegion :: RenderContext -> RenderedCanvasRegion
_renderContext_broadPhase :: RenderContext -> BroadPhaseState
_renderContext_layerMetaMap :: RenderContext -> LayerMetaMap
_renderContext_owlTree :: RenderContext -> OwlTree
..} XY
pan XY
sr = (RenderContext, Bool)
r where
newBox :: LBox
newBox = XY -> XY -> LBox
LBox (-XY
pan) XY
sr
didScreenRegionMove :: Bool
didScreenRegionMove = RenderedCanvasRegion -> LBox
_renderedCanvasRegion_box RenderedCanvasRegion
_renderContext_renderedCanvasRegion forall a. Eq a => a -> a -> Bool
/= LBox
newBox
r :: (RenderContext, Bool)
r = if Bool
didScreenRegionMove
then (LBox -> RenderContext -> RenderContext
moveRenderedCanvasRegion LBox
newBox RenderContext
rc, Bool
True)
else (RenderContext
rc, Bool
False)
goat_renderCanvas_update :: (HasCallStack) => RenderContext -> NeedsUpdateSet -> SuperOwlChanges -> RenderContext
goat_renderCanvas_update :: HasCallStack =>
RenderContext
-> NeedsUpdateSet -> IntMap (Maybe SuperOwl) -> RenderContext
goat_renderCanvas_update RenderContext
rc NeedsUpdateSet
needsupdateaabbs IntMap (Maybe SuperOwl)
cslmap = RenderContext
r where
r :: RenderContext
r = if forall a. IntMap a -> Bool
IM.null IntMap (Maybe SuperOwl)
cslmap
then RenderContext
rc
else IntMap (Maybe SuperOwl)
-> NeedsUpdateSet -> RenderContext -> RenderContext
updateCanvas IntMap (Maybe SuperOwl)
cslmap NeedsUpdateSet
needsupdateaabbs RenderContext
rc
goat_renderCanvas_selection :: RenderContext -> SuperOwlParliament -> RenderContext
goat_renderCanvas_selection :: RenderContext -> Selection -> RenderContext
goat_renderCanvas_selection RenderContext
rc_from_canvas Selection
next_selection = RenderContext
r where
newBox :: LBox
newBox = RenderedCanvasRegion -> LBox
_renderedCanvasRegion_box forall a b. (a -> b) -> a -> b
$ RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_from_canvas
rendercontext_forSelection :: RenderContext
rendercontext_forSelection = RenderContext
rc_from_canvas {
_renderContext_layerMetaMap :: LayerMetaMap
_renderContext_layerMetaMap = forall a. IntMap a
IM.empty
, _renderContext_renderedCanvasRegion :: RenderedCanvasRegion
_renderContext_renderedCanvasRegion = LBox -> RenderedCanvasRegion
emptyRenderedCanvasRegion LBox
newBox
}
selectionselts :: [Int]
selectionselts = forall (t :: * -> *) a. Foldable t => t a -> [a]
toList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap SuperOwl -> Int
_superOwl_id forall a b. (a -> b) -> a -> b
$ Selection -> Seq SuperOwl
unSuperOwlParliament Selection
next_selection
r :: RenderContext
r = LBox -> [Int] -> RenderContext -> RenderContext
render_new LBox
newBox [Int]
selectionselts RenderContext
rendercontext_forSelection
renderContextFromGoatState :: GoatState -> RenderContext
renderContextFromGoatState :: GoatState -> RenderContext
renderContextFromGoatState GoatState
goatState = RenderContext {
_renderContext_cache :: RenderCache
_renderContext_cache = GoatState -> RenderCache
_goatState_renderCache GoatState
goatState
, _renderContext_owlTree :: OwlTree
_renderContext_owlTree = OwlPFState -> OwlTree
_owlPFState_owlTree (GoatState -> OwlPFState
goatState_pFState GoatState
goatState)
, _renderContext_layerMetaMap :: LayerMetaMap
_renderContext_layerMetaMap = LayersState -> LayerMetaMap
_layersState_meta (GoatState -> LayersState
_goatState_layersState GoatState
goatState)
, _renderContext_broadPhase :: BroadPhaseState
_renderContext_broadPhase = GoatState -> BroadPhaseState
_goatState_broadPhaseState GoatState
goatState
, _renderContext_renderedCanvasRegion :: RenderedCanvasRegion
_renderContext_renderedCanvasRegion = GoatState -> RenderedCanvasRegion
_goatState_renderedCanvas GoatState
goatState
}
goat_setPan :: XY -> GoatState -> GoatState
goat_setPan :: XY -> GoatState -> GoatState
goat_setPan (V2 Int
dx Int
dy) GoatState
goatState = GoatState
r where
V2 Int
cx0 Int
cy0 = GoatState -> XY
_goatState_pan GoatState
goatState
next_pan :: XY
next_pan = forall a. a -> a -> V2 a
V2 (Int
cx0forall a. Num a => a -> a -> a
+Int
dx) (Int
cy0 forall a. Num a => a -> a -> a
+ Int
dy)
rc :: RenderContext
rc = GoatState -> RenderContext
renderContextFromGoatState GoatState
goatState
(RenderContext
rc_aftermove, Bool
_) = RenderContext -> XY -> XY -> (RenderContext, Bool)
goat_renderCanvas_move RenderContext
rc XY
next_pan (GoatState -> XY
_goatState_screenRegion GoatState
goatState)
rc_afterselection :: RenderContext
rc_afterselection = RenderContext -> Selection -> RenderContext
goat_renderCanvas_selection RenderContext
rc_aftermove (GoatState -> Selection
_goatState_selection GoatState
goatState)
r :: GoatState
r = GoatState
goatState {
_goatState_pan :: XY
_goatState_pan = XY
next_pan
, _goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_renderedCanvas = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_aftermove
, _goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedSelection = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_afterselection
}
computeCanvasSelection :: (HasCallStack) => GoatState -> CanvasSelection
computeCanvasSelection :: HasCallStack => GoatState -> CanvasSelection
computeCanvasSelection GoatState
goatState = CanvasSelection
r where
pfs :: OwlPFState
pfs = GoatState -> OwlPFState
goatState_pFState GoatState
goatState
filterHiddenOrLocked :: SuperOwl -> Bool
filterHiddenOrLocked SuperOwl
sowl = Bool -> Bool
not forall a b. (a -> b) -> a -> b
$ OwlTree -> Int -> LayerMetaMap -> Bool
layerMetaMap_isInheritHiddenOrLocked (OwlPFState -> OwlTree
_owlPFState_owlTree OwlPFState
pfs) (SuperOwl -> Int
_superOwl_id SuperOwl
sowl) (LayersState -> LayerMetaMap
_layersState_meta (GoatState -> LayersState
_goatState_layersState GoatState
goatState))
r :: CanvasSelection
r = OwlTree -> (SuperOwl -> Bool) -> Selection -> CanvasSelection
superOwlParliament_convertToCanvasSelection (OwlPFState -> OwlTree
_owlPFState_owlTree OwlPFState
pfs) SuperOwl -> Bool
filterHiddenOrLocked (GoatState -> Selection
_goatState_selection GoatState
goatState)
goat_autoExpandFoldersOfSelection :: GoatState -> GoatState
goat_autoExpandFoldersOfSelection :: GoatState -> GoatState
goat_autoExpandFoldersOfSelection GoatState
goatState = GoatState
r where
next_layersState :: LayersState
next_layersState = Selection -> OwlPFState -> LayersState -> LayersState
expandAllCollapsedParents (GoatState -> Selection
_goatState_selection GoatState
goatState) (GoatState -> OwlPFState
goatState_pFState GoatState
goatState) (GoatState -> LayersState
_goatState_layersState GoatState
goatState)
r :: GoatState
r = GoatState
goatState { _goatState_layersState :: LayersState
_goatState_layersState = LayersState
next_layersState }
goat_setSelection :: Bool -> SuperOwlParliament -> GoatState -> GoatState
goat_setSelection :: Bool -> Selection -> GoatState -> GoatState
goat_setSelection Bool
add Selection
selection GoatState
goatState = GoatState
r where
ot :: OwlTree
ot = forall o. HasOwlTree o => o -> OwlTree
hasOwlTree_owlTree forall b c a. (b -> c) -> (a -> b) -> a -> c
. GoatState -> OwlPFState
goatState_pFState forall a b. (a -> b) -> a -> b
$ GoatState
goatState
next_selection :: Selection
next_selection = Seq SuperOwl -> Selection
SuperOwlParliament forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> a -> Ordering) -> Seq a -> Seq a
Seq.sortBy (OwlTree -> SuperOwl -> SuperOwl -> Ordering
owlTree_superOwl_comparePosition OwlTree
ot) forall b c a. (b -> c) -> (a -> b) -> a -> c
. Selection -> Seq SuperOwl
unSuperOwlParliament forall a b. (a -> b) -> a -> b
$ if Bool
add
then OwlTree -> Selection -> Selection -> Selection
superOwlParliament_disjointUnionAndCorrect OwlTree
ot (GoatState -> Selection
_goatState_selection GoatState
goatState) Selection
selection
else Selection
selection
goatState_afterSelection :: GoatState
goatState_afterSelection = GoatState -> GoatState
goat_autoExpandFoldersOfSelection GoatState
goatState { _goatState_selection :: Selection
_goatState_selection = Selection
next_selection }
next_canvasSelection :: CanvasSelection
next_canvasSelection = HasCallStack => GoatState -> CanvasSelection
computeCanvasSelection GoatState
goatState_afterSelection
next_handler :: SomePotatoHandler
next_handler = SomePotatoHandler -> CanvasSelection -> SomePotatoHandler
maybeUpdateHandlerFromSelection (GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_afterSelection) CanvasSelection
next_canvasSelection
rc_afterselection :: RenderContext
rc_afterselection = RenderContext -> Selection -> RenderContext
goat_renderCanvas_selection (GoatState -> RenderContext
renderContextFromGoatState GoatState
goatState_afterSelection) (Seq SuperOwl -> Selection
SuperOwlParliament forall a b. (a -> b) -> a -> b
$ CanvasSelection -> Seq SuperOwl
unCanvasSelection CanvasSelection
next_canvasSelection)
r :: GoatState
r = GoatState
goatState_afterSelection {
_goatState_handler :: SomePotatoHandler
_goatState_handler = SomePotatoHandler
next_handler
, _goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedSelection = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_afterselection
, _goatState_canvasSelection :: CanvasSelection
_goatState_canvasSelection = CanvasSelection
next_canvasSelection
}
goat_setLayersStateWithChangesFromToggleHide :: LayersState -> SuperOwlChanges -> GoatState -> GoatState
LayersState
ls IntMap (Maybe SuperOwl)
changes GoatState
goatState = GoatState
r where
goatState_afterLayers :: GoatState
goatState_afterLayers = GoatState
goatState {
_goatState_layersState :: LayersState
_goatState_layersState = LayersState
ls
}
next_canvasSelection :: CanvasSelection
next_canvasSelection = HasCallStack => GoatState -> CanvasSelection
computeCanvasSelection forall a b. (a -> b) -> a -> b
$ GoatState
goatState_afterLayers
goatState_afterSelection :: GoatState
goatState_afterSelection = GoatState
goatState_afterLayers {
_goatState_canvasSelection :: CanvasSelection
_goatState_canvasSelection = CanvasSelection
next_canvasSelection
, _goatState_handler :: SomePotatoHandler
_goatState_handler = forall a. HasCallStack => Bool -> a -> a
assert (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. HandlerActiveState -> Bool
handlerActiveState_isActive forall a b. (a -> b) -> a -> b
$ forall h. PotatoHandler h => h -> HandlerActiveState
pIsHandlerActive (GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_afterLayers)) CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
next_canvasSelection
}
(NeedsUpdateSet
needsupdateaabbs, BroadPhaseState
next_broadPhaseState) = forall a.
HasOwlTree a =>
a
-> IntMap (Maybe SuperOwl)
-> BPTree
-> (NeedsUpdateSet, BroadPhaseState)
update_bPTree (GoatState -> OwlPFState
goatState_pFState GoatState
goatState_afterSelection) IntMap (Maybe SuperOwl)
changes (BroadPhaseState -> BPTree
_broadPhaseState_bPTree (GoatState -> BroadPhaseState
_goatState_broadPhaseState GoatState
goatState_afterSelection))
goatState_afterUpdateBroadPhase :: GoatState
goatState_afterUpdateBroadPhase = GoatState
goatState_afterSelection { _goatState_broadPhaseState :: BroadPhaseState
_goatState_broadPhaseState = BroadPhaseState
next_broadPhaseState }
rc :: RenderContext
rc = GoatState -> RenderContext
renderContextFromGoatState GoatState
goatState_afterUpdateBroadPhase
rc_afterupdate :: RenderContext
rc_afterupdate = HasCallStack =>
RenderContext
-> NeedsUpdateSet -> IntMap (Maybe SuperOwl) -> RenderContext
goat_renderCanvas_update RenderContext
rc NeedsUpdateSet
needsupdateaabbs IntMap (Maybe SuperOwl)
changes
rc_afterselection :: RenderContext
rc_afterselection = RenderContext -> Selection -> RenderContext
goat_renderCanvas_selection RenderContext
rc_afterupdate ( Seq SuperOwl -> Selection
SuperOwlParliament forall b c a. (b -> c) -> (a -> b) -> a -> c
. CanvasSelection -> Seq SuperOwl
unCanvasSelection forall a b. (a -> b) -> a -> b
$ CanvasSelection
next_canvasSelection)
r :: GoatState
r = GoatState
goatState_afterUpdateBroadPhase {
_goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_renderedCanvas = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_afterupdate
, _goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedSelection = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_afterselection
}
goat_processHandlerOutput_noSetHandler :: PotatoHandlerOutput -> GoatState -> GoatState
goat_processHandlerOutput_noSetHandler :: PotatoHandlerOutput -> GoatState -> GoatState
goat_processHandlerOutput_noSetHandler PotatoHandlerOutput
pho GoatState
goatState = forall a. String -> a -> a
trace (String
"goat_processHandlerOutput_noSetHandler HANDLER OUTPUT: " forall a. Semigroup a => a -> a -> a
<> forall b a. (Show a, IsString b) => a -> b
show PotatoHandlerOutput
pho forall a. Semigroup a => a -> a -> a
<> String
" CURRENT HANDLER: " forall a. Semigroup a => a -> a -> a
<> forall b a. (Show a, IsString b) => a -> b
show (GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState)) forall a b. (a -> b) -> a -> b
$ GoatState
r where
r :: GoatState
r = case PotatoHandlerOutput -> HandlerOutputAction
_potatoHandlerOutput_action PotatoHandlerOutput
pho of
HOA_Select Bool
x Selection
y -> Bool -> Selection -> GoatState -> GoatState
goat_setSelection Bool
x Selection
y GoatState
goatState
HOA_Pan XY
x -> XY -> GoatState -> GoatState
goat_setPan XY
x GoatState
goatState
HOA_Layers LayersState
x IntMap (Maybe SuperOwl)
y -> LayersState -> IntMap (Maybe SuperOwl) -> GoatState -> GoatState
goat_setLayersStateWithChangesFromToggleHide LayersState
x IntMap (Maybe SuperOwl)
y GoatState
goatState
HOA_Preview Preview
p -> WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
WSEventType_Local_NoRefresh (Shepard -> Shift -> Preview -> WSEvent
WSEApplyPreview Shepard
dummyShepard Shift
dummyShift Preview
p) GoatState
goatState
HandlerOutputAction
HOA_Nothing -> GoatState
goatState
goat_processLayersHandlerOutput :: PotatoHandlerOutput -> GoatState -> GoatState
goat_processLayersHandlerOutput :: PotatoHandlerOutput -> GoatState -> GoatState
goat_processLayersHandlerOutput PotatoHandlerOutput
pho GoatState
goatState = PotatoHandlerOutput -> GoatState -> GoatState
goat_processHandlerOutput_noSetHandler PotatoHandlerOutput
pho forall a b. (a -> b) -> a -> b
$ GoatState
goatState { _goatState_layersHandler :: SomePotatoHandler
_goatState_layersHandler = forall a. a -> Maybe a -> a
fromMaybe (GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState) (PotatoHandlerOutput -> Maybe SomePotatoHandler
_potatoHandlerOutput_nextHandler PotatoHandlerOutput
pho) }
goat_processCanvasHandlerOutput :: PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput :: PotatoHandlerOutput -> GoatState -> GoatState
goat_processCanvasHandlerOutput PotatoHandlerOutput
pho GoatState
goatState = GoatState
r where
canvasSelection :: CanvasSelection
canvasSelection = HasCallStack => GoatState -> CanvasSelection
computeCanvasSelection GoatState
goatState
wasNoAction :: Bool
wasNoAction = HandlerOutputAction -> Bool
handlerOutputAction_isNothing forall a b. (a -> b) -> a -> b
$ PotatoHandlerOutput -> HandlerOutputAction
_potatoHandlerOutput_action PotatoHandlerOutput
pho
(SomePotatoHandler
next_handler, OwlPFWorkspace
next_workspace) = case PotatoHandlerOutput -> Maybe SomePotatoHandler
_potatoHandlerOutput_nextHandler PotatoHandlerOutput
pho of
Maybe SomePotatoHandler
Nothing -> (CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
canvasSelection, if Bool
wasNoAction then OwlPFWorkspace -> OwlPFWorkspace
maybeCommitLocalPreviewToLlamaStackAndClear forall a b. (a -> b) -> a -> b
$ GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState else GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState)
Just SomePotatoHandler
x -> (SomePotatoHandler
x, GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState)
goatState' :: GoatState
goatState' = GoatState
goatState {
_goatState_handler :: SomePotatoHandler
_goatState_handler = SomePotatoHandler
next_handler
, _goatState_workspace :: OwlPFWorkspace
_goatState_workspace = OwlPFWorkspace
next_workspace
}
r :: GoatState
r = PotatoHandlerOutput -> GoatState -> GoatState
goat_processHandlerOutput_noSetHandler PotatoHandlerOutput
pho forall a b. (a -> b) -> a -> b
$ GoatState
goatState'
data WSEventType = WSEventType_Local_NoRefresh | WSEventType_Local_Refresh | WSEventType_Remote_Refresh deriving (WSEventType -> WSEventType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WSEventType -> WSEventType -> Bool
$c/= :: WSEventType -> WSEventType -> Bool
== :: WSEventType -> WSEventType -> Bool
$c== :: WSEventType -> WSEventType -> Bool
Eq, Int -> WSEventType -> ShowS
[WSEventType] -> ShowS
WSEventType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WSEventType] -> ShowS
$cshowList :: [WSEventType] -> ShowS
show :: WSEventType -> String
$cshow :: WSEventType -> String
showsPrec :: Int -> WSEventType -> ShowS
$cshowsPrec :: Int -> WSEventType -> ShowS
Show)
wSEventType_isRemote :: WSEventType -> Bool
wSEventType_isRemote :: WSEventType -> Bool
wSEventType_isRemote WSEventType
WSEventType_Remote_Refresh = Bool
True
wSEventType_isRemote WSEventType
_ = Bool
False
wSEventType_needsRefresh :: WSEventType -> Bool
wSEventType_needsRefresh :: WSEventType -> Bool
wSEventType_needsRefresh WSEventType
WSEventType_Local_Refresh = Bool
True
wSEventType_needsRefresh WSEventType
WSEventType_Remote_Refresh = Bool
True
wSEventType_needsRefresh WSEventType
_ = Bool
False
goat_applyWSEvent :: WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent :: WSEventType -> WSEvent -> GoatState -> GoatState
goat_applyWSEvent WSEventType
wsetype WSEvent
wse GoatState
goatState = GoatState
goatState_final where
last_pFState :: OwlPFState
last_pFState = GoatState -> OwlPFState
goatState_pFState GoatState
goatState
(OwlPFWorkspace
workspace_afterEvent, IntMap (Maybe SuperOwl)
cslmap_afterEvent) = WSEvent
-> OwlPFWorkspace -> (OwlPFWorkspace, IntMap (Maybe SuperOwl))
updateOwlPFWorkspace WSEvent
wse (GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState)
goatState_afterEvent :: GoatState
goatState_afterEvent = GoatState
goatState { _goatState_workspace :: OwlPFWorkspace
_goatState_workspace = OwlPFWorkspace
workspace_afterEvent }
pFState_afterEvent :: OwlPFState
pFState_afterEvent = OwlPFWorkspace -> OwlPFState
_owlPFWorkspace_owlPFState OwlPFWorkspace
workspace_afterEvent
(Bool
isNewSelection, Selection
next_selection) = if forall a. IntMap a -> Bool
IM.null IntMap (Maybe SuperOwl)
cslmap_afterEvent
then (Bool
False, GoatState -> Selection
_goatState_selection GoatState
goatState_afterEvent)
else (Bool, Selection)
r where
newEltFoldMapFn :: Int -> Maybe SuperOwl -> [SuperOwl]
newEltFoldMapFn Int
rid Maybe SuperOwl
v = case Maybe SuperOwl
v of
Maybe SuperOwl
Nothing -> []
Just SuperOwl
sowl -> if forall a. Int -> IntMap a -> Bool
IM.member Int
rid (OwlTree -> IntMap (OwlItemMeta, OwlItem)
_owlTree_mapping forall b c a. (b -> c) -> (a -> b) -> a -> c
. OwlPFState -> OwlTree
_owlPFState_owlTree forall a b. (a -> b) -> a -> b
$ OwlPFState
last_pFState) then [] else [SuperOwl
sowl]
newlyCreatedSEltls :: [SuperOwl]
newlyCreatedSEltls = forall m a. Monoid m => (Int -> a -> m) -> IntMap a -> m
IM.foldMapWithKey Int -> Maybe SuperOwl -> [SuperOwl]
newEltFoldMapFn IntMap (Maybe SuperOwl)
cslmap_afterEvent
sortedNewlyCreatedSEltls :: Selection
sortedNewlyCreatedSEltls = Seq SuperOwl -> Selection
SuperOwlParliament forall a b. (a -> b) -> a -> b
$ forall a. (a -> a -> Ordering) -> Seq a -> Seq a
Seq.sortBy (OwlTree -> SuperOwl -> SuperOwl -> Ordering
owlTree_superOwl_comparePosition forall a b. (a -> b) -> a -> b
$ OwlPFState -> OwlTree
_owlPFState_owlTree forall a b. (a -> b) -> a -> b
$ OwlPFState
pFState_afterEvent) (forall a. [a] -> Seq a
Seq.fromList [SuperOwl]
newlyCreatedSEltls)
wasLoad :: Bool
wasLoad = case WSEvent
wse of
WSELoad SPotatoFlow
_ -> Bool
True
WSEvent
_ -> Bool
False
r :: (Bool, Selection)
r = if Bool
wasLoad Bool -> Bool -> Bool
|| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [SuperOwl]
newlyCreatedSEltls Bool -> Bool -> Bool
|| WSEventType -> Bool
wSEventType_isRemote WSEventType
wsetype
then (\Seq SuperOwl
x -> (Bool
False, Seq SuperOwl -> Selection
SuperOwlParliament Seq SuperOwl
x)) forall a b. (a -> b) -> a -> b
$ forall a. Seq (Maybe a) -> Seq a
catMaybesSeq forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Selection -> Seq SuperOwl
unSuperOwlParliament (GoatState -> Selection
_goatState_selection GoatState
goatState_afterEvent)) forall a b. (a -> b) -> a -> b
$ \SuperOwl
sowl ->
case forall a. Int -> IntMap a -> Maybe a
IM.lookup (SuperOwl -> Int
_superOwl_id SuperOwl
sowl) IntMap (Maybe SuperOwl)
cslmap_afterEvent of
Maybe (Maybe SuperOwl)
Nothing -> forall a. a -> Maybe a
Just SuperOwl
sowl
Just Maybe SuperOwl
Nothing -> forall a. Maybe a
Nothing
Just (Just SuperOwl
x) -> forall a. a -> Maybe a
Just SuperOwl
x
else (Bool
True, Selection
sortedNewlyCreatedSEltls)
goatState_afterSelection :: GoatState
goatState_afterSelection = GoatState
goatState_afterEvent { _goatState_selection :: Selection
_goatState_selection = Selection
next_selection }
goatState_afterRefreshHandler :: GoatState
goatState_afterRefreshHandler = if WSEventType -> Bool
wSEventType_needsRefresh WSEventType
wsetype
then let
layersHandler :: SomePotatoHandler
layersHandler = GoatState -> SomePotatoHandler
_goatState_layersHandler GoatState
goatState_afterSelection
canvasHandler :: SomePotatoHandler
canvasHandler = GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_afterSelection
checkvalid :: GoatState -> GoatState
checkvalid = forall a. HasCallStack => Bool -> a -> a
assert (forall h. PotatoHandler h => h -> HandlerActiveState
pIsHandlerActive SomePotatoHandler
canvasHandler forall a. Eq a => a -> a -> Bool
/= HandlerActiveState
HAS_Active_Mouse Bool -> Bool -> Bool
&& forall h. PotatoHandler h => h -> HandlerActiveState
pIsHandlerActive SomePotatoHandler
layersHandler forall a. Eq a => a -> a -> Bool
/= HandlerActiveState
HAS_Active_Mouse)
next_potatoHandlerInput :: PotatoHandlerInput
next_potatoHandlerInput = GoatState -> PotatoHandlerInput
potatoHandlerInputFromGoatState GoatState
goatState_afterSelection
canvasSelection :: CanvasSelection
canvasSelection = HasCallStack => GoatState -> CanvasSelection
computeCanvasSelection GoatState
goatState_afterSelection
refreshedCanvasHandler :: SomePotatoHandler
refreshedCanvasHandler = forall a. a -> Maybe a -> a
fromMaybe (CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
canvasSelection) ( forall h.
PotatoHandler h =>
h -> PotatoHandlerInput -> Maybe SomePotatoHandler
pRefreshHandler SomePotatoHandler
canvasHandler PotatoHandlerInput
next_potatoHandlerInput)
refreshedLayersHandler :: SomePotatoHandler
refreshedLayersHandler = forall a. a -> Maybe a -> a
fromMaybe (forall h. PotatoHandler h => h -> SomePotatoHandler
SomePotatoHandler (forall a. Default a => a
def :: LayersHandler)) (forall h.
PotatoHandler h =>
h -> PotatoHandlerInput -> Maybe SomePotatoHandler
pRefreshHandler SomePotatoHandler
layersHandler PotatoHandlerInput
next_potatoHandlerInput)
in GoatState -> GoatState
checkvalid GoatState
goatState_afterSelection {
_goatState_handler :: SomePotatoHandler
_goatState_handler = SomePotatoHandler
refreshedCanvasHandler
, _goatState_layersHandler :: SomePotatoHandler
_goatState_layersHandler = SomePotatoHandler
refreshedLayersHandler
}
else GoatState
goatState_afterSelection
next_layersState' :: LayersState
next_layersState' = OwlPFState -> IntMap (Maybe SuperOwl) -> LayersState -> LayersState
updateLayers OwlPFState
pFState_afterEvent IntMap (Maybe SuperOwl)
cslmap_afterEvent (GoatState -> LayersState
_goatState_layersState GoatState
goatState_afterRefreshHandler)
goatState_afterSetLayersState :: GoatState
goatState_afterSetLayersState = GoatState -> GoatState
goat_autoExpandFoldersOfSelection forall a b. (a -> b) -> a -> b
$ GoatState
goatState_afterRefreshHandler { _goatState_layersState :: LayersState
_goatState_layersState = LayersState
next_layersState' }
next_canvasSelection :: CanvasSelection
next_canvasSelection = HasCallStack => GoatState -> CanvasSelection
computeCanvasSelection GoatState
goatState_afterSetLayersState
(SomePotatoHandler
next_handler, OwlPFWorkspace
next_workspace) = if (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. HandlerActiveState -> Bool
handlerActiveState_isActive) (forall h. PotatoHandler h => h -> HandlerActiveState
pIsHandlerActive (GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_afterSetLayersState)) Bool -> Bool -> Bool
&& Bool -> Bool
not (GoatState -> Bool
goatState_hasLocalPreview GoatState
goatState_afterSetLayersState)
then forall a. String -> a -> a
trace String
"COMMIT: " forall a b. (a -> b) -> a -> b
$ (CanvasSelection -> SomePotatoHandler
makeHandlerFromSelection CanvasSelection
next_canvasSelection, OwlPFWorkspace -> OwlPFWorkspace
maybeCommitLocalPreviewToLlamaStackAndClear forall a b. (a -> b) -> a -> b
$ GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState_afterSetLayersState)
else (GoatState -> SomePotatoHandler
_goatState_handler GoatState
goatState_afterSetLayersState, GoatState -> OwlPFWorkspace
_goatState_workspace GoatState
goatState_afterSetLayersState)
goatState_afterSetHandler :: GoatState
goatState_afterSetHandler = GoatState
goatState_afterSetLayersState {
_goatState_handler :: SomePotatoHandler
_goatState_handler = SomePotatoHandler
next_handler
, _goatState_canvasSelection :: CanvasSelection
_goatState_canvasSelection = CanvasSelection
next_canvasSelection
, _goatState_workspace :: OwlPFWorkspace
_goatState_workspace = OwlPFWorkspace
next_workspace
}
(NeedsUpdateSet
needsupdateaabbs, GoatState
goatState_afterUpdateAttachmentsAndRenderState) = IntMap (Maybe SuperOwl) -> GoatState -> (NeedsUpdateSet, GoatState)
goat_updateAttachmentsAndRenderStateFromChanges IntMap (Maybe SuperOwl)
cslmap_afterEvent GoatState
goatState_afterSetHandler
rc :: RenderContext
rc = GoatState -> RenderContext
renderContextFromGoatState GoatState
goatState_afterUpdateAttachmentsAndRenderState
rc_afterRenderCanvas :: RenderContext
rc_afterRenderCanvas = HasCallStack =>
RenderContext
-> NeedsUpdateSet -> IntMap (Maybe SuperOwl) -> RenderContext
goat_renderCanvas_update RenderContext
rc NeedsUpdateSet
needsupdateaabbs IntMap (Maybe SuperOwl)
cslmap_afterEvent
rc_afterRenderSelection :: RenderContext
rc_afterRenderSelection = RenderContext -> Selection -> RenderContext
goat_renderCanvas_selection RenderContext
rc (GoatState -> Selection
_goatState_selection GoatState
goatState_afterUpdateAttachmentsAndRenderState)
goatState_final :: GoatState
goatState_final = GoatState
goatState_afterUpdateAttachmentsAndRenderState {
_goatState_renderedCanvas :: RenderedCanvasRegion
_goatState_renderedCanvas = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_afterRenderCanvas
, _goatState_renderedSelection :: RenderedCanvasRegion
_goatState_renderedSelection = RenderContext -> RenderedCanvasRegion
_renderContext_renderedCanvasRegion RenderContext
rc_afterRenderSelection
}
goat_updateAttachmentsAndRenderStateFromChanges :: SuperOwlChanges -> GoatState -> ([AABB], GoatState)
goat_updateAttachmentsAndRenderStateFromChanges :: IntMap (Maybe SuperOwl) -> GoatState -> (NeedsUpdateSet, GoatState)
goat_updateAttachmentsAndRenderStateFromChanges IntMap (Maybe SuperOwl)
cslmap_afterEvent GoatState
goatState = (NeedsUpdateSet, GoatState)
r where
pFState_afterEvent :: OwlPFState
pFState_afterEvent = GoatState -> OwlPFState
goatState_pFState GoatState
goatState
next_attachmentMap :: AttachmentMap
next_attachmentMap = IntMap (Maybe SuperOwl) -> AttachmentMap -> AttachmentMap
updateAttachmentMapFromSuperOwlChanges IntMap (Maybe SuperOwl)
cslmap_afterEvent (GoatState -> AttachmentMap
_goatState_attachmentMap GoatState
goatState)
attachmentMapForComputingChanges :: AttachmentMap
attachmentMapForComputingChanges = forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IM.unionWith IntSet -> IntSet -> IntSet
IS.union AttachmentMap
next_attachmentMap (GoatState -> AttachmentMap
_goatState_attachmentMap GoatState
goatState)
attachmentChanges :: IntMap (Maybe SuperOwl)
attachmentChanges = OwlTree
-> AttachmentMap
-> IntMap (Maybe SuperOwl)
-> IntMap (Maybe SuperOwl)
getChangesFromAttachmentMap (OwlPFState -> OwlTree
_owlPFState_owlTree OwlPFState
pFState_afterEvent) AttachmentMap
attachmentMapForComputingChanges IntMap (Maybe SuperOwl)
cslmap_afterEvent
cslmap_withAttachments :: IntMap (Maybe SuperOwl)
cslmap_withAttachments = forall a. IntMap a -> IntMap a -> IntMap a
IM.union IntMap (Maybe SuperOwl)
cslmap_afterEvent IntMap (Maybe SuperOwl)
attachmentChanges
renderCache_resetOnChangesAndAttachments :: RenderCache
renderCache_resetOnChangesAndAttachments = RenderCache -> [Int] -> RenderCache
renderCache_clearAtKeys (GoatState -> RenderCache
_goatState_renderCache GoatState
goatState) (forall a. IntMap a -> [Int]
IM.keys IntMap (Maybe SuperOwl)
cslmap_withAttachments)
(NeedsUpdateSet
needsupdateaabbs, BroadPhaseState
next_broadPhaseState) = forall a.
HasOwlTree a =>
a
-> IntMap (Maybe SuperOwl)
-> BPTree
-> (NeedsUpdateSet, BroadPhaseState)
update_bPTree (OwlPFState -> OwlTree
_owlPFState_owlTree OwlPFState
pFState_afterEvent) IntMap (Maybe SuperOwl)
cslmap_withAttachments (BroadPhaseState -> BPTree
_broadPhaseState_bPTree (GoatState -> BroadPhaseState
_goatState_broadPhaseState GoatState
goatState))
r :: (NeedsUpdateSet, GoatState)
r = (NeedsUpdateSet
needsupdateaabbs, GoatState
goatState {
_goatState_attachmentMap :: AttachmentMap
_goatState_attachmentMap = AttachmentMap
next_attachmentMap
, _goatState_broadPhaseState :: BroadPhaseState
_goatState_broadPhaseState = BroadPhaseState
next_broadPhaseState
, _goatState_renderCache :: RenderCache
_goatState_renderCache = RenderCache
renderCache_resetOnChangesAndAttachments
})