packages feed

gtk-toy 0.1.0 → 0.1.1

raw patch · 2 files changed

+14/−15 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Graphics.UI.Gtk.Toy: type KeyEvent = (Bool, Either String Char)
+ Graphics.UI.Gtk.Toy: type MouseEvent = Maybe (Bool, Int)

Files

gtk-toy.cabal view
@@ -1,5 +1,5 @@ Name:                gtk-toy-Version:             0.1.0+Version:             0.1.1 Cabal-Version:       >= 1.6 Synopsis:            Convenient Gtk canvas with mouse and keyboard input. Category:            Graphics, GUI@@ -21,7 +21,7 @@ Library   Extensions:        TupleSections, ViewPatterns   Build-Depends:     base >= 4.2 && < 4.6,-                     gtk >= 0.12.0 && < 0.13.0,-                     containers+                     containers,+                     gtk >= 0.12.0 && < 0.13.0   Hs-source-dirs:    src   Exposed-Modules:   Graphics.UI.Gtk.Toy
src/Graphics/UI/Gtk/Toy.hs view
@@ -8,15 +8,15 @@ -- Stability   :  experimental -- Portability :  GHC only ----- The Gtk Toy Framework is an interface over Gtk for creating applications--- which draw things and use the mouse or keyboard.+-- The Gtk Toy Framework is a wrapper over Gtk for conveniently creating +-- applications which draw things and use the mouse or keyboard. -- -- It handles the minutiae of setting up the Gtk window and canvas, and -- processes mouse and keyboard inputs into more palatable data structures. ----------------------------------------------------------------------------- module Graphics.UI.Gtk.Toy   (-    KeyInfo, KeyTable, InputState(..), Interactive(..)+    KeyInfo, KeyTable, MouseEvent, KeyEvent, InputState(..), Interactive(..)   , runToy, quitToy    -- * InputState Accessors@@ -37,8 +37,8 @@ import qualified Graphics.UI.Gtk.Gdk.Events as E  -- | Information about the most recent key-state transition.---   The tuple contains whether the button was pressed, @True@, or released, @False,---   at what time in msec, with which GTK modifiers.+--   The tuple contains whether the button was pressed,+--   at what time in msec, and with which GTK modifiers. type KeyInfo = (Bool, Int, [G.Modifier])  -- | A map of GTK keynames to last-received event regarding each respective@@ -51,13 +51,13 @@   , keyTable :: KeyTable         -- ^ Map from key-name to most recent event   } --- | A KeyEvent tuple specifies whether the key was pressed or not, and---   which key was pressed.  @(Right Char)@ is yielded for keys which would---   normally correspond to character insertions, while @(Left String) provides+-- | A @KeyEvent@ tuple specifies whether the key was pressed or not, and+--   which key was pressed.  @Right Char@ is yielded for keys which would+--   normally correspond to character insertions, while @Left String@ provides --   GTK-convention names for the rest. type KeyEvent = (Bool, Either String Char) --- | A MouseEvent is @Nothing@ if it's a mouse motion event, and otherwise+-- | A @MouseEvent@ is @Nothing@ if it's a mouse motion event, and otherwise --   provides mouse press information. type MouseEvent = Maybe (Bool, Int) @@ -90,7 +90,7 @@ keyInfo :: String -> InputState -> Maybe KeyInfo keyInfo name = M.lookup name . keyTable --- | Gets whether the named key is currently thought to be held down.+-- | Gets whether the named key is held down. keyHeld :: String -> InputState -> Bool keyHeld name (keyInfo name -> Just (True, _, _)) = True keyHeld _ _ = False@@ -100,8 +100,7 @@ eitherHeld :: String -> InputState -> Bool eitherHeld key inp = (keyHeld (key ++ "_L") inp || keyHeld (key ++ "_R") inp) --- | Yields whether the mouse button (1st parameter) is considered pressed---   in the passed InputState.+-- | Whether the indicated mouse button is considered pressed in the InputState. mouseHeld :: Int -> InputState -> Bool mouseHeld ix = keyHeld ("Mouse" ++ show ix)