mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-09-20 08:17:37 +03:00
Another improvement on cursor handling
This commit is contained in:
parent
7ff1fc1850
commit
8bf1d92338
@ -132,7 +132,7 @@ handleAppEvent wenv node model evt = case evt of
|
||||
_ -> []
|
||||
|
||||
buildUI :: WidgetEnv App AppEvent -> App -> WidgetNode App AppEvent
|
||||
buildUI wenv model = traceShow "Creating UI" widgetTree where
|
||||
buildUI wenv model = traceShow "Creating UI" widgetDial where
|
||||
widgetScroll = vscroll (hgrid [
|
||||
vstack [
|
||||
scroll (image "assets/images/pecans.jpg") `style` [height 200],
|
||||
|
@ -770,15 +770,12 @@ resetCursorIfOut
|
||||
-> Maybe Path
|
||||
-> HandlerStep s e
|
||||
-> m ()
|
||||
resetCursorIfOut evt mpath step = do
|
||||
when (isOnLeave evt && isJust targetNode && not inTargetVp) $
|
||||
resetCursorIfOut (Leave point) (Just path) step = do
|
||||
when (isNothing childNode && isJust targetNode) $
|
||||
void $ handleResetCursorIcon (fromJust targetNode ^. L.widgetId) step
|
||||
where
|
||||
(wenv, root, _, _) = step
|
||||
widget = root ^. L.widget
|
||||
targetNode = mpath >>= \path -> widgetFindByPath widget wenv path root
|
||||
targetVp = targetNode ^? _Just . L.viewport
|
||||
inTargetVp = Just True == (pointInRect point <$> targetVp)
|
||||
point = case evt of
|
||||
Leave p -> p
|
||||
_ -> def
|
||||
targetNode = widgetFindByPath widget wenv path root
|
||||
childNode = widgetFindByPoint widget wenv path point root
|
||||
resetCursorIfOut _ _ step = return ()
|
||||
|
@ -166,13 +166,14 @@ handleCursorChange wenv target evt style node = reqs where
|
||||
widgetId = node ^. L.info . L.widgetId
|
||||
isTarget = node ^. L.info . L.path == target
|
||||
hasCursor = isJust (style ^. L.cursorIcon)
|
||||
isPressed = isNodePressed wenv node
|
||||
(_, curIcon) = fromMaybe def (wenv ^. L.cursor)
|
||||
newIcon = fromMaybe CursorArrow (style ^. L.cursorIcon)
|
||||
setCursor = isTarget
|
||||
&& hasCursor
|
||||
&& isCursorEvt evt
|
||||
&& curIcon /= newIcon
|
||||
resetCursor = isTarget && isCursorEvt evt && not hasCursor
|
||||
resetCursor = isTarget && not isPressed && isCursorEvt evt && not hasCursor
|
||||
-- Result
|
||||
reqs
|
||||
| setCursor = [SetCursorIcon widgetId newIcon, RenderOnce]
|
||||
|
4
tasks.md
4
tasks.md
@ -501,6 +501,8 @@
|
||||
- Check split handle size
|
||||
- Add scrollInvisible option (just set the values in cfg)
|
||||
- Check icon not drawing correctly
|
||||
- Check cursor after click (most likely caused by "active" style)
|
||||
- Remove StyleChangeCfg if possible
|
||||
|
||||
- Pending
|
||||
- Add header in all files, indicating license and documenting what the module does
|
||||
@ -520,8 +522,6 @@ Next
|
||||
- Composite example
|
||||
- Validate nested structures update correctly when disabling/enabling parent
|
||||
- Something of generative art (OpenGL example)
|
||||
- Check cursor after click (most likely caused by "active" style)
|
||||
- Remove StyleChangeCfg if possible
|
||||
- Check dial
|
||||
- What's the purpose of custom findByPoint? Handling in event may be better.
|
||||
- Auto scroll affects dropdown
|
||||
|
Loading…
Reference in New Issue
Block a user