Standardize path related record field names

This commit is contained in:
Francisco Vallarino 2020-12-07 14:29:52 -03:00
parent 04b8ba09bd
commit 226fc8ccfa
5 changed files with 32 additions and 32 deletions

View File

@ -148,7 +148,7 @@ runApp window maxFps fonts theme exitEvent widgetRoot = do
}
mainModel .= _weModel newWenv
pathFocus .= findNextFocus newWenv FocusFwd rootPath Nothing resizedRoot
focusedPath .= findNextFocus newWenv FocusFwd rootPath Nothing resizedRoot
mainLoop window renderer loopArgs
@ -167,9 +167,9 @@ mainLoop window renderer loopArgs = do
mousePos <- getCurrentMousePos
currentModel <- use mainModel
currentCursor <- use currentCursor
focused <- use pathFocus
overlay <- use pathOverlay
pressed <- use pathPressed
focused <- use focusedPath
overlay <- use overlayPath
pressed <- use pressedPath
let MainLoopArgs{..} = loopArgs
let !ts = startTicks - _mlFrameStartTs
@ -215,7 +215,7 @@ mainLoop window renderer loopArgs = do
let baseStep = (wenv, Seq.empty, _mlWidgetRoot)
when (mouseEntered && isMainBtnPressed && isMouseFocused) $
pathPressed .= Nothing
pressedPath .= Nothing
(rqWenv, _, rqRoot) <- handleRequests baseReqs baseStep
(wtWenv, _, wtRoot) <- handleWidgetTasks rqWenv rqRoot
@ -310,8 +310,8 @@ preProcessEvent
:: (MonomerM s m)
=> WidgetEnv s e -> WidgetNode s e -> SystemEvent -> m [SystemEvent]
preProcessEvent wenv widgetRoot evt@(Move point) = do
overlay <- use L.pathOverlay
hover <- use pathHover
overlay <- use L.overlayPath
hover <- use hoveredPath
let startPath = fromMaybe rootPath overlay
let widget = widgetRoot ^. L.widget
let current = widgetFindByPoint widget wenv startPath point widgetRoot
@ -320,26 +320,26 @@ preProcessEvent wenv widgetRoot evt@(Move point) = do
let leave = [Leave (fromJust hover) point | isJust hover && hoverChanged]
when hoverChanged $
pathHover .= current
hoveredPath .= current
return $ leave ++ enter ++ [evt]
preProcessEvent wenv widgetRoot evt@(ButtonAction point btn PressedBtn) = do
overlay <- use L.pathOverlay
overlay <- use L.overlayPath
let startPath = fromMaybe rootPath overlay
let widget = widgetRoot ^. L.widget
let current = widgetFindByPoint widget wenv startPath point widgetRoot
pathPressed .= current
pressedPath .= current
return [evt]
preProcessEvent wenv widgetRoot evt@(ButtonAction point btn ReleasedBtn) = do
overlay <- use L.pathOverlay
pressed <- use pathPressed
overlay <- use L.overlayPath
pressed <- use pressedPath
let startPath = fromMaybe rootPath overlay
let widget = widgetRoot ^. L.widget
let current = widgetFindByPoint widget wenv startPath point widgetRoot
let extraEvt = [Click point btn | current == pressed]
pathPressed .= Nothing
pressedPath .= Nothing
return $ extraEvt ++ [evt]
preProcessEvent wenv widgetRoot event = return [event]

View File

