Copyright | (c) Atze van der Ploeg 2015 George Steel 2017 |
---|---|
License | BSD3 |
Maintainer | george.steel@gmail.org |
Safe Haskell | None |
Language | Haskell2010 |
Core functions for inteoperability between GTK and FRPNow
- ffor :: Functor f => f a -> (a -> b) -> f b
- runNowGTK :: Now () -> IO ()
- setAttr :: (WidgetClass w, Eq b) => ReadWriteAttr w a b -> w -> Behavior b -> Now ()
- getUnrealize :: WidgetClass w => w -> Now (Event ())
- getSignal :: GObjectClass widget => Signal widget callback -> widget -> ((value -> IO ()) -> callback) -> Now (EvStream value)
- getSimpleSignal :: GObjectClass widget => Signal widget (value -> IO ()) -> widget -> Now (EvStream value)
- getUnitSignal :: GObjectClass widget => Signal widget (IO ()) -> widget -> Now (EvStream ())
- getClock :: Double -> Now (Behavior Double)
Documentation
ffor :: Functor f => f a -> (a -> b) -> f b Source #
Flipped version of fmap for defining trandformations inline.
runNowGTK :: Now () -> IO () Source #
Run a Now computation which can interact with GTK. Also starts the GTK system. Call only once, or GTK will freak out.
setAttr :: (WidgetClass w, Eq b) => ReadWriteAttr w a b -> w -> Behavior b -> Now () Source #
Set a GTK attribute to a behavior. Each time the behavior changes the attribute is updated.
getUnrealize :: WidgetClass w => w -> Now (Event ()) Source #
Get an event that fires when a widget is destroyed. Useful for cutting off event streams with beforeEs
.
getSignal :: GObjectClass widget => Signal widget callback -> widget -> ((value -> IO ()) -> callback) -> Now (EvStream value) Source #
General interface to convert an GTK signal to an event stream.
The signal has type callback
, for example (ScrollType -> Double -> IO Bool)
and the eventstream gives elements of type value
, for instance (ScrollType,Double)
The conversion function (3rd argument) takes a function to call for producing the value
in our example, a function of type (ScollType,Double) -> IO ()
and produces
a function of the form callback
, in our example (ScrollType -> Double -> IO Bool)
.
In this example we can convert a signal with handler (ScrollType -> Double -> IO Bool)
to an eventstream giving elements of type (ScrollType,Double)
by letting the handler return False
as follows:
scrollToEvStream :: Signal widget (ScrollType -> Double -> IO Bool) -> widget -> Now (EvStream (ScrollType,Double)) scrollToEvStream s w = getSignal s w convert where convert call scrolltype double = do call (scrolltype, double) return False
getSimpleSignal :: GObjectClass widget => Signal widget (value -> IO ()) -> widget -> Now (EvStream value) Source #
Obtain an event stream from a GTK signal giving a single value.
getUnitSignal :: GObjectClass widget => Signal widget (IO ()) -> widget -> Now (EvStream ()) Source #
Obtain an event stream from a unit GTK signal, i.e. a signal with handler type: IO ()
getClock :: Double -> Now (Behavior Double) Source #
Get a clock that gives the time since the creation of the clock in seconds, and updates maximally even given number of seconds.