fltkhs-themes-0.2.0.0: A set of themed widgets that provides drop in replacements to the ones in FLTKHS.

Graphics.UI.FLTK.Theme.Light.Common

Synopsis

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

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

Return the Position which centers the given Size in Rectangle.

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.

pi/180

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.

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 WidgetBase => Ref a -> IO (Maybe (Ref b)) -> IO Bool Source #

Check if the given references point to the same Widget.

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

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.

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.

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.

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.

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.

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 draw on its parent. For an example use-case see inputDraw.

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

Specifies how to draw a border around a Rectangle.

Constructors

 BorderBoxSpec FieldsborderBoxBounds :: RectangleThe bounds of the rectangle to borderborderBoxFocusedColor :: ColorThe color of the border if the widget is focusedborderBoxHoveringColor :: ColorThe color of the border if the mouse pointer is over the widgetborderBoxColor :: ColorThe default color of the borderborderBoxFillColor :: ColorThe fill color of the rectangle. Even though FillSpec exists this is useful if you want a simple solid color and don't care about gradients.
Instances
 Source # Instance detailsDefined in Graphics.UI.FLTK.Theme.Light.Common MethodsshowList :: [BorderBoxSpec] -> ShowS #

drawBorderBox :: Parent a WidgetBase => 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 FieldsfillBounds :: RectangleThe bounds of the rectangle to be filledfillTopColor :: ColorThe color at the top of the rectanglefillTopSelectionColor :: ColorThe color at the top of the rectangle if this widget is selected (mostly of use to buttons)fillTopFillPercentage :: IntThe % of the rectangle at that top that is filled with fillTopColor before the gradient beginsfillBottomColor :: ColorThe color at the bottom of the rectanglefillBottomSelectionColor :: ColorThe color at the bottom of the rectangle if this widget is selected (mostly of use to buttons)fillBottomFillPercentage :: IntThe % of the rectangle at the bottom that is filled with fillBottomColor after the gradient endsfillCornerRadius :: IntThe roundedness of the cornersfillBorderColor :: ColorThe border color of this rectanglefillBorderFocusColor :: ColorThe border color of this rectangle if it is focusedfillBorderHovered :: ColorThe border color of this rectangle if the mouse is over it

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.

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 :: (orig ~ a b, Parent orig WidgetBase, Match x ~ FindOp orig orig (Redraw ()), Op (Redraw ()) x orig (IO ())) => 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. It also takes this widget's default handle so it can be called for events that don't apply to hovering, eg. Show, Hide etc.

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

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.