From d23ee09e006612230de02865ed2c340211c16a7a Mon Sep 17 00:00:00 2001 From: Francisco Vallarino Date: Mon, 15 Feb 2021 00:02:00 -0300 Subject: [PATCH] Remove unneeded fields in StyleChangeCfg --- app/Main.hs | 2 +- src/Monomer/Widgets/Util/Style.hs | 14 +++----------- src/Monomer/Widgets/Util/Types.hs | 4 ---- tasks.md | 6 +++++- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index f762d53c..08d70118 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -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], diff --git a/src/Monomer/Widgets/Util/Style.hs b/src/Monomer/Widgets/Util/Style.hs index 5f3cc980..e231e21e 100644 --- a/src/Monomer/Widgets/Util/Style.hs +++ b/src/Monomer/Widgets/Util/Style.hs @@ -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] diff --git a/src/Monomer/Widgets/Util/Types.hs b/src/Monomer/Widgets/Util/Types.hs index b7465a8d..84660adf 100644 --- a/src/Monomer/Widgets/Util/Types.hs +++ b/src/Monomer/Widgets/Util/Types.hs @@ -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 diff --git a/tasks.md b/tasks.md index aec24489..c7f3dd08 100644 --- a/tasks.md +++ b/tasks.md @@ -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