@ -49,7 +49,7 @@ handleSystemEvents
-> m (HandlerStep s e)
handleSystemEvents wenv systemEvents widgetRoot = nextStep where
reducer (currWctx, currEvents, currRoot) evt = do
focused <- use L.pathFocus
focused <- use L.focusedPath
(wenv2, evts2, wroot2) <- handleSystemEvent currWctx evt focused currRoot
return (wenv2, currEvents >< evts2, wroot2)
@ -63,8 +63,8 @@ handleSystemEvent
-> WidgetNode s e
-> m (HandlerStep s e)
handleSystemEvent wenv event currentTarget widgetRoot = do
pressed <- use L.pathPressed
overlay <- use L.pathOverlay
pressed <- use L.pressedPath
overlay <- use L.overlayPath
case getTargetPath wenv pressed overlay currentTarget event widgetRoot of
Nothing -> return (wenv, Seq.empty, widgetRoot)
@ -170,15 +170,15 @@ handleResizeWidgets reqs previousStep =
handleMoveFocus
:: (MonomerM s m) => FocusDirection -> HandlerStep s e -> m (HandlerStep s e)
handleMoveFocus direction (wenv, events, root) = do
oldFocus <- use L.pathFocus
overlay <- use L.pathOverlay
oldFocus <- use L.focusedPath
overlay <- use L.overlayPath
let wenv0 = wenv { _weFocusedPath = rootPath }
(wenv1, events1, root1) <- handleSystemEvent wenv0 Blur oldFocus root
let newFocus = findNextFocus wenv1 direction oldFocus overlay root1
let tempWenv = wenv1 { _weFocusedPath = newFocus }
L.pathFocus .= newFocus
L.focusedPath .= newFocus
(wenv2, events2, root2) <- handleSystemEvent tempWenv Focus newFocus root1
return (wenv2, events >< events1 >< events2, root2)
@ -188,8 +188,8 @@ handleSetFocus
handleSetFocus newFocus (wenv, events, root) = do
let wenv0 = wenv { _weFocusedPath = newFocus }
oldFocus <- use L.pathFocus
L.pathFocus .= newFocus
oldFocus <- use L.focusedPath
L.focusedPath .= newFocus
(wenv1, events1, root1) <- handleSystemEvent wenv0 Blur oldFocus root
(wenv2, events2, root2) <- handleSystemEvent wenv1 Focus newFocus root1
@ -230,12 +230,12 @@ handleStopTextInput previousStep = do
handleSetOverlay
:: (MonomerM s m) => Path -> HandlerStep s e -> m (HandlerStep s e)
handleSetOverlay path previousStep = do
L.pathOverlay .= Just path
L.overlayPath .= Just path
return previousStep
handleResetOverlay :: (MonomerM s m) => HandlerStep s e -> m (HandlerStep s e)
handleResetOverlay previousStep = do
L.pathOverlay .= Nothing
L.overlayPath .= Nothing
return previousStep
handleSetCursorIcon

View File

@ -46,10 +46,10 @@ data MonomerContext s = MonomerContext {
_mcDpr :: Double,
_mcInputStatus :: InputStatus,
_mcCurrentCursor :: CursorIcon,
_mcPathFocus :: Path,
_mcPathHover :: Maybe Path,
_mcPathPressed :: Maybe Path,
_mcPathOverlay :: Maybe Path,
_mcFocusedPath :: Path,
_mcHoveredPath :: Maybe Path,
_mcPressedPath :: Maybe Path,
_mcOverlayPath :: Maybe Path,
_mcWidgetTasks :: Seq WidgetTask,
_mcCursorIcons :: Map CursorIcon SDLR.Cursor,
_mcRenderRequested :: Bool,

View File

@ -31,10 +31,10 @@ initMonomerContext model win winSize useHiDPI devicePixelRate = MonomerContext {
_mcDpr = devicePixelRate,
_mcInputStatus = def,
_mcCurrentCursor = CursorArrow,
_mcPathFocus = Seq.empty,
_mcPathHover = Nothing,
_mcPathPressed = Nothing,
_mcPathOverlay = Nothing,
_mcFocusedPath = Seq.empty,
_mcHoveredPath = Nothing,
_mcPressedPath = Nothing,
_mcOverlayPath = Nothing,
_mcWidgetTasks = Seq.empty,
_mcCursorIcons = Map.empty,
_mcRenderRequested = False,

View File

@ -85,7 +85,7 @@ processTaskEvent
-> a
-> m (HandlerStep s e)
processTaskEvent wenv widgetRoot path event = do
currentFocus <- use pathFocus
currentFocus <- use L.focusedPath
let emptyResult = WidgetResult widgetRoot Seq.empty Seq.empty
let widget = widgetRoot ^. L.widget