packages feed

reactive-banana-wx 1.1.0.0 → 1.1.1.0

raw patch · 3 files changed

+126/−2 lines, 3 filesdep ~reactive-bananadep ~wxdep ~wxcore

Dependency ranges changed: reactive-banana, wx, wxcore

Files

CHANGELOG.md view
@@ -1,6 +1,20 @@ Changelog for the `reactive-banana-wx` package ---------------------------------------------- +**version 1.1.1.0**++* Add function `sinkPaint` for time-varying paint functions. #133+* Add mouse event helpers. #132+* Add convenience stack.yml file to reactive-banana-wx. #129++**version 1.1.0.0**++* Adjust to `reactive-banana` version `== 1.1.*`.++**version 1.0.0.0**++* Adjust to `reactive-banana` version `== 1.0.*`.+ **version 0.9.0.2**  * Allow newer dependencies (including `array`, `process`, `wx`, `wxcore`).
reactive-banana-wx.cabal view
@@ -1,5 +1,5 @@ Name:                reactive-banana-wx-Version:             1.1.0.0+Version:             1.1.1.0 Synopsis:            Examples for the reactive-banana library, using wxHaskell. Description:     This library provides some GUI examples for the @reactive-banana@ library,
src/Reactive/Banana/WX.hs view
@@ -16,6 +16,13 @@     -- * Specific widgets     eventText, behaviorText, eventSelection, +    -- * Mouse event helpers+    mouseMotion, mouseEnter, mouseLeave,+    leftDown, leftUp, leftDClick, leftDrag,+    rightDown, rightUp, rightDClick, rightDrag,+    middleDown, middleUp, middleDClick, middleDrag,+    mouseWheel, mouseWheelDown, mouseWheelUp,+     -- * Utilities     event1ToAddHandler, event0ToEvent1,     ) where@@ -66,6 +73,14 @@         e <- changes b         reactimate' $ (fmap $ \x -> set widget [attr := x]) <$> e +-- | Use a time-varying paint function for a widget,+-- but also make sure that the widget is redrawn whenever said function changes.+sinkPaint :: Paint w => w -> Behavior (DC () -> Rect -> IO ()) -> MomentIO ()+sinkPaint w b = do+    sink w [on paint :== b]+    e <- changes b+    reactimate $ repaint w <$ e+ {-----------------------------------------------------------------------------     Specific widgets ------------------------------------------------------------------------------}@@ -108,7 +123,103 @@         s <- get listbox selection         when (s == -1) $ get listbox (on select) >>= id +{-----------------------------------------------------------------------------+    Mouse event helpers+------------------------------------------------------------------------------} +-- | Return 'Just' in the case that the mouse moves.+mouseMotion :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+mouseMotion (MouseMotion point mod) = Just (point, mod)+mouseMotion _ = Nothing++-- | Return 'Just' in the case that the mouse enters the boundary.+mouseEnter :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+mouseEnter (MouseEnter point mod) = Just (point, mod)+mouseEnter _ = Nothing++-- | Return 'Just' in the case that the mouse leaves the boundary.+mouseLeave :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+mouseLeave (MouseLeave point mod) = Just (point, mod)+mouseLeave _ = Nothing++-- | Return 'Just' in the case that the left mouse button is pressed.+leftDown :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+leftDown (MouseLeftDown point mod) = Just (point, mod)+leftDown _ = Nothing++-- | Return 'Just' in the case that the left mouse button is released.+leftUp :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+leftUp (MouseLeftUp point mod) = Just (point, mod)+leftUp _ = Nothing++-- | Return 'Just' in the case that the left mouse button is double-clicked.+leftDClick :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+leftDClick (MouseLeftDClick point mod) = Just (point, mod)+leftDClick _ = Nothing++-- | Return 'Just' in the case that the mouse is dragged around with the left button+-- pressed.+leftDrag :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+leftDrag (MouseLeftDrag point mod) = Just (point, mod)+leftDrag _ = Nothing++-- | Return 'Just' in the case that the right mouse button is pressed.+rightDown :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+rightDown (MouseRightDown point mod) = Just (point, mod)+rightDown _ = Nothing++-- | Return 'Just' in the case that the right mouse button is released.+rightUp :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+rightUp (MouseRightUp point mod) = Just (point, mod)+rightUp _ = Nothing++-- | Return 'Just' in the case that the right mouse button is double-clicked.+rightDClick :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+rightDClick (MouseRightDClick point mod) = Just (point, mod)+rightDClick _ = Nothing++-- | Return 'Just' in the case that the mouse is dragged around with the right button+-- pressed.+rightDrag :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+rightDrag (MouseRightDrag point mod) = Just (point, mod)+rightDrag _ = Nothing++-- | Return 'Just' in the case that the middle mouse button is pressed.+middleDown :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+middleDown (MouseMiddleDown point mod) = Just (point, mod)+middleDown _ = Nothing++-- | Return 'Just' in the case that the middle mouse button is released.+middleUp :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+middleUp (MouseMiddleUp point mod) = Just (point, mod)+middleUp _ = Nothing++-- | Return 'Just' in the case that the middle mouse button is double-clicked.+middleDClick :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+middleDClick (MouseMiddleDClick point mod) = Just (point, mod)+middleDClick _ = Nothing++-- | Return 'Just' in the case that the mouse is dragged around with the middle button+-- pressed.+middleDrag :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+middleDrag (MouseMiddleDrag point mod) = Just (point, mod)+middleDrag _ = Nothing++-- | Return 'Just' in the case that the mouse wheel is scrolled.+mouseWheel :: WX.EventMouse -> Maybe (Bool, WX.Point, WX.Modifiers)+mouseWheel (MouseWheel down point mod) = Just (down, point, mod)+mouseWheel _ = Nothing++-- | Return 'Just' in the case that the mouse wheel is scrolled downward.+mouseWheelDown :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+mouseWheelDown (MouseWheel True point mod) = Just (point, mod)+mouseWheelDown _ = Nothing++-- | Return 'Just' in the case that the mouse wheel is scrolled upward.+mouseWheelUp :: WX.EventMouse -> Maybe (WX.Point, WX.Modifiers)+mouseWheelUp (MouseWheel False point mod) = Just (point, mod)+mouseWheelUp _ = Nothing+ {-----------------------------------------------------------------------------     Utilities ------------------------------------------------------------------------------}@@ -122,4 +233,3 @@ -- | Obtain an 'AddHandler' from a 'WX.Event'. event0ToEvent1 :: WX.Event w (IO ()) -> WX.Event w (() -> IO ()) event0ToEvent1 = mapEvent const (\_ e -> e ())-