packages feed

reactive-glut 0.1.6 → 0.1.7

raw patch · 3 files changed

+25/−9 lines, 3 files

Files

reactive-glut.cabal view
@@ -1,5 +1,5 @@ Name:                reactive-glut-Version:             0.1.6+Version:             0.1.7 Cabal-Version:       >= 1.2 Synopsis:            Connects Reactive and GLUT Category:            FRP, graphics
src/FRP/Reactive/GLUT/Adapter.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Rank2Types, TypeOperators #-} {-# OPTIONS -Wall #-} ---------------------------------------------------------------------- -- |@@ -22,12 +23,17 @@  import qualified Graphics.UI.GLUT as G -import FRP.Reactive (Behavior,stepper)+import FRP.Reactive (Event,Behavior,stepper) import FRP.Reactive.LegacyAdapters  import FRP.Reactive.GLUT.UI import FRP.Reactive.GLUT.SimpleGL +-- while debugging+-- import Control.Concurrent (forkIO)+-- import FRP.Reactive.Internal.Reactive (eFutures,isNeverE)++ -- | Adapter to connect @FRP.Reactive@ with @GLUT@.  Uses given window -- title and a simple canned initialization.  Or do your own -- initialization and then invoke 'adapt'.@@ -39,15 +45,23 @@ adapt :: Sink (UI -> Behavior Action) adapt f =   do clock <- makeClock-     let mkE = makeEvent clock+     let mkE :: forall a. Show a => (a :+-> Event a)+         mkE = makeEvent clock      (mousePosSink , mousePosE ) <- mkE      (leftDownSink , leftDown  ) <- mkE      (rightDownSink, rightDown ) <- mkE      (keyActionSink, keyActions) <- mkE      (tickSink     , tick      ) <- mkE++     -- Debugging:+     -- isNeverE leftDown ==   C-c C-c+     -- putStrLn ("isNeverE leftDown == " ++ show (isNeverE leftDown))+     -- forkIO $ do putStrLn ("mouse motion: " ++ show mousePosE)+     -- forkIO $ do putStrLn ("lbp: " ++ show (eFutures leftDown))+      -- TODO: let the initial mouse position be its actual position-     let windowPoint' p = do -- putStrLn $ "window point " ++ show p-                             windowPoint p+     let windowPoint'  p = do -- putStrLn $ "window point " ++ show p+                              windowPoint p          mousePosSink' p = do -- putStrLn $ "mouse " ++ show p                               mousePosSink p                               -- yield@@ -61,10 +75,10 @@        case (k,ks) of          (G.MouseButton G.LeftButton ,G.Down) -> leftDownSink  ()          (G.MouseButton G.RightButton,G.Down) -> rightDownSink ()-         (G.Char c      ,G.Down) -> keyActionSink (Down, Char c)+         (G.Char       c,G.Down) -> keyActionSink (Down, Char       c)          (G.SpecialKey s,G.Down) -> keyActionSink (Down, SpecialKey s)-         (G.Char c      ,G.Up)   -> keyActionSink (Up  , Char c)-         (G.SpecialKey s,G.Up)   -> keyActionSink (Up  , SpecialKey s)+         (G.Char       c,G.Up  ) -> keyActionSink (Up  , Char       c)+         (G.SpecialKey s,G.Up  ) -> keyActionSink (Up  , SpecialKey s)          _ -> return ()       )      updater <- mkUpdater
src/FRP/Reactive/GLUT/UI.hs view
@@ -25,6 +25,8 @@ import qualified Graphics.UI.GLUT as G  import Data.VectorSpace+import Data.AffineSpace+ import FRP.Reactive  -- | Simple UI type.@@ -49,6 +51,6 @@ keyPressed = fmap snd . filterE ((==Down) . fst) . keyAction  -- | Integral tracking frame sampling-uiIntegral :: (VectorSpace v, Scalar v ~ TimeT) =>+uiIntegral :: (VectorSpace v, Scalar v ~ Diff TimeT) =>               (UI -> Behavior v) -> (UI -> Behavior v) uiIntegral = liftA2 integral framePass