{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MediaLive.Types.CaptionRectangle
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.CaptionRectangle where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Caption Rectangle
--
-- /See:/ 'newCaptionRectangle' smart constructor.
data CaptionRectangle = CaptionRectangle'
  { -- | See the description in leftOffset. For topOffset, specify the position
    -- of the top edge of the rectangle, as a percentage of the underlying
    -- frame height, and relative to the top edge of the frame. For example,
    -- \\\"10\\\" means the measurement is 10% of the underlying frame height.
    -- The rectangle top edge starts at that position from the top edge of the
    -- frame. This field corresponds to tts:origin - Y in the TTML standard.
    CaptionRectangle -> Double
topOffset :: Prelude.Double,
    -- | See the description in leftOffset. For height, specify the entire height
    -- of the rectangle as a percentage of the underlying frame height. For
    -- example, \\\"80\\\" means the rectangle height is 80% of the underlying
    -- frame height. The topOffset and rectangleHeight must add up to 100% or
    -- less. This field corresponds to tts:extent - Y in the TTML standard.
    CaptionRectangle -> Double
height :: Prelude.Double,
    -- | See the description in leftOffset. For width, specify the entire width
    -- of the rectangle as a percentage of the underlying frame width. For
    -- example, \\\"80\\\" means the rectangle width is 80% of the underlying
    -- frame width. The leftOffset and rectangleWidth must add up to 100% or
    -- less. This field corresponds to tts:extent - X in the TTML standard.
    CaptionRectangle -> Double
width :: Prelude.Double,
    -- | Applies only if you plan to convert these source captions to EBU-TT-D or
    -- TTML in an output. (Make sure to leave the default if you don\'t have
    -- either of these formats in the output.) You can define a display
    -- rectangle for the captions that is smaller than the underlying video
    -- frame. You define the rectangle by specifying the position of the left
    -- edge, top edge, bottom edge, and right edge of the rectangle, all within
    -- the underlying video frame. The units for the measurements are
    -- percentages. If you specify a value for one of these fields, you must
    -- specify a value for all of them. For leftOffset, specify the position of
    -- the left edge of the rectangle, as a percentage of the underlying frame
    -- width, and relative to the left edge of the frame. For example,
    -- \\\"10\\\" means the measurement is 10% of the underlying frame width.
    -- The rectangle left edge starts at that position from the left edge of
    -- the frame. This field corresponds to tts:origin - X in the TTML
    -- standard.
    CaptionRectangle -> Double
leftOffset :: Prelude.Double
  }
  deriving (CaptionRectangle -> CaptionRectangle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CaptionRectangle -> CaptionRectangle -> Bool
$c/= :: CaptionRectangle -> CaptionRectangle -> Bool
== :: CaptionRectangle -> CaptionRectangle -> Bool
$c== :: CaptionRectangle -> CaptionRectangle -> Bool
Prelude.Eq, ReadPrec [CaptionRectangle]
ReadPrec CaptionRectangle
Int -> ReadS CaptionRectangle
ReadS [CaptionRectangle]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CaptionRectangle]
$creadListPrec :: ReadPrec [CaptionRectangle]
readPrec :: ReadPrec CaptionRectangle
$creadPrec :: ReadPrec CaptionRectangle
readList :: ReadS [CaptionRectangle]
$creadList :: ReadS [CaptionRectangle]
readsPrec :: Int -> ReadS CaptionRectangle
$creadsPrec :: Int -> ReadS CaptionRectangle
Prelude.Read, Int -> CaptionRectangle -> ShowS
[CaptionRectangle] -> ShowS
CaptionRectangle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CaptionRectangle] -> ShowS
$cshowList :: [CaptionRectangle] -> ShowS
show :: CaptionRectangle -> String
$cshow :: CaptionRectangle -> String
showsPrec :: Int -> CaptionRectangle -> ShowS
$cshowsPrec :: Int -> CaptionRectangle -> ShowS
Prelude.Show, forall x. Rep CaptionRectangle x -> CaptionRectangle
forall x. CaptionRectangle -> Rep CaptionRectangle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CaptionRectangle x -> CaptionRectangle
$cfrom :: forall x. CaptionRectangle -> Rep CaptionRectangle x
Prelude.Generic)

