module Data.Text.ParagraphLayout.Internal.Line (Line (..), shiftLine)
where
import Data.Int (Int32)
import Data.Text.ParagraphLayout.Internal.Rect
-- | Information about a line in a laid out paragraph.
data Line = Line
{ lineNumber :: Int
-- ^ Logical number of the line box, starting at 1 for a given paragraph.
, lineRect :: Rect Int32
-- ^ Dimensions of the line box (CSS), containing all fragments on a given
-- line, and matching the width of the whole paragraph.
}
deriving (Eq, Read, Show)
-- | Add @dx@ and @dy@ to the line's `x_origin` and `y_origin`,
-- respectively.
shiftLine :: Int32 -> Int32 -> Line -> Line
shiftLine dx dy l = l'
where
l' = l { lineRect = r' }
r' = r { x_origin = x_origin r + dx, y_origin = y_origin r + dy }
r = lineRect l