fltkhs-themes-0.1.0.1

Safe HaskellNone
LanguageHaskell2010

Graphics.UI.FLTK.Theme.Light

Contents

Description

A Light theme for FLTKHS.

Synopsis

Motivation

This package tries to make it easy to write nice consistent-looking FLTKHS applications by providing drop-in light themed replacement widgets to the standard ones with minimal performance and memory overhead. While FLTK itself has very good performance and memory usage the default look of the widgets is quite dated; this package aims to bridge that gap by providing a more modern interface while retaining the responsiveness.

NOTE: This is not a theme in the same sense as CSS; the look is achieved simply providing a custom drawing routine for each widget.

Inspiration

The Light theme is massively indebted to and steals shamelessly from the excellent Qooxdoo project which manages to create a very slick interface which is at the same time production-grade and easy to understand and use.

Installation

Installation follows the same basic procedure as FLTKHS. The only difference is that those instructions use the default hello world skeleton whereas for themed UIs you'll want the themed skeleton, so wherever the original instructions tell you to use the default skeleton use the latter instead. And to run it, instead of:

> stack exec fltkhs-hello-world

do

> stack exec fltkhs-light-theme-skeleton

Getting Started

The underlying widget API has not been touched so all of the existing FLTK and FLTKHS documentation still applies which makes switching over from an existing codebase, not entirely but mostly, frictionless.

The simplest app skeleton to get started with this theme is as follows:

