{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module IHaskell.Display.Widgets.Float.BoundedFloat.FloatProgress
(
FloatProgress
, mkFloatProgress
) 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.ProgressStyle
type FloatProgress = IPythonWidget 'FloatProgressType
mkFloatProgress :: IO FloatProgress
mkFloatProgress :: IO FloatProgress
mkFloatProgress = do
UUID
wid <- IO UUID
U.random
IPythonWidget 'LayoutType
layout <- IO (IPythonWidget 'LayoutType)
mkLayout
ProgressStyle
pstyle <- IO ProgressStyle
mkProgressStyle
let boundedFloatAttrs :: Rec Attr BoundedFloatClass
boundedFloatAttrs = FieldType 'ViewName
-> FieldType 'ModelName
-> IPythonWidget 'LayoutType
-> StyleWidget
-> Rec Attr BoundedFloatClass
defaultBoundedFloatWidget Text
"ProgressView" Text
"FloatProgressModel" IPythonWidget 'LayoutType
layout forall a b. (a -> b) -> a -> b
$ forall (w :: WidgetType).
RecAll Attr (WidgetFields w) ToPairs =>
IPythonWidget w -> StyleWidget
StyleWidget ProgressStyle
pstyle
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 'FloatProgressType
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, 'FloatValue,
'ChangeHandler, 'MinFloat, 'MaxFloat]
boundedFloatAttrs 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 'FloatProgressType)
stateIO <- forall a. a -> IO (IORef a)
newIORef WidgetState 'FloatProgressType
widgetState
let widget :: FloatProgress
widget = forall (w :: WidgetType).
UUID -> IORef (WidgetState w) -> IPythonWidget w
IPythonWidget UUID
wid IORef (WidgetState 'FloatProgressType)
stateIO
forall a. IHaskellWidget a => a -> Value -> IO ()
widgetSendOpen FloatProgress
widget forall a b. (a -> b) -> a -> b
$ forall a. ToJSON a => a -> Value
toJSON WidgetState 'FloatProgressType
widgetState
forall (m :: * -> *) a. Monad m => a -> m a
return FloatProgress
widget
instance IHaskellWidget FloatProgress where
getCommUUID :: FloatProgress -> UUID
getCommUUID = forall (w :: WidgetType). IPythonWidget w -> UUID
uuid