-- |
-- Create a value of 'CaptionRectangle' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'topOffset', 'captionRectangle_topOffset' - See the description in leftOffset. For topOffset, specify the position
-- of the top edge of the rectangle, as a percentage of the underlying
-- frame height, and relative to the top edge of the frame. For example,
-- \\\"10\\\" means the measurement is 10% of the underlying frame height.
-- The rectangle top edge starts at that position from the top edge of the
-- frame. This field corresponds to tts:origin - Y in the TTML standard.
--
-- 'height', 'captionRectangle_height' - See the description in leftOffset. For height, specify the entire height
-- of the rectangle as a percentage of the underlying frame height. For
-- example, \\\"80\\\" means the rectangle height is 80% of the underlying
-- frame height. The topOffset and rectangleHeight must add up to 100% or
-- less. This field corresponds to tts:extent - Y in the TTML standard.
--
-- 'width', 'captionRectangle_width' - See the description in leftOffset. For width, specify the entire width
-- of the rectangle as a percentage of the underlying frame width. For
-- example, \\\"80\\\" means the rectangle width is 80% of the underlying
-- frame width. The leftOffset and rectangleWidth must add up to 100% or
-- less. This field corresponds to tts:extent - X in the TTML standard.
--
-- 'leftOffset', 'captionRectangle_leftOffset' - Applies only if you plan to convert these source captions to EBU-TT-D or
-- TTML in an output. (Make sure to leave the default if you don\'t have
-- either of these formats in the output.) You can define a display
-- rectangle for the captions that is smaller than the underlying video
-- frame. You define the rectangle by specifying the position of the left
-- edge, top edge, bottom edge, and right edge of the rectangle, all within
-- the underlying video frame. The units for the measurements are
-- percentages. If you specify a value for one of these fields, you must
-- specify a value for all of them. For leftOffset, specify the position of
-- the left edge of the rectangle, as a percentage of the underlying frame
-- width, and relative to the left edge of the frame. For example,
-- \\\"10\\\" means the measurement is 10% of the underlying frame width.
-- The rectangle left edge starts at that position from the left edge of
-- the frame. This field corresponds to tts:origin - X in the TTML
-- standard.
newCaptionRectangle ::
  -- | 'topOffset'
  Prelude.Double ->
  -- | 'height'
  Prelude.Double ->
  -- | 'width'
  Prelude.Double ->
  -- | 'leftOffset'
  Prelude.Double ->
  CaptionRectangle
newCaptionRectangle :: Double -> Double -> Double -> Double -> CaptionRectangle
newCaptionRectangle
  Double
pTopOffset_
  Double
pHeight_
  Double
pWidth_
  Double
pLeftOffset_ =
    CaptionRectangle'
      { $sel:topOffset:CaptionRectangle' :: Double
topOffset = Double
pTopOffset_,
        $sel:height:CaptionRectangle' :: Double
height = Double
pHeight_,
        $sel:width:CaptionRectangle' :: Double
width = Double
pWidth_,
        $sel:leftOffset:CaptionRectangle' :: Double
leftOffset = Double
pLeftOffset_
      }

-- | See the description in leftOffset. For topOffset, specify the position
-- of the top edge of the rectangle, as a percentage of the underlying
-- frame height, and relative to the top edge of the frame. For example,
-- \\\"10\\\" means the measurement is 10% of the underlying frame height.
-- The rectangle top edge starts at that position from the top edge of the
-- frame. This field corresponds to tts:origin - Y in the TTML standard.
captionRectangle_topOffset :: Lens.Lens' CaptionRectangle Prelude.Double
captionRectangle_topOffset :: Lens' CaptionRectangle Double
captionRectangle_topOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionRectangle' {Double
topOffset :: Double
$sel:topOffset:CaptionRectangle' :: CaptionRectangle -> Double
topOffset} -> Double
topOffset) (\s :: CaptionRectangle
s@CaptionRectangle' {} Double
a -> CaptionRectangle
s {$sel:topOffset:CaptionRectangle' :: Double
topOffset = Double
a} :: CaptionRectangle)

-- | See the description in leftOffset. For height, specify the entire height
-- of the rectangle as a percentage of the underlying frame height. For
-- example, \\\"80\\\" means the rectangle height is 80% of the underlying
-- frame height. The topOffset and rectangleHeight must add up to 100% or
-- less. This field corresponds to tts:extent - Y in the TTML standard.
captionRectangle_height :: Lens.Lens' CaptionRectangle Prelude.Double
captionRectangle_height :: Lens' CaptionRectangle Double
captionRectangle_height = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionRectangle' {Double
height :: Double
$sel:height:CaptionRectangle' :: CaptionRectangle -> Double
height} -> Double
height) (\s :: CaptionRectangle
s@CaptionRectangle' {} Double
a -> CaptionRectangle
s {$sel:height:CaptionRectangle' :: Double
height = Double
a} :: CaptionRectangle)

