nano-ui
Safe HaskellNone
LanguageGHC2024

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

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

shouldRedrawFrame Source #

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.