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
754b3be8
Commit
754b3be8
authored
Jul 24, 2021
by
David Davó
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added colorpicker widget
parent
2ae0cba2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
0 deletions
+69
-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
ColorPicker.hs
...skell-widgets/src/IHaskell/Display/Widgets/ColorPicker.hs
+56
-0
Common.hs
...y/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
+1
-0
Singletons.hs
...askell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
+1
-0
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+9
-0
No files found.
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
View file @
754b3be8
...
...
@@ -61,6 +61,7 @@ library
-- Modules included in this library but not exported.
other-modules: IHaskell.Display.Widgets.Button
IHaskell.Display.Widgets.ColorPicker
IHaskell.Display.Widgets.Box.Box
IHaskell.Display.Widgets.Box.SelectionContainer.Accordion
IHaskell.Display.Widgets.Box.SelectionContainer.Tab
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets.hs
View file @
754b3be8
module
IHaskell.Display.Widgets
(
module
X
)
where
import
IHaskell.Display.Widgets.Button
as
X
import
IHaskell.Display.Widgets.ColorPicker
as
X
import
IHaskell.Display.Widgets.Box.Box
as
X
import
IHaskell.Display.Widgets.Box.SelectionContainer.Accordion
as
X
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/ColorPicker.hs
0 → 100644
View file @
754b3be8
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
IHaskell.Display.Widgets.ColorPicker
(
-- * The ColorPicker Widget
ColorPicker
-- * Create a new ColorPicker
,
mkColorPicker
)
where
-- To keep `cabal repl` happy when running from the ihaskell repo
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
-- | A 'ColorPicker' represents a ColorPicker from IPython.html.widgets.
type
ColorPicker
=
IPythonWidget
'C
o
lorPickerType
-- | Create a new ColorPicker
mkColorPicker
::
IO
ColorPicker
mkColorPicker
=
do
-- Default properties, with a random uuid
wid
<-
U
.
random
let
ddw
=
defaultDescriptionWidget
"ColorPickerView"
"ColorPickerModel"
color
=
(
StringValue
=::
"black"
)
:&
(
Concise
=::
False
)
:&
(
Disabled
=::
False
)
:&
RNil
colorPickerState
=
WidgetState
(
ddw
<+>
color
)
stateIO
<-
newIORef
colorPickerState
let
colorPicker
=
IPythonWidget
wid
stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen
colorPicker
$
toJSON
colorPickerState
-- Return the ColorPicker widget
return
colorPicker
instance
IHaskellWidget
ColorPicker
where
getCommUUID
=
uuid
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Common.hs
View file @
754b3be8
...
...
@@ -101,6 +101,7 @@ pattern Playing = S.SPlaying
pattern
Repeat
=
S
.
SRepeat
pattern
Interval
=
S
.
SInterval
pattern
ShowRepeat
=
S
.
SShowRepeat
pattern
Concise
=
S
.
SConcise
-- | Close a widget's comm
closeWidget
::
IHaskellWidget
w
=>
w
->
IO
()
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Singletons.hs
View file @
754b3be8
...
...
@@ -107,5 +107,6 @@ singletons
| Repeat
| Interval
| ShowRepeat
| Concise
deriving (Eq, Ord, Show)
|]
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
754b3be8
...
...
@@ -246,6 +246,7 @@ type family FieldType (f :: Field) :: * where
FieldType
'S
.
Repeat
=
Bool
FieldType
'S
.
Interval
=
Integer
FieldType
'S
.
ShowRepeat
=
Bool
FieldType
'S
.
Concise
=
Bool
-- | 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
)
...
...
@@ -274,6 +275,7 @@ instance CustomBounded Double where
-- Different types of widgets. Every widget in IPython has a corresponding WidgetType
data
WidgetType
=
ButtonType
|
ColorPickerType
|
AudioType
|
ImageType
|
VideoType
...
...
@@ -318,6 +320,10 @@ type family WidgetFields (w :: WidgetType) :: [Field] where
DescriptionWidgetClass
:++
[
'S
.
Disabled
,
'S
.
Icon
,
'S
.
ButtonStyle
,
'S
.
ClickHandler
]
WidgetFields
'C
o
lorPickerType
=
DescriptionWidgetClass
:++
[
'S
.
StringValue
,
'S
.
Concise
,
'S
.
Disabled
]
WidgetFields
'A
u
dioType
=
MediaClass
:++
[
'S
.
AudioFormat
,
'S
.
AutoPlay
,
'S
.
Loop
,
'S
.
Controls
]
WidgetFields
'I
m
ageType
=
...
...
@@ -642,6 +648,9 @@ instance ToPairs (Attr 'S.Interval) where
instance
ToPairs
(
Attr
'S
.
ShowRepeat
)
where
toPairs
x
=
[
"show_repeat"
.=
toJSON
x
]
instance
ToPairs
(
Attr
'S
.
Concise
)
where
toPairs
x
=
[
"concise"
.=
toJSON
x
]
-- | Store the value for a field, as an object parametrized by the Field. No verification is done
-- for these values.
(
=::
)
::
(
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