-- | See the description in leftOffset. For width, specify the entire width
-- of the rectangle as a percentage of the underlying frame width. For
-- example, \\\"80\\\" means the rectangle width is 80% of the underlying
-- frame width. The leftOffset and rectangleWidth must add up to 100% or
-- less. This field corresponds to tts:extent - X in the TTML standard.
captionRectangle_width :: Lens.Lens' CaptionRectangle Prelude.Double
captionRectangle_width :: Lens' CaptionRectangle Double
captionRectangle_width = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionRectangle' {Double
width :: Double
$sel:width:CaptionRectangle' :: CaptionRectangle -> Double
width} -> Double
width) (\s :: CaptionRectangle
s@CaptionRectangle' {} Double
a -> CaptionRectangle
s {$sel:width:CaptionRectangle' :: Double
width = Double
a} :: CaptionRectangle)

-- | Applies only if you plan to convert these source captions to EBU-TT-D or
-- TTML in an output. (Make sure to leave the default if you don\'t have
-- either of these formats in the output.) You can define a display
-- rectangle for the captions that is smaller than the underlying video
-- frame. You define the rectangle by specifying the position of the left
-- edge, top edge, bottom edge, and right edge of the rectangle, all within
-- the underlying video frame. The units for the measurements are
-- percentages. If you specify a value for one of these fields, you must
-- specify a value for all of them. For leftOffset, specify the position of
-- the left edge of the rectangle, as a percentage of the underlying frame
-- width, and relative to the left edge of the frame. For example,
-- \\\"10\\\" means the measurement is 10% of the underlying frame width.
-- The rectangle left edge starts at that position from the left edge of
-- the frame. This field corresponds to tts:origin - X in the TTML
-- standard.
captionRectangle_leftOffset :: Lens.Lens' CaptionRectangle Prelude.Double
captionRectangle_leftOffset :: Lens' CaptionRectangle Double
captionRectangle_leftOffset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CaptionRectangle' {Double
leftOffset :: Double
$sel:leftOffset:CaptionRectangle' :: CaptionRectangle -> Double
leftOffset} -> Double
leftOffset) (\s :: CaptionRectangle
s@CaptionRectangle' {} Double
a -> CaptionRectangle
s {$sel:leftOffset:CaptionRectangle' :: Double
leftOffset = Double
a} :: CaptionRectangle)

instance Data.FromJSON CaptionRectangle where
  parseJSON :: Value -> Parser CaptionRectangle
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CaptionRectangle"
      ( \Object
x ->
          Double -> Double -> Double -> Double -> CaptionRectangle
CaptionRectangle'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"topOffset")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"height")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"width")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"leftOffset")
      )

instance Prelude.Hashable CaptionRectangle where
  hashWithSalt :: Int -> CaptionRectangle -> Int
hashWithSalt Int
_salt CaptionRectangle' {Double
leftOffset :: Double
width :: Double
height :: Double
topOffset :: Double
$sel:leftOffset:CaptionRectangle' :: CaptionRectangle -> Double
$sel:width:CaptionRectangle' :: CaptionRectangle -> Double
$sel:height:CaptionRectangle' :: CaptionRectangle -> Double
$sel:topOffset:CaptionRectangle' :: CaptionRectangle -> Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
topOffset
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
height
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
width
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
leftOffset

instance Prelude.NFData CaptionRectangle where
  rnf :: CaptionRectangle -> ()
rnf CaptionRectangle' {Double
leftOffset :: Double
width :: Double
height :: Double
topOffset :: Double
$sel:leftOffset:CaptionRectangle' :: CaptionRectangle -> Double
$sel:width:CaptionRectangle' :: CaptionRectangle -> Double
$sel:height:CaptionRectangle' :: CaptionRectangle -> Double
$sel:topOffset:CaptionRectangle' :: CaptionRectangle -> Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Double
topOffset
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
height
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
width
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
leftOffset

instance Data.ToJSON CaptionRectangle where
  toJSON :: CaptionRectangle -> Value
toJSON CaptionRectangle' {Double
leftOffset :: Double
width :: Double
height :: Double
topOffset :: Double
$sel:leftOffset:CaptionRectangle' :: CaptionRectangle -> Double
$sel:width:CaptionRectangle' :: CaptionRectangle -> Double
$sel:height:CaptionRectangle' :: CaptionRectangle -> Double
$sel:topOffset:CaptionRectangle' :: CaptionRectangle -> Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"topOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
topOffset),
            forall a. a -> Maybe a
Prelude.Just (Key
"height" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
height),
            forall a. a -> Maybe a
Prelude.Just (Key
"width" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
width),
            forall a. a -> Maybe a
Prelude.Just (Key
"leftOffset" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
leftOffset)
          ]
      )