packages feed

nano-ui-0.2.0.0: lib/NanoUI/Monad.hs

-- | The 'NanoUI' monad: widget id scopes and keys, frame input and time,
-- theme scopes, focus, clipboard, scrolling, and damage requests from inside
-- a view. "NanoUI" re-exports the most common operations; this module exports
-- the rest. Running a view against a context is in "NanoUI.Backend", and
-- mixing views with other @effectful@ effects in "NanoUI.Effectful".
module NanoUI.Monad
  ( -- * Views
    NanoUI
  , liftIO
  , withUiResource
  , catchView

    -- | The functions of "NanoUI" that take a 'Context' (scrolling, themes)
    -- take the view's from 'askContext'.
  , Context
  , askContext

    -- * Widget ids
  , withKey
  , keyedTag
  , scope
  , nextId
  , currentId

    -- * Input and time
  , askInput
  , askFrameInput
  , localInput
  , uiMousePos
  , mousePressed
  , mouseReleased
  , mouseHeld
  , uiTime
  , windowSize
  , windowWidth
  , windowHeight
  , lastRect
  , takeEscape

    -- * Layout, fonts and themes
  , askDefaultLayout
  , withDefaultLayout
  , uiFontMetrics
  , uiFontSize
  , resolveFontUi
  , lineWidthUi
  , truncateTextUi
  , truncateTextWithUi
  , uiTheme
  , setTheme
  , followSystemTheme
  , styled
  , themed
  , disabledWhen
  , systemAppearance

    -- * Focus and clipboard
  , holdFocus
  , releaseFocus
  , focusedWidget
  , requestFocus
  , focusNext
  , focusPrevious
  , clearFocus
  , isFocused
  , getClipboard
  , setClipboard

    -- * Host

    -- | A 'Host' is a typed slot that holds one value or none, for the UI
    -- thread: 'setHost' installs the value and 'askHost' reads it in a view.
  , Host
  , newHost
  , setHost
  , askHost

    -- * Scrolling
  , getScrollTuning
  , setScrollTuning
  , getScrollMetrics
  , setScrollOffset
  , scrollTo
  , scrollBy
  , scrollPages
  , scrollToStart
  , scrollToEnd
  , scrollIntoView
  , scrollRectIntoView
  , setScrollStep

    -- * Redraw and damage
  , requestFrame
  , DamageBounds (..)
  , damageWidgetNow
  , damageKeyNow
  , damageRectNow
  , damageGroupNow
  , damageFullNow

    -- * Monadic helpers
  , whenM
  , unlessM
  , ifM
  , (<&&>)
  )
where

import NanoUI.Internal.Context (Context)
import NanoUI.Internal.Monad
import NanoUI.Internal.Host (Host, newHost, setHost)
import NanoUI.Internal.Types (DamageBounds (..))