FULE-0.3.1: Functional UI Layout Engine
Copyright(c) Paul Schnapp 2023
LicenseBSD3
MaintainerPaul Schnapp <paul.schnapp@gmail.com>
Safe HaskellSafe-Inferred
LanguageHaskell2010

FULE.Layout

Description

This is the basic, low-level layout functionality.

You'll start by creating a LayoutDesign and then make a usable Layout from it by building it.

Synopsis

Documentation

data LayoutDesign Source #

A Layout that is still under construction. Use the build function to turn a LayoutDesign into an elivened Layout.

Instances

Instances details
NFData LayoutDesign Source # 
Instance details

Defined in FULE.Layout

Methods

rnf :: LayoutDesign -> () #

data GuideID Source #

An identifier for a Guide in a Layout or LayoutDesign.

Instances

Instances details
Read GuideID Source # 
Instance details

Defined in FULE.Layout

Show GuideID Source # 
Instance details

Defined in FULE.Layout

NFData GuideID Source # 
Instance details

Defined in FULE.Layout

Methods

rnf :: GuideID -> () #

Eq GuideID Source # 
Instance details

Defined in FULE.Layout

Methods

(==) :: GuideID -> GuideID -> Bool #

(/=) :: GuideID -> GuideID -> Bool #

Ord GuideID Source # 
Instance details

Defined in FULE.Layout

data PlasticDependencyType Source #

The type of a plastic dependency between two Guides.

Constructors

Asymmetric

Specifies that changes to the dependent Guide do not affect the reference Guide, but changes to the reference propagate to the dependent Guide.

Symmetric

Specifies that changes to either Guide are applied to the other as well.

data GuideSpecification Source #

The specification of a Guide to be added to a LayoutDesign. A Guide may be added:

  • at an absolute position within the design
  • relative to a reference Guide within the design with a plastic dependencey upon the reference
  • relative to two reference Guides within the design with an elastic dependency upon both

See each constructor and its fields for more information.

Constructors

Absolute

Add a new Guide at an absolute position within the Layout.

Fields

  • positionOf :: Int

    The position the new Guide should have in the Layout. Note this could be either an x or y position, the axis doesn't matter for the specification.

Relative

Add a new Guide with a plastic dependence on a reference Guide.

Fields

Between

Add a new Guide between two other Guides with an elastic dependency on them: Whenever one of the reference Guides moves the dependent Guide will be moved to remain positioned relatively between them.

The Double arguments of the pairs below should sum to equal 1.0; this will not be checked.

Fields

  • (GuideID, Double)

    A reference Guide and how close the dependent Guide should be to it relative to the other reference, as a percentage.

  • (GuideID, Double)

    Another reference Guide and how close the dependent Guide should be to it relative to the first reference, as a percentage.

addGuide :: GuideSpecification -> LayoutDesign -> (GuideID, LayoutDesign) Source #

Add a new Guide to a LayoutDesign according to the given GuideSpecification.

Returns an ID for the new Guide along with an updated LayoutDesign.

data GuideConstraint Source #

The type of constraint one Guide should have relative to another.

Constructors

LTE

Constrain a Guide to be always less-than or equal-to another.

Fields

GTE

Constrain a Guide to be always greater-than or equal-to another.

Fields

Instances

Instances details
Show GuideConstraint Source # 
Instance details

Defined in FULE.Layout

Eq GuideConstraint Source # 
Instance details

Defined in FULE.Layout

addGuideConstraint :: GuideConstraint -> LayoutDesign -> LayoutDesign Source #

Constrain the movement of one Guide relative to another. (Still slightly experimental.)

Important Notes:

  • Never constrain a Guide against itself
  • A Guide should be used only once as the constrainee (first argument) for a given constraint-type
  • The above conditions will not be checked!
  • If a guide depends on multiple other guides that are simultaneously affected by constraints, things may go a bit wonky, just sayin'.

data Layout Source #

A LayoutDesign that has been enlivened and can have its Guides queried or moved.

Instances

Instances details
Show Layout Source # 
Instance details

Defined in FULE.Layout

NFData Layout Source # 
Instance details

Defined in FULE.Layout

Methods

rnf :: Layout -> () #

build :: LayoutDesign -> Layout Source #

Create an enlivened Layout from a LayoutDesign.

design :: Layout -> LayoutDesign Source #

Transform a Layout back into a LayoutDesign.

getGuide :: GuideID -> Layout -> Int Source #

Get the position of a Guide within a Layout.

getGuides :: [GuideID] -> Layout -> [Int] Source #

Get the position of multiple Guides within a Layout.

reactToChange Source #

Arguments

:: GuideID

The Guide to move.

-> Int

The movement to apply to the Guide -- a delta.

-> Layout 
-> Layout 

Move a Guide within a Layout.

reactToChanges Source #

Arguments

:: [(GuideID, Int)]

A list of Guides with movements (deltas) to apply to them.

-> Layout 
-> Layout 

Move multiple Guides within a Layout.