{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module FULE.Container
( Container(..)
) where
import Control.Monad.Writer
import Data.Proxy
import FULE.Component
import FULE.LayoutOp
class (Monad m) => Container c k m where
minWidth :: c -> Proxy k -> m (Maybe Int)
minHeight :: c -> Proxy k -> m (Maybe Int)
addToLayout :: c -> Proxy k -> Bounds -> RenderGroup -> LayoutOp k m ()
instance {-# OVERLAPPABLE #-} (Component k m) => Container k k m where
minWidth :: k -> Proxy k -> m (Maybe Int)
minWidth k
k Proxy k
_ = k -> m (Maybe Int)
forall k (m :: * -> *). Component k m => k -> m (Maybe Int)
requiredWidth k
k
minHeight :: k -> Proxy k -> m (Maybe Int)
minHeight k
k Proxy k
_ = k -> m (Maybe Int)
forall k (m :: * -> *). Component k m => k -> m (Maybe Int)
requiredHeight k
k
addToLayout :: k -> Proxy k -> Bounds -> Maybe Int -> LayoutOp k m ()
addToLayout k
k Proxy k
_ Bounds
bounds Maybe Int
renderGroup = [ComponentInfo k] -> LayoutOp k m ()
forall w (m :: * -> *). MonadWriter w m => w -> m ()
tell [Bounds -> k -> Maybe Int -> ComponentInfo k
forall k. Bounds -> k -> Maybe Int -> ComponentInfo k
ComponentInfo Bounds
bounds k
k Maybe Int
renderGroup]