{-# LANGUAGE DeriveAnyClass #-}

module Chiasma.Ui.Data.ViewGeometry where

import Data.Data (Data)
import Data.Text.Prettyprint.Doc (Doc, Pretty(..), emptyDoc, space, (<+>))

data ViewGeometry =
  ViewGeometry {
    ViewGeometry -> Maybe Float
minSize :: Maybe Float,
    ViewGeometry -> Maybe Float
maxSize :: Maybe Float,
    ViewGeometry -> Maybe Float
fixedSize :: Maybe Float,
    ViewGeometry -> Maybe Float
minimizedSize :: Maybe Float,
    ViewGeometry -> Maybe Float
weight :: Maybe Float,
    ViewGeometry -> Maybe Float
position :: Maybe Float
  }
  deriving (ViewGeometry -> ViewGeometry -> Bool
(ViewGeometry -> ViewGeometry -> Bool)
-> (ViewGeometry -> ViewGeometry -> Bool) -> Eq ViewGeometry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ViewGeometry -> ViewGeometry -> Bool
$c/= :: ViewGeometry -> ViewGeometry -> Bool
== :: ViewGeometry -> ViewGeometry -> Bool
$c== :: ViewGeometry -> ViewGeometry -> Bool
Eq, Int -> ViewGeometry -> ShowS
[ViewGeometry] -> ShowS
ViewGeometry -> String
(Int -> ViewGeometry -> ShowS)
-> (ViewGeometry -> String)
-> ([ViewGeometry] -> ShowS)
-> Show ViewGeometry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ViewGeometry] -> ShowS
$cshowList :: [ViewGeometry] -> ShowS
show :: ViewGeometry -> String
$cshow :: ViewGeometry -> String
showsPrec :: Int -> ViewGeometry -> ShowS
$cshowsPrec :: Int -> ViewGeometry -> ShowS
Show, Typeable ViewGeometry
DataType
Constr
Typeable ViewGeometry
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ViewGeometry -> c ViewGeometry)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ViewGeometry)
-> (ViewGeometry -> Constr)
-> (ViewGeometry -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ViewGeometry))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ViewGeometry))
-> ((forall b. Data b => b -> b) -> ViewGeometry -> ViewGeometry)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r)
-> (forall u. (forall d. Data d => d -> u) -> ViewGeometry -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> ViewGeometry -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry)
-> Data ViewGeometry
ViewGeometry -> DataType
ViewGeometry -> Constr
(forall b. Data b => b -> b) -> ViewGeometry -> ViewGeometry
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ViewGeometry -> c ViewGeometry
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ViewGeometry
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> ViewGeometry -> u
forall u. (forall d. Data d => d -> u) -> ViewGeometry -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ViewGeometry
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ViewGeometry -> c ViewGeometry
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ViewGeometry)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ViewGeometry)
$cViewGeometry :: Constr
$tViewGeometry :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
gmapMp :: (forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
gmapM :: (forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> ViewGeometry -> m ViewGeometry
gmapQi :: Int -> (forall d. Data d => d -> u) -> ViewGeometry -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ViewGeometry -> u
gmapQ :: (forall d. Data d => d -> u) -> ViewGeometry -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ViewGeometry -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ViewGeometry -> r
gmapT :: (forall b. Data b => b -> b) -> ViewGeometry -> ViewGeometry
$cgmapT :: (forall b. Data b => b -> b) -> ViewGeometry -> ViewGeometry
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ViewGeometry)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ViewGeometry)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c ViewGeometry)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ViewGeometry)
dataTypeOf :: ViewGeometry -> DataType
$cdataTypeOf :: ViewGeometry -> DataType
toConstr :: ViewGeometry -> Constr
$ctoConstr :: ViewGeometry -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ViewGeometry
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ViewGeometry
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ViewGeometry -> c ViewGeometry
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ViewGeometry -> c ViewGeometry
$cp1Data :: Typeable ViewGeometry
Data, (forall x. ViewGeometry -> Rep ViewGeometry x)
-> (forall x. Rep ViewGeometry x -> ViewGeometry)
-> Generic ViewGeometry
forall x. Rep ViewGeometry x -> ViewGeometry
forall x. ViewGeometry -> Rep ViewGeometry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ViewGeometry x -> ViewGeometry
$cfrom :: forall x. ViewGeometry -> Rep ViewGeometry x
Generic, ViewGeometry
ViewGeometry -> Default ViewGeometry
forall a. a -> Default a
def :: ViewGeometry
$cdef :: ViewGeometry
Default)

mayPretty :: Text -> Maybe Float -> Doc a
mayPretty :: Text -> Maybe Float -> Doc a
mayPretty Text
prefix (Just Float
a) =
  Doc a
forall ann. Doc ann
space Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Text -> Doc a
forall a ann. Pretty a => a -> Doc ann
pretty Text
prefix Doc a -> Doc a -> Doc a
forall a. Semigroup a => a -> a -> a
<> Doc a
":" Doc a -> Doc a -> Doc a
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Float -> Doc a
forall a ann. Pretty a => a -> Doc ann
pretty Float
a
mayPretty Text
_ Maybe Float
Nothing =
  Doc a
forall ann. Doc ann
emptyDoc

instance Pretty ViewGeometry where
  pretty :: ViewGeometry -> Doc ann
pretty (ViewGeometry Maybe Float
minSize Maybe Float
maxSize Maybe Float
fixedSize Maybe Float
_ Maybe Float
_ Maybe Float
_) =
    (Doc ann -> Doc ann -> Doc ann) -> Doc ann -> [Doc ann] -> Doc ann
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl @[] Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
(<>) Doc ann
forall ann. Doc ann
emptyDoc ((Text -> Maybe Float -> Doc ann) -> (Text, Maybe Float) -> Doc ann
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Text -> Maybe Float -> Doc ann
forall a. Text -> Maybe Float -> Doc a
mayPretty ((Text, Maybe Float) -> Doc ann)
-> [(Text, Maybe Float)] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Text
"min", Maybe Float
minSize), (Text
"max", Maybe Float
maxSize), (Text
"fixed", Maybe Float
fixedSize)])