Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
2ae0cba2
Commit
2ae0cba2
authored
Jul 23, 2021
by
David Davó
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Play widget
parent
ad2b61a7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
0 deletions
+97
-0
ihaskell-widgets.cabal
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
+1
-0
Widgets.hs
...-display/ihaskell-widgets/src/IHaskell/Display/Widgets.hs
+1
-0
Common.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
+4
-0
Play.hs
...dgets/src/IHaskell/Display/Widgets/Int/BoundedInt/Play.hs
+67
-0
Singletons.hs
...askell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
+4
-0
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+20
-0
No files found.
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
View file @
2ae0cba2
...
@@ -71,6 +71,7 @@ library
...
@@ -71,6 +71,7 @@ library
IHaskell.Display.Widgets.Int.BoundedInt.BoundedIntText
IHaskell.Display.Widgets.Int.BoundedInt.BoundedIntText
IHaskell.Display.Widgets.Int.BoundedInt.IntProgress
IHaskell.Display.Widgets.Int.BoundedInt.IntProgress
IHaskell.Display.Widgets.Int.BoundedInt.IntSlider
IHaskell.Display.Widgets.Int.BoundedInt.IntSlider
IHaskell.Display.Widgets.Int.BoundedInt.Play
IHaskell.Display.Widgets.Int.BoundedIntRange.IntRangeSlider
IHaskell.Display.Widgets.Int.BoundedIntRange.IntRangeSlider
IHaskell.Display.Widgets.Float.FloatText
IHaskell.Display.Widgets.Float.FloatText
IHaskell.Display.Widgets.Float.BoundedFloat.BoundedFloatText
IHaskell.Display.Widgets.Float.BoundedFloat.BoundedFloatText
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets.hs
View file @
2ae0cba2
...
@@ -14,6 +14,7 @@ import IHaskell.Display.Widgets.Int.IntText as X
...
@@ -14,6 +14,7 @@ import IHaskell.Display.Widgets.Int.IntText as X
import
IHaskell.Display.Widgets.Int.BoundedInt.BoundedIntText
as
X
import
IHaskell.Display.Widgets.Int.BoundedInt.BoundedIntText
as
X
import
IHaskell.Display.Widgets.Int.BoundedInt.IntProgress
as
X
import
IHaskell.Display.Widgets.Int.BoundedInt.IntProgress
as
X
import
IHaskell.Display.Widgets.Int.BoundedInt.IntSlider
as
X
import
IHaskell.Display.Widgets.Int.BoundedInt.IntSlider
as
X
import
IHaskell.Display.Widgets.Int.BoundedInt.Play
as
X
import
IHaskell.Display.Widgets.Int.BoundedIntRange.IntRangeSlider
as
X
import
IHaskell.Display.Widgets.Int.BoundedIntRange.IntRangeSlider
as
X
import
IHaskell.Display.Widgets.Float.FloatText
as
X
import
IHaskell.Display.Widgets.Float.FloatText
as
X
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
View file @
2ae0cba2
...
@@ -97,6 +97,10 @@ pattern Loop = S.SLoop
...
@@ -97,6 +97,10 @@ pattern Loop = S.SLoop
pattern
Controls
=
S
.
SControls
pattern
Controls
=
S
.
SControls
pattern
Options
=
S
.
SOptions
pattern
Options
=
S
.
SOptions
pattern
EnsureOption
=
S
.
SEnsureOption
pattern
EnsureOption
=
S
.
SEnsureOption
pattern
Playing
=
S
.
SPlaying
pattern
Repeat
=
S
.
SRepeat
pattern
Interval
=
S
.
SInterval
pattern
ShowRepeat
=
S
.
SShowRepeat
-- | Close a widget's comm
-- | Close a widget's comm
closeWidget
::
IHaskellWidget
w
=>
w
->
IO
()
closeWidget
::
IHaskellWidget
w
=>
w
->
IO
()
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/Play.hs
0 → 100644
View file @
2ae0cba2
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
IHaskell.Display.Widgets.Int.BoundedInt.Play
(
-- * The Play Widget
Play
-- * Constructor
,
mkPlay
)
where
-- To keep `cabal repl` happy when running from the ihaskell repo
import
Prelude
import
Control.Monad
(
void
)
import
Data.Aeson
import
Data.IORef
(
newIORef
)
import
qualified
Data.Scientific
as
Sci
import
Data.Vinyl
(
Rec
(
..
),
(
<+>
))
import
IHaskell.Eval.Widgets
import
IHaskell.IPython.Message.UUID
as
U
import
IHaskell.Display
(
IHaskellWidget
(
..
))
import
IHaskell.Display.Widgets.Types
import
IHaskell.Display.Widgets.Common
-- | 'Play' represents an Play widget from IPython.html.widgets.
type
Play
=
IPythonWidget
'P
l
ayType
-- | Create a new widget
mkPlay
::
IO
Play
mkPlay
=
do
-- Default properties, with a random uuid
wid
<-
U
.
random
let
boundedIntAttrs
=
defaultBoundedIntWidget
"PlayView"
"PlayModel"
playAttrs
=
(
Playing
=::
True
)
:&
(
Repeat
=::
True
)
:&
(
Interval
=::
100
)
:&
(
StepInt
=::
Just
1
)
:&
(
Disabled
=::
False
)
:&
(
ShowRepeat
=::
True
)
:&
RNil
widgetState
=
WidgetState
$
boundedIntAttrs
<+>
playAttrs
stateIO
<-
newIORef
widgetState
let
widget
=
IPythonWidget
wid
stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
widget
$
toJSON
widgetState
-- Return the widget
return
widget
instance
IHaskellWidget
Play
where
getCommUUID
=
uuid
comm
widget
val
_
=
case
nestedObjectLookup
val
[
"state"
,
"value"
]
of
Just
(
Number
value
)
->
do
void
$
setField'
widget
IntValue
(
Sci
.
coefficient
value
)
triggerChange
widget
_
->
pure
()
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
View file @
2ae0cba2
...
@@ -103,5 +103,9 @@ singletons
...
@@ -103,5 +103,9 @@ singletons
| Controls
| Controls
| Options
| Options
| EnsureOption
| EnsureOption
| Playing
| Repeat
| Interval
| ShowRepeat
deriving (Eq, Ord, Show)
deriving (Eq, Ord, Show)
|]
|]
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
2ae0cba2
...
@@ -242,6 +242,10 @@ type family FieldType (f :: Field) :: * where
...
@@ -242,6 +242,10 @@ type family FieldType (f :: Field) :: * where
FieldType
'S
.
Controls
=
Bool
FieldType
'S
.
Controls
=
Bool
FieldType
'S
.
Options
=
[
Text
]
FieldType
'S
.
Options
=
[
Text
]
FieldType
'S
.
EnsureOption
=
Bool
FieldType
'S
.
EnsureOption
=
Bool
FieldType
'S
.
Playing
=
Bool
FieldType
'S
.
Repeat
=
Bool
FieldType
'S
.
Interval
=
Integer
FieldType
'S
.
ShowRepeat
=
Bool
-- | Can be used to put different widgets in a list. Useful for dealing with children widgets.
-- | Can be used to put different widgets in a list. Useful for dealing with children widgets.
data
ChildWidget
=
forall
w
.
RecAll
Attr
(
WidgetFields
w
)
ToPairs
=>
ChildWidget
(
IPythonWidget
w
)
data
ChildWidget
=
forall
w
.
RecAll
Attr
(
WidgetFields
w
)
ToPairs
=>
ChildWidget
(
IPythonWidget
w
)
...
@@ -294,6 +298,7 @@ data WidgetType = ButtonType
...
@@ -294,6 +298,7 @@ data WidgetType = ButtonType
|
IntTextType
|
IntTextType
|
BoundedIntTextType
|
BoundedIntTextType
|
IntSliderType
|
IntSliderType
|
PlayType
|
IntProgressType
|
IntProgressType
|
IntRangeSliderType
|
IntRangeSliderType
|
FloatTextType
|
FloatTextType
...
@@ -351,6 +356,9 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
...
@@ -351,6 +356,9 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
WidgetFields
'I
n
tSliderType
=
WidgetFields
'I
n
tSliderType
=
BoundedIntClass
:++
BoundedIntClass
:++
[
'S
.
StepInt
,
'S
.
Orientation
,
'S
.
ReadOut
,
'S
.
ReadOutFormat
,
'S
.
ContinuousUpdate
,
'S
.
Disabled
]
[
'S
.
StepInt
,
'S
.
Orientation
,
'S
.
ReadOut
,
'S
.
ReadOutFormat
,
'S
.
ContinuousUpdate
,
'S
.
Disabled
]
WidgetFields
'P
l
ayType
=
BoundedIntClass
:++
[
'S
.
Playing
,
'S
.
Repeat
,
'S
.
Interval
,
'S
.
StepInt
,
'S
.
Disabled
,
'S
.
ShowRepeat
]
WidgetFields
'I
n
tProgressType
=
WidgetFields
'I
n
tProgressType
=
BoundedIntClass
:++
[
'S
.
Orientation
,
'S
.
BarStyle
]
BoundedIntClass
:++
[
'S
.
Orientation
,
'S
.
BarStyle
]
WidgetFields
'I
n
tRangeSliderType
=
WidgetFields
'I
n
tRangeSliderType
=
...
@@ -622,6 +630,18 @@ instance ToPairs (Attr 'S.Options) where
...
@@ -622,6 +630,18 @@ instance ToPairs (Attr 'S.Options) where
instance
ToPairs
(
Attr
'S
.
EnsureOption
)
where
instance
ToPairs
(
Attr
'S
.
EnsureOption
)
where
toPairs
x
=
[
"ensure_option"
.=
toJSON
x
]
toPairs
x
=
[
"ensure_option"
.=
toJSON
x
]
instance
ToPairs
(
Attr
'S
.
Playing
)
where
toPairs
x
=
[
"playing"
.=
toJSON
x
]
instance
ToPairs
(
Attr
'S
.
Repeat
)
where
toPairs
x
=
[
"repeat"
.=
toJSON
x
]
instance
ToPairs
(
Attr
'S
.
Interval
)
where
toPairs
x
=
[
"interval"
.=
toJSON
x
]
instance
ToPairs
(
Attr
'S
.
ShowRepeat
)
where
toPairs
x
=
[
"show_repeat"
.=
toJSON
x
]
-- | Store the value for a field, as an object parametrized by the Field. No verification is done
-- | Store the value for a field, as an object parametrized by the Field. No verification is done
-- for these values.
-- for these values.
(
=::
)
::
(
SingI
f
,
Typeable
(
FieldType
f
))
=>
Sing
f
->
FieldType
f
->
Attr
f
(
=::
)
::
(
SingI
f
,
Typeable
(
FieldType
f
))
=>
Sing
f
->
FieldType
f
->
Attr
f
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment