Remove unneeded fields in StyleChangeCfg

This commit is contained in:
Francisco Vallarino 2021-02-15 00:02:00 -03:00
parent cfc5c4d9f4
commit d23ee09e00
4 changed files with 9 additions and 17 deletions

View File

@ -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" widgetDial where
buildUI wenv model = traceShow "Creating UI" widgetTree where
widgetScroll = vscroll (hgrid [
vstack [
scroll (image "assets/images/pecans.jpg") `style` [height 200],

View File

@ -160,29 +160,21 @@ handleCursorChange
-> [WidgetRequest s]
handleCursorChange wenv target evt style cfg node = reqs where
-- Cursor
cfgIcon = cfg ^. L.cursorIcon
isCursorEvt = cfg ^. L.cursorEvt
isCursorInside = cfg ^. L.cursorInside
hoveredPath = fromMaybe rootPath (wenv ^. L.hoveredPath)
mousePos = wenv ^. L.inputStatus . L.mousePos
widgetId = node ^. L.info . L.widgetId
path = node ^. L.info . L.path
isTarget = path == target
isTarget = node ^. L.info . L.path == target
hasCursor = isJust (style ^. L.cursorIcon)
isHoveredParent = seqStartsWith target hoveredPath
&& notElem target [hoveredPath, rootPath]
(curIcon, _) = fromMaybe def (wenv ^. L.cursor)
inOverlay = isNodeInOverlay wenv node
outsideActiveOverlay = isJust (wenv ^. L.overlayPath) && not inOverlay
newIcon
| outsideActiveOverlay = CursorArrow
| otherwise = fromMaybe CursorArrow (style ^. L.cursorIcon <|> cfgIcon)
| otherwise = fromMaybe CursorArrow (style ^. L.cursorIcon)
setCursor = isTarget
&& (hasCursor || outsideActiveOverlay)
&& isCursorEvt evt
&& isCursorInside mousePos
&& curIcon /= newIcon
resetCursor = not isHoveredParent && not (isCursorInside mousePos)
resetCursor = isTarget && not hasCursor
-- Result
reqs
| setCursor = [SetCursorIcon widgetId newIcon, RenderOnce]

View File

@ -18,16 +18,12 @@ type GetBaseStyle s e
data StyleChangeCfg = StyleChangeCfg {
_sccCursorIgnore :: Bool,
_sccCursorIcon :: Maybe CursorIcon,
_sccCursorInside :: Point -> Bool,
_sccCursorEvt :: SystemEvent -> Bool
}
instance Default StyleChangeCfg where {
def = StyleChangeCfg {
_sccCursorIgnore = False,
_sccCursorIcon = Nothing,
_sccCursorInside = const True,
_sccCursorEvt = \case
Enter{} -> True
_ -> False

View File

@ -512,11 +512,15 @@ Next
- Composite example
- Validate nested structures update correctly when disabling/enabling parent
- Something of generative art (OpenGL example)
- Check StyleChangeCfg
- Fix cursor change handling
- Children should not change it if they don't have their own icon
- OnLeave should restore the previous icon (use a stack)
- Check StyleChangeCfg
- Add scrollInvisible option (just set the values in cfg)
- Auto scroll affects dropdown
- Check split handle size
- Add scissor to image
- Check icon not drawing correctly
- Add underline and strikethrough
- Add externalLink component
- https://stackoverflow.com/questions/3037088/how-to-open-the-default-web-browser-in-windows-in-c/54334181