{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
module GI.Gtk.Declarative.State where
import Data.Typeable
import Data.Vector (Vector)
import qualified GI.Gtk as Gtk
import GI.Gtk.Declarative.Attributes.Collected
import GI.Gtk.Declarative.Container.Class
data SomeState where
SomeState
:: ( Gtk.IsWidget widget
, Typeable widget
, Typeable customState
)
=> StateTree stateType widget child event customState
-> SomeState
data StateType = WidgetState | BinState | ContainerState
data StateTree (stateType :: StateType) widget child event customState where
StateTreeWidget
:: !(StateTreeNode widget event customState)
-> StateTree 'WidgetState widget child event customState
StateTreeBin
:: !(StateTreeNode widget event customState)
-> SomeState
-> StateTree 'BinState widget child event customState
StateTreeContainer
:: ( Gtk.IsContainer widget
, IsContainer widget child
)
=> !(StateTreeNode widget event customState)
-> Vector SomeState
-> StateTree 'ContainerState widget child event customState
data StateTreeNode widget event customState = StateTreeNode
{ StateTreeNode widget event customState -> widget
stateTreeWidget :: !widget
, StateTreeNode widget event customState -> StyleContext
stateTreeStyleContext :: !Gtk.StyleContext
, StateTreeNode widget event customState -> Collected widget event
stateTreeCollectedAttributes :: !(Collected widget event)
, StateTreeNode widget event customState -> customState
stateTreeCustomState :: customState
}
stateTreeNode
:: StateTree stateType widget child event customState
-> StateTreeNode widget event customState
stateTreeNode :: StateTree stateType widget child event customState
-> StateTreeNode widget event customState
stateTreeNode (StateTreeWidget s :: StateTreeNode widget event customState
s ) = StateTreeNode widget event customState
s
stateTreeNode (StateTreeBin s :: StateTreeNode widget event customState
s _) = StateTreeNode widget event customState
s
stateTreeNode (StateTreeContainer s :: StateTreeNode widget event customState
s _) = StateTreeNode widget event customState
s
stateTreeNodeWidget :: StateTree stateType widget child event customState -> widget
stateTreeNodeWidget :: StateTree stateType widget child event customState -> widget
stateTreeNodeWidget = StateTreeNode widget event customState -> widget
forall widget event customState.
StateTreeNode widget event customState -> widget
stateTreeWidget (StateTreeNode widget event customState -> widget)
-> (StateTree stateType widget child event customState
-> StateTreeNode widget event customState)
-> StateTree stateType widget child event customState
-> widget
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StateTree stateType widget child event customState
-> StateTreeNode widget event customState
forall (stateType :: StateType) widget (child :: * -> *) event
customState.
StateTree stateType widget child event customState
-> StateTreeNode widget event customState
stateTreeNode
someStateWidget :: SomeState -> IO Gtk.Widget
someStateWidget :: SomeState -> IO Widget
someStateWidget (SomeState st :: StateTree stateType widget child event customState
st) = widget -> IO Widget
forall (m :: * -> *) o. (MonadIO m, IsWidget o) => o -> m Widget
Gtk.toWidget (StateTree stateType widget child event customState -> widget
forall (stateType :: StateType) widget (child :: * -> *) event
customState.
StateTree stateType widget child event customState -> widget
stateTreeNodeWidget StateTree stateType widget child event customState
st)