Stability | experimental |
---|---|
Maintainer | dwc@cs.yale.edu |
Safe Haskell | None |
A simple Graphical User Interface with concepts borrowed from Phooey by Conal Elliot.
- type UISF = MSF UI
- getTime :: UISF () Time
- getCTX :: UISF () CTX
- getEvents :: UISF () UIEvent
- getFocusData :: UISF () Focus
- getMousePosition :: UISF () Point
- mkUISF :: (a -> (CTX, Focus, Time, UIEvent) -> (Layout, DirtyBit, Focus, Action, ControlData, b)) -> UISF a b
- mkUISF' :: (a -> (CTX, Focus, Time, UIEvent) -> IO (Layout, DirtyBit, Focus, Action, ControlData, b)) -> UISF a b
- expandUISF :: UISF a b -> a -> (CTX, Focus, Time, UIEvent) -> IO (Layout, DirtyBit, Focus, Action, ControlData, (b, UISF a b))
- compressUISF :: (a -> (CTX, Focus, Time, UIEvent) -> IO (Layout, DirtyBit, Focus, Action, ControlData, (b, UISF a b))) -> UISF a b
- transformUISF :: (UI (c, UISF b c) -> UI (c, UISF b c)) -> UISF b c -> UISF b c
- initialIOAction :: IO x -> (x -> UISF a b) -> UISF a b
- uisfSourceE :: IO c -> UISF (SEvent ()) (SEvent c)
- uisfSinkE :: (b -> IO ()) -> UISF (SEvent b) (SEvent ())
- uisfPipeE :: (b -> IO c) -> UISF (SEvent b) (SEvent c)
- toUISF :: Automaton a b -> UISF a b
- convertToUISF :: NFData b => Double -> Double -> Automaton a b -> UISF a [(b, Time)]
- asyncUISF :: NFData b => Automaton a b -> UISF (SEvent a) (SEvent b)
- 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
- runUI :: Dimension -> String -> UISF () () -> IO ()
- runUI' :: String -> UISF () () -> IO ()
Documentation
UISF Getters
getFocusData :: UISF () FocusSource
Get the focus data from a UISF
getMousePosition :: UISF () PointSource
Get the mouse position from a UISF
UISF constructors, transformers, and converters
These fuctions are various shortcuts for creating UISFs. The types pretty much say it all for how they work.
mkUISF :: (a -> (CTX, Focus, Time, UIEvent) -> (Layout, DirtyBit, Focus, Action, ControlData, b)) -> UISF a bSource
mkUISF' :: (a -> (CTX, Focus, Time, UIEvent) -> IO (Layout, DirtyBit, Focus, Action, ControlData, b)) -> UISF a bSource
expandUISF :: UISF a b -> a -> (CTX, Focus, Time, UIEvent) -> IO (Layout, DirtyBit, Focus, Action, ControlData, (b, UISF a b))Source
compressUISF :: (a -> (CTX, Focus, Time, UIEvent) -> IO (Layout, DirtyBit, Focus, Action, ControlData, (b, UISF a b))) -> UISF a bSource
initialIOAction :: IO x -> (x -> UISF a b) -> UISF a bSource
Apply the given IO action when this UISF is first run and use its result to produce the UISF to run
uisfSinkE :: (b -> IO ()) -> UISF (SEvent b) (SEvent ())Source
Generate a sink UISF from the IO action.
uisfPipeE :: (b -> IO c) -> UISF (SEvent b) (SEvent c)Source
Generate a pipe UISF from the IO action.
UISF Lifting
The following two functions are for lifting SFs to UISFs.
toUISF :: Automaton a b -> UISF a bSource
This is a quick and dirty solution that ignores timing issues.
convertToUISF :: 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.
asyncUISF :: NFData b => Automaton a b -> UISF (SEvent a) (SEvent b)Source
We can also lift a signal function to a UISF asynchronously.
Layout Transformers
These functions are UISF transformers that modify the context.
setSize :: Dimension -> UISF a b -> UISF a bSource
A convenience function for setLayout, setSize sets the layout to a fixed size (in pixels).