gloss 1.5.0.2 → 1.5.2.1
raw patch · 4 files changed
+68/−11 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Graphics.Gloss.Data.Color: rawColor :: Float -> Float -> Float -> Float -> Color
Files
- Graphics/Gloss/Data/Color.hs +20/−4
- Graphics/Gloss/Internals/Interface/Backend/GLFW.hs +45/−5
- Graphics/Gloss/Internals/Interface/Backend/GLUT.hs +2/−1
- gloss.cabal +1/−1
Graphics/Gloss/Data/Color.hs view
@@ -4,8 +4,8 @@ ( -- ** Color data type Color- , makeColor- , makeColor8+ , makeColor, makeColor8+ , rawColor , rgbaOfColor -- ** Color functions@@ -31,7 +31,7 @@ -- are in the required range. To make a custom color use 'makeColor'. data Color -- | Holds the color components. All components lie in the range [0..1.- = RGBA Float Float Float Float+ = RGBA !Float !Float !Float !Float deriving (Show, Eq) @@ -46,7 +46,8 @@ makeColor r g b a = clampColor $ RGBA r g b a-+{-# INLINE makeColor #-}+ -- | Make a custom color. All components are clamped to the range [0..255]. makeColor8 @@ -62,12 +63,27 @@ (fromIntegral g / 255) (fromIntegral b / 255) (fromIntegral a / 255)+{-# INLINE makeColor8 #-} -- | Take the RGBA components of a color. rgbaOfColor :: Color -> (Float, Float, Float, Float) rgbaOfColor (RGBA r g b a) = (r, g, b, a)+{-# INLINE rgbaOfColor #-} ++-- | Make a custom color.+-- Components should be in the range [0..1] but this is not checked.+rawColor+ :: Float -- ^ Red component.+ -> Float -- ^ Green component.+ -> Float -- ^ Blue component.+ -> Float -- ^ Alpha component.+ -> Color++rawColor = RGBA+{-# INLINE rawColor #-}+ -- Internal
Graphics/Gloss/Internals/Interface/Backend/GLFW.hs view
@@ -6,6 +6,7 @@ (GLFWState) where import Data.IORef+import Data.Char (toLower) import Control.Monad import Graphics.UI.GLFW (WindowValue(..)) import qualified Graphics.UI.GLFW as GLFW@@ -108,7 +109,7 @@ exitGLFW _ = do #ifdef linux_HOST_OS--- See comment in header on why we exit GLUT for Linux+-- See [Note: FreeGlut] on why we exit GLUT for Linux GLUT.exit #endif GLFW.closeWindow@@ -302,9 +303,15 @@ :: IORef GLFWState -> [Callback] -> Char -> Bool -> IO () -callbackChar stateRef callbacks key keystate+callbackChar stateRef callbacks char keystate = do (GLFWState mods pos _ _ _ _) <- readIORef stateRef- let key' = if (fromEnum key == 32) then SpecialKey KeySpace else Char key+ let key' = charToSpecial char+ -- Only key presses of characters are passed to this callback,+ -- character key releases are caught by the 'keyCallback'. This is an+ -- intentional feature of GLFW. What this means that a key press of+ -- the '>' char (on a US Intl keyboard) is captured by this callback,+ -- but a release is captured as a '.' with the shift-modifier in the+ -- keyCallback. let keystate' = if keystate then Down else Up -- Call all the Gloss KeyMouse actions with the new state.@@ -448,7 +455,7 @@ instance GLFWKey GLFW.Key where fromGLFW key = case key of- GLFW.CharKey _ -> SpecialKey KeyUnknown+ GLFW.CharKey c -> charToSpecial (toLower c) GLFW.KeySpace -> SpecialKey KeySpace GLFW.KeyEsc -> SpecialKey KeyEsc GLFW.KeyF1 -> SpecialKey KeyF1@@ -504,9 +511,42 @@ GLFW.KeyPadSubtract -> SpecialKey KeyPadSubtract GLFW.KeyPadAdd -> SpecialKey KeyPadAdd GLFW.KeyPadDecimal -> SpecialKey KeyPadDecimal- GLFW.KeyPadEqual -> SpecialKey KeyPadEqual+ GLFW.KeyPadEqual -> Char '=' GLFW.KeyPadEnter -> SpecialKey KeyPadEnter _ -> SpecialKey KeyUnknown+++-- | Convert char keys to special keys to work around a bug in +-- GLFW 2.7. On OS X, GLFW sometimes registers special keys as char keys,+-- so we convert them back here.+-- GLFW 2.7 is current as of Nov 2011, and is shipped with the Hackage+-- binding GLFW-b 0.2.*+charToSpecial :: Char -> Key+charToSpecial c = case (fromEnum c) of+ 32 -> SpecialKey KeySpace+ 63232 -> SpecialKey KeyUp+ 63233 -> SpecialKey KeyDown+ 63234 -> SpecialKey KeyLeft+ 63235 -> SpecialKey KeyRight+ 63236 -> SpecialKey KeyF1+ 63237 -> SpecialKey KeyF2+ 63238 -> SpecialKey KeyF3+ 63239 -> SpecialKey KeyF4+ 63240 -> SpecialKey KeyF5+ 63241 -> SpecialKey KeyF6+ 63242 -> SpecialKey KeyF7+ 63243 -> SpecialKey KeyF8+ 63244 -> SpecialKey KeyF9+ 63245 -> SpecialKey KeyF10+ 63246 -> SpecialKey KeyF11+ 63247 -> SpecialKey KeyF12+ 63248 -> SpecialKey KeyF13+ 63272 -> SpecialKey KeyDelete+ 63273 -> SpecialKey KeyHome+ 63275 -> SpecialKey KeyEnd+ 63276 -> SpecialKey KeyPageUp+ 63277 -> SpecialKey KeyPageDown+ _ -> Char c instance GLFWKey GLFW.MouseButton where fromGLFW mouse
Graphics/Gloss/Internals/Interface/Backend/GLUT.hs view
@@ -239,7 +239,8 @@ -> IO () installMotionCallbackGLUT ref callbacks- = GLUT.motionCallback $= Just (callbackMotion ref callbacks)+ = do GLUT.motionCallback $= Just (callbackMotion ref callbacks)+ GLUT.passiveMotionCallback $= Just (callbackMotion ref callbacks) callbackMotion :: IORef GLUTState -> [Callback]
gloss.cabal view
@@ -1,5 +1,5 @@ Name: gloss-Version: 1.5.0.2+Version: 1.5.2.1 License: MIT License-file: LICENSE Author: Ben Lippmeier