fltkhs-themes-0.1.0.1

Safe HaskellNone
LanguageHaskell2010

Graphics.UI.FLTK.Theme.Light.Common

Contents

Synopsis

Theme Loading

configureTheme :: IO Assets Source #

Needs to be called by every app to load the themes's resources and do some minor setup See Graphics.UI.FLTK.Theme.Light for more information.

Common Colors & Fonts

commonFont :: (?assets :: Assets) => Font Source #

Common Calculations For Drawing Widgets

angleToCoordinate :: PreciseAngle -> PrecisePosition Source #

Given a PreciseAngle in degrees return the corresponding location on the unit circle

centerInRectangle :: Rectangle -> Size -> Position Source #

Return the Position which centers the given Size in Rectangle.

centerInRectangleByRelativePosition :: Rectangle -> X -> Y -> Rectangle Source #

Return the Rectangle that is centered in the given Rectangle by the X and Y offset , so for example, (X 20) (Y 20) returns a Rectangle with a top left coordinate which is 20 pixels over and 20 pixels below the top left of the given Rectangle.

fromFltkAngle :: PreciseAngle -> PreciseAngle Source #

Converts from an FLTK angle to a unit circle's. FLTK starts its angles counter-clockwise from 270 so, for example, 45 degrees in FLTK is 270-45 = 225 degrees on a unit circle. Angle unit is in degrees.

insideRectangle :: Position -> Rectangle -> Bool Source #

Check if the given Position is inside the Rectangle. Useful for checking if an event happened within some bounds.

intDiv :: Int -> Int -> Int Source #

A lossy division of 'Int'/'Int'. The result is truncated but it's good enough for widget dimensions which is the primary use-case.

isWidget :: Parent a Widget => Ref a -> IO (Maybe (Ref b)) -> IO Bool Source #

Check if the given references point to the same Widget.

percentOf :: Double -> Int -> Int Source #

Straightfoward % of the given Int, the Double % must be between 0.0 and 1.0

percentOfSmallerEllipseRadius :: Double -> PreciseSize -> Double Source #

Given the width and height of an ellipse via PreciseSize, return the Double % of the smaller radius. % must be between 0.0 and 1.0. Used in Dials and Clocks to measure the length of hands.

positionInside :: Rectangle -> Size -> X -> Y -> Rectangle Source #

Return a Rectangle of Size positioned at X and Y inside the given Rectangle. It's on the caller to make sure that the resulting Rectangle actually fits inside the one passed in. Size, X and Y are not checked.

splitVertically :: Rectangle -> Double -> (Rectangle, Rectangle) Source #

Split the width of the Rectangle into two side-by-side (Rectangle,Rectangle) by the Double %. % must be between 0.0 and 1.0. The width of the 2 returned rectangles will always sum to the width of the one passed in.

splitVerticallyByPixels :: Rectangle -> Int -> (Rectangle, Rectangle) Source #

Like splitVertically but takes a Int pixel width instead of a %. If the width is greater than the Rectangle the first of the pair will be the Rectangle passed in and the second will have the same dimensions but a 0 width.

splitHorizontally :: Rectangle -> Double -> (Rectangle, Rectangle) Source #

Split the height of the Rectangle into two stacked (Rectangle,Rectangle) by the Double %. % must be between 0.0 and 1.0. The height of the 2 returned rectangles will always sum to the height of the one passed in.

splitHorizontallyByPixels :: Rectangle -> Int -> (Rectangle, Rectangle) Source #

Like splitHorizontally but takes a Int pixel height instead of a %. If the height is greater than the Rectangle the first of the pair will be the Rectangle passed in and the second will have the same dimensions but a 0 height.

withPositionX :: Position -> (X -> X) -> Position Source #

Transform the X coordinate of a location

withPositionY :: Position -> (Y -> Y) -> Position Source #

Transform the Y coordinate of a location

withSizeHeight :: Size -> (Height -> Height) -> Size Source #

Transform the height.

withSizeWidth :: Size -> (Width -> Width) -> Size Source #

Transform the width.

Common Widget Drawing Helpers

withCustomBoxDraw :: Boxtype -> BoxDrawF -> IO () -> IO () Source #

Temporarily swap out the FLTK's box drawing function for a given Boxtype with BoxDrawF. The IO '()' action will typically use the custom function that was just swapped in some kind custom drawing routine. For example, if a custom widget used a BorderBox on the FLTK side but you don't like the default BorderBox look, you can override the draw function of the widget with this one where the IO '()' action calls drawSuper. For an example use-case see inputDraw.

NOTE: The IO '()' action is not exception safe.

data BorderBoxSpec Source #

Specifies how to draw a border around a Rectangle.

Constructors

BorderBoxSpec 

Fields

drawBorderBox :: Parent a Widget => Ref a -> BorderBoxSpec -> Bool -> IO () Source #

Draw a bordered rectangle for the given widget according to BorderBoxSpec, the Bool determines if it should be filled with borderBoxFillColor.

data FillSpec Source #

Specifies how a Rectangle should be filled. Allows for a vertical color gradient.

Constructors

FillSpec 

Fields

makeFillSpec :: Rectangle -> Color -> Color -> IO FillSpec Source #

Make the default FillSpec used by most of the theme color graded with the initial Color. The second Color is used to determine the border color.

borderRectangle :: FillSpec -> Bool -> Bool -> IO () Source #

Draw the border around the Rectangle specified by FillSpec possibly changing the border color if the widget (usually a Button) is currently focused or if the mouse pointer is hovering over it.

fillRectangle :: FillSpec -> Bool -> IO () Source #

Draw a box according to the FillSpec. It was originally intended for custom Graphics.UI.FLTK.Theme.Light.Button which is why it takes a Bool specifies if the button is pressed but is used widely in the theme for any rounded rectangular area.

handleHover :: (Parent orig Widget, Match x ~ FindOp orig orig (Redraw ()), Op (Redraw ()) x orig (IO ()), Match y ~ FindOp orig orig (HandleSuper ()), Op (HandleSuper ()) y orig (Event -> IO (Either UnknownEvent ()))) => Ref orig -> Event -> IO (Either UnknownEvent ()) Source #

The default FLTK widgets don't react to a mouse pointer hovering over them. This handler when applied to a customized widget initiates a redraw when the mouse enters and leaves the widget area.

data OpenBorder Source #

For drawing a rectangular widget that is borderless on the top or bottom. Guess it could be passed into a function as yet another Bool but we have too many of those as it is.

Constructors

OpenBorderTop

Signifies a bordered rectangle with the top side. Useful, for example, for a bottom tab

OpenBorderBottom

Signifies a bordered rectangle without a bottom side. Useful, for example, for a top tab

roundedBoxPoints :: Rectangle -> Maybe Int -> Maybe OpenBorder -> [Position] Source #

Return a set of vertices that circumscribe a region bounded by Rectangle. The Maybe Int when provided means the rectangle has rounded corners of Int radius. In a rounded rectangle the vertices don't meet stopping short of the corners, the client is responsible for filling in the arcs.

Maybe OpenBorder determines whether the rectangle is whole (if not provided) or has an open top or bottom.