| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
NanoUI.Runner
Description
The event loop the backends share: event waiting and frame pacing, click
counting, the redraw decision, quit handling, and the drawing lock. A
backend supplies a SessionDriver for event translation and presentation.
Synopsis
- newtype DrawingLock = DrawingLock (IORef Bool)
- newDrawingLock :: IO DrawingLock
- tryWithDrawingLock :: DrawingLock -> IO a -> IO (Maybe a)
- shouldRedrawFrame :: Context -> Input -> Input -> Bool -> Bool -> Bool -> IO Bool
- data SessionDriver ev = SessionDriver {
- sdPollEvents :: IO [ev]
- sdWaitEvents :: Int -> IO [ev]
- sdApplyEvent :: Input -> ev -> Input
- sdIsButtonEdge :: ev -> Bool
- sdIsHardQuit :: ev -> Bool
- sdIsSessionQuit :: ev -> Bool
- sdSyncDisplay :: Context -> Input -> IO (Context, Input)
- sdDebug :: DebugSamplerRef
- sdContinuous :: !Bool
- sdPacingMs :: !Int
- sdPresentPaces :: IO Bool
- sdAlignSec :: Double
- sdShouldDraw :: Context -> Input -> Input -> Bool -> Bool -> IO Bool
- sdDraw :: Context -> Input -> Bool -> IO (Bool, Input)
- sdOnCursor :: Context -> Input -> IO ()
- sdShouldQuit :: Input -> Bool
- runSessionLoop :: SessionDriver ev -> Context -> Input -> IO ()
Drawing Lock
newtype DrawingLock Source #
Concurrency lock for drawing vs async callbacks (e.g. resize watchers).
Constructors
| DrawingLock (IORef Bool) |
newDrawingLock :: IO DrawingLock Source #
Create a new unacquired drawing lock.
tryWithDrawingLock :: DrawingLock -> IO a -> IO (Maybe a) Source #
Attempt to execute an action under the drawing lock without blocking.
Redraw Decision
Arguments
| :: Context | |
| -> Input | Previous input |
| -> Input | Current input |
| -> Bool | Was animating on previous frame? |
| -> Bool | Continuous redraw requested? |
| -> Bool | Debug live refresh requested? |
| -> IO Bool |
Centralized decision predicate: should the host backend redraw this frame?
Session loop
data SessionDriver ev Source #
What a backend provides to runSessionLoop.
Constructors
| SessionDriver | |
Fields
| |
runSessionLoop :: SessionDriver ev -> Context -> Input -> IO () Source #
Run an event-driven session loop until a termination event or user quit condition.