Safe Haskell | None |
---|---|
Language | Haskell2010 |
A module that allows access to the resources (fonts, images, etc.) bundled with this theme. Clients of this package should not need to directly include this module since Graphics.UI.FLTK.Theme.Light
re-exports it.
Synopsis
- data Assets
- loadAssets :: IO Assets
- dejaVuSans :: (?assets :: Assets) => Font
- josefinSlabSemiBold :: (?assets :: Assets) => Font
- yanoneKaffesatz :: (?assets :: Assets) => Font
- cancelButtonImage :: (?assets :: Assets) => Ref PNGImage
- downSmallImage :: (?assets :: Assets) => Ref PNGImage
- forwardImage :: (?assets :: Assets) => Ref PNGImage
- leftImage :: (?assets :: Assets) => Ref PNGImage
- okButtonImage :: (?assets :: Assets) => Ref PNGImage
- returnButtonImage :: (?assets :: Assets) => Ref PNGImage
- rewindImage :: (?assets :: Assets) => Ref PNGImage
- rightImage :: (?assets :: Assets) => Ref PNGImage
- upSmallImage :: (?assets :: Assets) => Ref PNGImage
Assets
Description & Usage
This module mediates access to fonts, images and whatever other data is needed
by this theme. To provide a consistent look-and-feel across platforms the theme
bundles whatever it needs and loads them when a user's app is started. The
loaded assets should not interfere with any other process thread. For example,
when a user's application starts up the dejaVuSansMono
font is loaded into the
font cache, but it should be isolated to the app's process.
To use the assets in an FLTK app you need to enable the ImplicitParams
pragma and then pass the Assets
implicit constraint to every function that
needs the resources:
{-# LANGUAGE ImplicitParams ...#-} ... myAwesomeUI :: (?assets :: Assets) => ... myAwesomeUI = do ... b <- buttonNew ... setLabelFont b dejaVuSansMono ...
For more extensive documentation on how to use assets in the context of a full application see Graphics.UI.FLTK.Theme.Light.
Why ImplicitParams?
ImplicitParams is a fairly contentious extension because of how it interacts with
recursion
and the dangers of accidental name-shadowing. The two alternatives are
Reader
and reflection. While both
are more principled the first requires all UI functions have a MonadReader
constraint which makes the API way uglier and harder to use, and the second
incurs a dependency on
template-haskell which
I also did not want. ImplicitParams are easier to use and have been in GHC
since 6.8.1 and since we're just threading through some fonts and images
hopefully the downsides won't become a big deal in practice.
An opaque type that contains all of the resources needed by this theme.
Getting to the resources requires threading something of the type as an implicit
parameter to the accessors below, eg. dejaVuSans
.
loadAssets :: IO Assets Source #
Used at app start time to load the resources of this theme into memory.
This should never be called directly, but through
configureTheme
which does some other
setup.
Fonts
The fonts required by this theme, all are TTF.
dejaVuSans :: (?assets :: Assets) => Font Source #
The standard font used for most labels, titles, output etc.
josefinSlabSemiBold :: (?assets :: Assets) => Font Source #
A nice banner font.
yanoneKaffesatz :: (?assets :: Assets) => Font Source #
Currently unused but a nice font around for the future ...