{-# LANGUAGE ImplicitParams #-}      -- (1)
module Main where
...
import Graphics.UI.FLTK.Theme.Light  -- (2)
...
main :: IO ()
main = do
  assets <- configureTheme           -- (3)
  let ?assets = assets               -- (3)
  ui
  FL.run
  FL.flush

ui :: (?assets :: Assets) => IO ()   -- (4)
ui = ...

It involves only (1) enabling the ImplicitParams extension, (2) importing this module (3) doing some minor setup before the actual app code and (4) threading the implicit constraint to whatever function uses this theme. Graphics.UI.FLTK.Theme.Light.Assets has more information.

The ImplicitParams requirement is so that widgets have access to the resources needed by this theme (icons, images, fonts etc.). See Graphics.UI.FLTK.Theme.Light.Assets for more information.

Running In the REPL

Assuming you're using the skeleton project getting a GUI running in GHCi is pretty much the same FLTKHS except the command to run the REPL is:

stack ghci --flag fltkhs:bundled fltkhs-light-theme-skeleton:exe:fltkhs-light-theme-skeleton

Deployment

This package bundles a lot of local assets, images and especially fonts so deploying a themed application is not as simple as just adding an executable file to your path. To help with this the skeleton project uses the asset-bundle package to create a ZIP archive of all the assets the application needs at runtime. The package docs have a lot more info but in a nutshell when you build the skeletop app a ZIP archive, fltkhs-light-theme-skeleton_bundled.zip, is generated for you and placed deep inside your .stack-work (or dist-new if you're using Cabal) directory. It contains all the assets and a runner script (run.sh on Linux and OSX and run.bat on Windows) which invokes the executable, passes along all command line arguments and sets up the environment so it can find the assets at runtime.

Demo

In addition to the skeleton project there is a also a small but steadily growing showcase app that gives a better idea of the look-and-feel of this theme. More will be added as time permits.

What's Missing

While most of the widgets and functionality in FLTKHS have and themed analogs but some do not mostly because, in my view, they don't fit into app development much nowadays and so weren't worth porting. If there's a pressing need let me know.

  • Fill and Nice Sliders - here they fallback to the slider provided by the theme.
  • FLTK's Pre-Made Modal Dialogs
  • FLTK's Square Clock
  • Fluid integration - FLTK ships with FLUID GUI builder and the default FLTKHS integrates with it quite well but currently there is no support for using it to create themed apps. This is definitely on the roadmap and should be resolved in the near future.

Assets

The resources bundled with the theme, see the module documentation for more information.

Banners

Some banners

Themed Widgets

Haddock barf

There is no reason to read anything below, this module hides the default widgets it overrides and then re-exports what it doesn't. The re-exported module from FLTKHS in turn re-exports modules from that package. Instead of just showing the exported module as a link Haddock insists on flattening and barfing out all of its contents here. Sorry, didn't know how to get around it.

wizardCustom #

Arguments

:: Rectangle

The bounds of this Wizard

-> Maybe Text

The Wizard label

-> Maybe (Ref Wizard -> IO ())

Optional custom drawing function

-> Maybe (CustomWidgetFuncs Wizard)

Optional custom widget functions

-> IO (Ref Wizard) 

doubleWindowCustom #

Arguments

:: Size

Size of this window

-> Maybe Position

Optional position of this window

-> Maybe Text

Optional label

-> Maybe (Ref DoubleWindow -> IO ())

Optional table drawing routine

-> CustomWidgetFuncs DoubleWindow

Custom widget overrides

-> CustomWindowFuncs DoubleWindow

Custom window overrides

-> IO (Ref DoubleWindow) 

singleWindowCustom #

Arguments

:: Size

Size of this window

-> Maybe Position

Optional position of this window

-> Maybe Text

Optional label

-> Maybe (Ref SingleWindow -> IO ())

Optional custom drawing function

-> CustomWidgetFuncs SingleWindow

Custom widget overrides

-> CustomWindowFuncs SingleWindow

Custom window overrides

-> IO (Ref SingleWindow) 

windowCustom #

Arguments

:: Size

Size of this window

-> Maybe Position

Optional position of this window

-> Maybe Text

Optional label

-> Maybe (Ref Window -> IO ())

Optional table drawing routine

-> CustomWidgetFuncs Window

Custom widget overrides

-> CustomWindowFuncs Window

Custom window overrides

-> IO (Ref Window) 

windowMaker :: (Parent a Window, Parent b Widget) => Size -> Maybe Position -> Maybe Text -> Maybe (Ref b -> IO ()) -> CustomWidgetFuncs b -> CustomWindowFuncs a -> (Int -> Int -> Ptr () -> IO (Ptr ())) -> (Int -> Int -> Text -> Ptr () -> IO (Ptr ())) -> (Int -> Int -> Int -> Int -> Ptr () -> IO (Ptr ())) -> (Int -> Int -> Int -> Int -> Text -> Ptr () -> IO (Ptr ())) -> IO (Ref a) #

data CustomWindowFuncs a #

Constructors

CustomWindowFuncs 

Fields

adjusterCustom #

Arguments

:: Rectangle

The bounds of this Adjuster

-> Maybe Text

The Adjuster label

-> Maybe (Ref Adjuster -> IO ())

Optional custom drawing function

-> Maybe (CustomWidgetFuncs Adjuster)

Optional custom widget functions

-> IO (Ref Adjuster) 

boxCustom #

Arguments

:: Rectangle

The bounds of this box

-> Maybe Text

Optional label

-> Maybe (Ref Box -> IO ())

Optional custom box drawing function

-> Maybe (CustomWidgetFuncs Box)

Optional widget overrides

-> IO (Ref Box) 

buttonCustom #

Arguments

:: Rectangle

The bounds of this button

-> Maybe Text

The button label

-> Maybe (Ref Button -> IO ())

Optional custom drawing function

-> Maybe (CustomWidgetFuncs Button)

Optional custom widget functions

-> IO (Ref Button) 

checkButtonCustom #

Arguments

:: Rectangle

The bounds of this CheckButton

-> Maybe Text

The CheckButton label

-> Maybe (Ref CheckButton -> IO ())

Optional custom drawing function

-> Maybe (CustomWidgetFuncs CheckButton)

Optional custom widget functions

-> IO (Ref CheckButton) 

choiceCustom #

Arguments

:: Rectangle

The bounds of this Choice

-> Maybe Text

The Choice label

-> Maybe (Ref Choice -> IO ())

Optional custom drawing function

-> Maybe (CustomWidgetFuncs Choice)

Optional custom widget functions

-> IO (Ref Choice) 

clockCustom #

Arguments

:: Rectangle

The bounds of this Clock

-> Maybe Text

The Clock label

-> Maybe (Ref Clock -> IO ())

Optional custom drawing function

-> Maybe (CustomWidgetFuncs Clock)

Optional custom widget functions

-> IO (Ref Clock) 

newtype Hour #

Constructors

Hour Int