Copyright | (c) Daniel Winograd-Cort 2014 |
---|---|
License | see the LICENSE file in the distribution |
Maintainer | dwc@cs.yale.edu |
Stability | experimental |
Safe Haskell | None |
Language | Haskell98 |
A simple Graphical User Interface with concepts borrowed from Phooey by Conal Elliot.
- data UISF b c = UISF {}
- uisfSource :: IO b -> UISF () b
- uisfSink :: (a -> IO ()) -> UISF a ()
- uisfPipe :: (a -> IO b) -> UISF a b
- uisfSourceE :: IO b -> UISF (SEvent ()) (SEvent b)
- uisfSinkE :: (a -> IO ()) -> UISF (SEvent a) (SEvent ())
- uisfPipeE :: (a -> IO b) -> UISF (SEvent a) (SEvent b)
- getTime :: UISF () Time
- getCTX :: UISF () CTX
- getEvents :: UISF () UIEvent
- getFocusData :: UISF () Focus
- addTerminationProc :: IO () -> UISF a a
- getMousePosition :: UISF () Point
- mkUISF :: Layout -> ((CTX, Focus, Time, UIEvent, a) -> (DirtyBit, Focus, Graphic, TerminationProc, b)) -> UISF a b
- asyncUISFE :: NFData b => Automaton (->) a b -> UISF (SEvent a) (SEvent b)
- asyncUISFV :: NFData b => Double -> Double -> Automaton (->) a b -> UISF a [(b, Time)]
- leftRight :: UISF a b -> UISF a b
- rightLeft :: UISF a b -> UISF a b
- topDown :: UISF a b -> UISF a b
- bottomUp :: UISF a b -> UISF a b
- conjoin :: UISF a b -> UISF a b
- unconjoin :: UISF a b -> UISF a b
- setLayout :: Layout -> UISF a b -> UISF a b
- setSize :: Dimension -> UISF a b -> UISF a b
- pad :: (Int, Int, Int, Int) -> UISF a b -> UISF a b
- data UIParams = UIParams {
- uiInitialize :: IO ()
- uiClose :: IO ()
- uiTitle :: String
- uiSize :: Dimension
- uiInitFlow :: Flow
- uiTickDelay :: Double
- defaultUIParams :: UIParams
- runUI :: UIParams -> UISF () () -> IO ()
- runUI' :: UISF () () -> IO ()
Documentation
uisfSource :: IO b -> UISF () b Source
Lift an IO source to UISF.
uisfSinkE :: (a -> IO ()) -> UISF (SEvent a) (SEvent ()) Source
Lift an IO sink to an event-based UISF.
uisfPipeE :: (a -> IO b) -> UISF (SEvent a) (SEvent b) Source
Lift an IO pipe to an event-based UISF.
UISF Getters
getFocusData :: UISF () Focus Source
Get the focus data from a UISF.
addTerminationProc :: IO () -> UISF a a Source
Add a termination procedure to a UISF.
getMousePosition :: UISF () Point Source
Get the mouse position from a UISF.
UISF constructors, transformers, and converters
mkUISF :: Layout -> ((CTX, Focus, Time, UIEvent, a) -> (DirtyBit, Focus, Graphic, TerminationProc, b)) -> UISF a b Source
This function creates a UISF with the given parameters.
UISF Lifting
The following two functions are for lifting Automatons to UISFs.
asyncUISFE :: NFData b => Automaton (->) a b -> UISF (SEvent a) (SEvent b) Source
We can also lift a signal function to a UISF asynchronously.
asyncUISFV :: NFData b => Double -> Double -> Automaton (->) a b -> UISF a [(b, Time)] Source
This is the standard one that appropriately keeps track of simulated time vs real time.
The clockrate is the simulated rate of the input signal function. The buffer is the number of time steps the given signal function is allowed to get ahead of real time. The real amount of time that it can get ahead is the buffer divided by the clockrate seconds. The output signal function takes and returns values in real time. The return values are the list of bs generated in the given time step, each time stamped.
Note that the returned list may be long if the clockrate is much faster than real time and potentially empty if it's slower. Note also that the caller can check the time stamp on the element at the end of the list to see if the inner, "simulated" signal function is performing as fast as it should.
Layout Transformers
These functions are UISF transformers that modify the context.
setSize :: Dimension -> UISF a b -> UISF a b Source
A convenience function for setLayout, setSize sets the layout to a fixed size (in pixels).
Execute UI Program
The UIParams data type provides an interface for modifying some of the settings for runUI without forcing runUI to take a zillion arguments. Typical usage will be to modify the below defaultUIParams using record syntax.
UIParams | |
|
defaultUIParams :: UIParams Source
This is the default UIParams value and what is used in runUI'.