~jaro/balkon

6cf2c7c1029689145011c1836ec519a485b7f088 — Jaro 1 year, 2 months ago c3170a2
Use Rect in "plain" interface.
1 files changed, 24 insertions(+), 23 deletions(-)

M src/Data/Text/ParagraphLayout/Plain.hs
M src/Data/Text/ParagraphLayout/Plain.hs => src/Data/Text/ParagraphLayout/Plain.hs +24 -23
@@ 28,6 28,8 @@ import Data.Text.Foreign (I8)
import Data.Text.Glyphize (Font, GlyphInfo, GlyphPos)
import Data.Text.Internal (Text(Text))

import Data.Text.ParagraphLayout.Rect

-- | Text to be laid out as a paragraph.
--
-- May be divided into any number of neighbouring spans, each of which will


@@ 84,31 86,30 @@ data ParagraphLayout = ParagraphLayout

-- | The resulting layout of each span, which may include multiple bounding
-- boxes if broken over multiple lines.
data SpanLayout = SpanLayout [(Rect Int32, [(GlyphInfo, GlyphPos)])]
data SpanLayout = SpanLayout [Box]
    deriving (Eq, Read, Show)

-- | Rectangle containing all glyph advances in the paragraph or corresponding
-- span. This is the space that the glyphs "take up" and is probably what you
-- want to use for detecting position-based events such as mouse clicks.
--
-- Beware that actual glyphs will not be drawn exactly to the borders of this
-- rectangle -- they may be offset inwards and they can also extend outwards!
-- These are not the typographic bounding boxes that you use for determining
-- the area to draw on -- you need FreeType or a similar library for that.
--
-- The origin coordinates are relative to the paragraph.
--
-- The sizes can be positive or negative, depending on the text direction.
--
-- X coordinates increase from left to right.
-- Y coordinates increase from bottom to top.
data Rect a = Rect
    { x_origin :: a
    , y_origin :: a
    , x_size :: a
    , y_size :: a
    }
    deriving (Eq, Read, Show)
type Box =
    ( Rect Int32
    -- ^ Rectangle containing all glyph advances in this box. This is the space
    -- that the glyphs "take up" and is probably what you want to use for
    -- detecting position-based events such as mouse clicks.
    --
    -- Beware that actual glyphs will not be drawn exactly to the borders of
    -- this rectangle -- they may be offset inwards and they can also extend
    -- outwards!
    --
    -- These are not the typographic bounding boxes that you use for determining
    -- the area to draw on -- you need FreeType or a similar library for that.
    --
    -- The origin coordinates are relative to the paragraph.
    --
    -- The sizes can be positive or negative, depending on the text direction.
    --
    -- X coordinates increase from left to right.
    -- Y coordinates increase from bottom to top.
    , [(GlyphInfo, GlyphPos)]
    )

-- | Interface for basic plain text layout.
--