{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.CaptionRectangle where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(CaptionRectangle -> CaptionRectangle -> Bool)
-> (CaptionRectangle -> CaptionRectangle -> Bool)
-> Eq CaptionRectangle
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]
(Int -> ReadS CaptionRectangle)
-> ReadS [CaptionRectangle]
-> ReadPrec CaptionRectangle
-> ReadPrec [CaptionRectangle]
-> Read 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
(Int -> CaptionRectangle -> ShowS)
-> (CaptionRectangle -> String)
-> ([CaptionRectangle] -> ShowS)
-> Show CaptionRectangle
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. CaptionRectangle -> Rep CaptionRectangle x)
-> (forall x. Rep CaptionRectangle x -> CaptionRectangle)
-> Generic CaptionRectangle
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' :: Double -> Double -> Double -> Double -> CaptionRectangle
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 :: (Double -> f Double) -> CaptionRectangle -> f CaptionRectangle
captionRectangle_topOffset = (CaptionRectangle -> Double)
-> (CaptionRectangle -> Double -> CaptionRectangle)
-> Lens CaptionRectangle CaptionRectangle Double Double
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 :: (Double -> f Double) -> CaptionRectangle -> f CaptionRectangle
captionRectangle_height = (CaptionRectangle -> Double)
-> (CaptionRectangle -> Double -> CaptionRectangle)
-> Lens CaptionRectangle CaptionRectangle Double Double
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 :: (Double -> f Double) -> CaptionRectangle -> f CaptionRectangle
captionRectangle_width = (CaptionRectangle -> Double)
-> (CaptionRectangle -> Double -> CaptionRectangle)
-> Lens CaptionRectangle CaptionRectangle Double Double
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 :: (Double -> f Double) -> CaptionRectangle -> f CaptionRectangle
captionRectangle_leftOffset = (CaptionRectangle -> Double)
-> (CaptionRectangle -> Double -> CaptionRectangle)
-> Lens CaptionRectangle CaptionRectangle Double Double
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 Core.FromJSON CaptionRectangle where
  parseJSON :: Value -> Parser CaptionRectangle
parseJSON =
    String
-> (Object -> Parser CaptionRectangle)
-> Value
-> Parser CaptionRectangle
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CaptionRectangle"
      ( \Object
x ->
          Double -> Double -> Double -> Double -> CaptionRectangle
CaptionRectangle'
            (Double -> Double -> Double -> Double -> CaptionRectangle)
-> Parser Double
-> Parser (Double -> Double -> Double -> CaptionRectangle)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"topOffset")
            Parser (Double -> Double -> Double -> CaptionRectangle)
-> Parser Double -> Parser (Double -> Double -> CaptionRectangle)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"height")
            Parser (Double -> Double -> CaptionRectangle)
-> Parser Double -> Parser (Double -> CaptionRectangle)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"width")
            Parser (Double -> CaptionRectangle)
-> Parser Double -> Parser CaptionRectangle
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"leftOffset")
      )

instance Prelude.Hashable CaptionRectangle

instance Prelude.NFData CaptionRectangle

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"topOffset" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
topOffset),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"height" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
height),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"width" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
width),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"leftOffset" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
leftOffset)
          ]
      )