{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module IHaskell.Display.Widgets.Int.BoundedInt.IntProgress
(
IntProgress
, mkIntProgress
) where
import Prelude
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle
type IntProgress = IPythonWidget 'IntProgressType
mkIntProgress :: IO IntProgress
mkIntProgress :: IO IntProgress
mkIntProgress = do
UUID
wid <- IO UUID
U.random
IPythonWidget 'LayoutType
layout <- IO (IPythonWidget 'LayoutType)
mkLayout
DescriptionStyle
dstyle <- IO DescriptionStyle
mkDescriptionStyle
let boundedIntAttrs :: Rec Attr BoundedIntClass
boundedIntAttrs = FieldType 'ViewName
-> FieldType 'ModelName
-> IPythonWidget 'LayoutType
-> StyleWidget
-> Rec Attr BoundedIntClass
defaultBoundedIntWidget Text
"ProgressView" Text
"IntProgressModel" IPythonWidget 'LayoutType
layout forall a b. (a -> b) -> a -> b
$ forall (w :: WidgetType).
RecAll Attr (WidgetFields w) ToPairs =>
IPythonWidget w -> StyleWidget
StyleWidget DescriptionStyle
dstyle
progressAttrs :: Rec Attr '[ 'Orientation, 'BarStyle]
progressAttrs = (forall {a :: Field}. (a ~ 'Orientation) => SField a
Orientation forall (f :: Field).
(SingI f, Typeable (FieldType f)) =>
Sing f -> FieldType f -> Attr f
=:: OrientationValue
HorizontalOrientation)
forall {u} (a :: u -> *) (r :: u) (rs :: [u]).
a r -> Rec a rs -> Rec a (r : rs)
:& (forall {a :: Field}. (a ~ 'BarStyle) => SField a
BarStyle forall (f :: Field).
(SingI f, Typeable (FieldType f)) =>
Sing f -> FieldType f -> Attr f
=:: BarStyleValue
DefaultBar)
forall {u} (a :: u -> *) (r :: u) (rs :: [u]).
a r -> Rec a rs -> Rec a (r : rs)
:& forall {u} (a :: u -> *). Rec a '[]
RNil
widgetState :: WidgetState 'IntProgressType
widgetState = forall (w :: WidgetType).
Rec Attr (WidgetFields w) -> WidgetState w
WidgetState forall a b. (a -> b) -> a -> b
$ Rec
Attr
'[ 'ViewModule, 'ViewModuleVersion, 'ModelModule,
'ModelModuleVersion, 'ModelName, 'ViewName, 'DOMClasses, 'Tooltip,
'Layout, 'DisplayHandler, 'Description, 'Style, 'IntValue,
'ChangeHandler, 'MaxInt, 'MinInt]
boundedIntAttrs forall {k} (f :: k -> *) (as :: [k]) (bs :: [k]).
Rec f as -> Rec f bs -> Rec f (as ++ bs)
<+> Rec Attr '[ 'Orientation, 'BarStyle]
progressAttrs
IORef (WidgetState 'IntProgressType)
stateIO <- forall a. a -> IO (IORef a)
newIORef WidgetState 'IntProgressType
widgetState
let widget :: IntProgress
widget = forall (w :: WidgetType).
UUID -> IORef (WidgetState w) -> IPythonWidget w
IPythonWidget UUID
wid IORef (WidgetState 'IntProgressType)
stateIO
forall a. IHaskellWidget a => a -> Value -> IO ()
widgetSendOpen IntProgress
widget forall a b. (a -> b) -> a -> b
$ forall a. ToJSON a => a -> Value
toJSON WidgetState 'IntProgressType
widgetState
forall (m :: * -> *) a. Monad m => a -> m a
return IntProgress
widget
instance IHaskellWidget IntProgress where
getCommUUID :: IntProgress -> UUID
getCommUUID = forall (w :: WidgetType). IPythonWidget w -> UUID
uuid