packages feed

reactive-banana-sdl 0.1.2 → 0.2.0

raw patch · 3 files changed

+19/−7 lines, 3 filesdep ~data-lensdep ~reactive-banana

Dependency ranges changed: data-lens, reactive-banana

Files

reactive-banana-sdl.cabal view
@@ -1,5 +1,5 @@ Name:                reactive-banana-sdl-Version:             0.1.2+Version:             0.2.0 Synopsis:            Reactive Banana bindings for SDL Description:         Provides bindings and convenience functions for using reactive banana with SDL. License:             GPL-3@@ -28,10 +28,10 @@    Build-depends:                         base >= 4.2 && < 5,-                    reactive-banana >= 0.7 && < 0.8,+                    reactive-banana >= 0.8 && < 0.9,                     SDL >= 0.6.3 && < 0.7,                     SDL-ttf >= 0.6.1 && < 0.7,-                    data-lens >= 2.0.4 && < 2.1,+                    data-lens >= 2.0.4 && < 2.11,                     data-lens-template >= 2.1.3 && < 2.2,                     SDL-image >=0.6.1 && <0.7 
src/Reactive/Banana/SDL/Graphics/Types.hs view
@@ -30,8 +30,10 @@ data AlignedText = AlignedText {_atextText :: Text, _atextHAlign :: Alignment, _atextVAlign :: Alignment} -- | Image data Image = Image { _imagePath :: String}+-- | a preloaded image+data LoadedImage = LoadedImage { _imageScreen :: Screen} -$(makeLenses [''Mask, ''Fill, ''Text, ''AlignedText, ''Image])+$(makeLenses [''Mask, ''Fill, ''Text, ''AlignedText, ''Image, ''LoadedImage])  instance Eq Color where     (Color r1 g1 b1) == (Color r2 g2 b2) = r1 == r2 && g1 == g2 && b1 == b2
src/Reactive/Banana/SDL/Graphics/Util.hs view
@@ -10,7 +10,7 @@ import Graphics.UI.SDL.TTF import Data.Lens.Common import Graphics.UI.SDL.Image (load)-import Reactive.Banana.Frameworks (Frameworks, changes, reactimate)+import Reactive.Banana.Frameworks (Frameworks, changes, reactimate,reactimate') import Control.Monad (void) --import Debug.Trace @@ -104,7 +104,17 @@             clip = maskClip ^$ mask             offset = Just Rect { rectX = maskX ^$ mask, rectY = maskY ^$ mask, rectW = 0, rectH = 0 } +instance Draw LoadedImage Mask where+    draw img mask = Graphic $ \dst -> blitText dst+        where+            blitText dst = do+                --sz <- textSize (textFont ^$ text) (textMsg ^$ text)+                blitSurface (imageScreen ^$ img) clip dst offset+                return offset+            clip = maskClip ^$ mask+            offset = Just Rect { rectX = maskX ^$ mask, rectY = maskY ^$ mask, rectW = 0, rectH = 0 } + instance Draw AlignedText Rect where     draw text rect = Graphic $ \dst -> blitText dst         where@@ -130,11 +140,11 @@           End->rectY rect + rectY rect-h        return  Rect { rectX = x, rectY = y, rectW = w, rectH = h } --- | rendrer Graph given a behavior for Graphics and a behavior for the Screen   +-- | render Graph given a behavior for Graphics and a behavior for the Screen    renderGraph :: Frameworks t => Behavior t Graphic -> Behavior t Screen -> Moment t () renderGraph bgraph bscreen = do     egraph <- changes $ render <$> bgraph-    reactimate $ (\a b->(void (paintGraphic b a))) <$> bscreen <@> egraph+    reactimate' $ (\b fe -> fe >>= \e -> return $ void $ paintGraphic e b) <$> bscreen <@> egraph  -- | render graph on a event renderGraphOnEvent :: Frameworks t => Behavior t Graphic -> Behavior t Screen -> R.Event t a -> Moment t ()