Commit 67ab446e authored by David Davó's avatar David Davó

Added widgets styles

parent abf2a721
...@@ -21,6 +21,8 @@ jupyter nbconvert *.ipynb --to notebook --inplace --clear-output ...@@ -21,6 +21,8 @@ jupyter nbconvert *.ipynb --to notebook --inplace --clear-output
- [ ] Make the `output` widget work - [ ] Make the `output` widget work
- [ ] Processing of widget messages concurrently - [ ] Processing of widget messages concurrently
- [ ] Make the layout widget values more 'Haskelian': Instead of checking if the string is valid at runtime, make some types so it's checked at compile-time - [ ] Make the layout widget values more 'Haskelian': Instead of checking if the string is valid at runtime, make some types so it's checked at compile-time
- [ ] Create a serializable color data type instead of using `Maybe String`
- [ ] Overload setField so it can be used with `Maybes` without having to put `Just` every time
- [ ] Add some "utils" work: - [ ] Add some "utils" work:
- [ ] Create media widget from file - [ ] Create media widget from file
- [ ] Get the selected label from a selection value - [ ] Get the selected label from a selection value
\ No newline at end of file
...@@ -108,6 +108,9 @@ library ...@@ -108,6 +108,9 @@ library
IHaskell.Display.Widgets.String.TextArea IHaskell.Display.Widgets.String.TextArea
IHaskell.Display.Widgets.Style.ButtonStyle IHaskell.Display.Widgets.Style.ButtonStyle
IHaskell.Display.Widgets.Style.DescriptionStyle IHaskell.Display.Widgets.Style.DescriptionStyle
IHaskell.Display.Widgets.Style.ProgressStyle
IHaskell.Display.Widgets.Style.SliderStyle
IHaskell.Display.Widgets.Style.ToggleButtonsStyle
IHaskell.Display.Widgets.Layout.Common IHaskell.Display.Widgets.Layout.Common
IHaskell.Display.Widgets.Layout.LayoutWidget IHaskell.Display.Widgets.Layout.LayoutWidget
......
...@@ -57,6 +57,9 @@ import IHaskell.Display.Widgets.String.TextArea as X ...@@ -57,6 +57,9 @@ import IHaskell.Display.Widgets.String.TextArea as X
import IHaskell.Display.Widgets.Style.ButtonStyle as X import IHaskell.Display.Widgets.Style.ButtonStyle as X
import IHaskell.Display.Widgets.Style.DescriptionStyle as X import IHaskell.Display.Widgets.Style.DescriptionStyle as X
import IHaskell.Display.Widgets.Style.ProgressStyle as X
import IHaskell.Display.Widgets.Style.SliderStyle as X
import IHaskell.Display.Widgets.Style.ToggleButtonsStyle as X
import IHaskell.Display.Widgets.Common as X import IHaskell.Display.Widgets.Common as X
import IHaskell.Display.Widgets.Types as X (setField, getField, properties, triggerDisplay, import IHaskell.Display.Widgets.Types as X (setField, getField, properties, triggerDisplay,
......
...@@ -40,7 +40,7 @@ mkCheckBox = do ...@@ -40,7 +40,7 @@ mkCheckBox = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boolAttrs = defaultBoolWidget "CheckboxView" "CheckboxModel" layout dstyle let boolAttrs = defaultBoolWidget "CheckboxView" "CheckboxModel" layout $ StyleWidget dstyle
checkBoxAttrs = (Indent =:: True) checkBoxAttrs = (Indent =:: True)
:& RNil :& RNil
widgetState = WidgetState $ boolAttrs <+> checkBoxAttrs widgetState = WidgetState $ boolAttrs <+> checkBoxAttrs
......
...@@ -40,7 +40,7 @@ mkToggleButton = do ...@@ -40,7 +40,7 @@ mkToggleButton = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boolState = defaultBoolWidget "ToggleButtonView" "ToggleButtonModel" layout dstyle let boolState = defaultBoolWidget "ToggleButtonView" "ToggleButtonModel" layout $ StyleWidget dstyle
toggleState = (Icon =:: "") toggleState = (Icon =:: "")
:& (ButtonStyle =:: DefaultButton) :& (ButtonStyle =:: DefaultButton)
:& RNil :& RNil
......
...@@ -39,7 +39,7 @@ mkValidWidget = do ...@@ -39,7 +39,7 @@ mkValidWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boolState = defaultBoolWidget "ValidView" "ValidModel" layout dstyle let boolState = defaultBoolWidget "ValidView" "ValidModel" layout $ StyleWidget dstyle
validState = (ReadOutMsg =:: "") :& RNil validState = (ReadOutMsg =:: "") :& RNil
widgetState = WidgetState $ boolState <+> validState widgetState = WidgetState $ boolState <+> validState
......
...@@ -38,14 +38,12 @@ mkButton = do ...@@ -38,14 +38,12 @@ mkButton = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
wid <- U.random wid <- U.random
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle
btnstyle <- mkButtonStyle btnstyle <- mkButtonStyle
let ddw = defaultDescriptionWidget "ButtonView" "ButtonModel" layout dstyle let ddw = defaultDescriptionWidget "ButtonView" "ButtonModel" layout $ StyleWidget btnstyle
but = (Disabled =:: False) but = (Disabled =:: False)
:& (Icon =:: "") :& (Icon =:: "")
:& (ButtonStyle =:: DefaultButton) :& (ButtonStyle =:: DefaultButton)
:& (StyleButton =:: btnstyle)
:& (ClickHandler =:: return ()) :& (ClickHandler =:: return ())
:& RNil :& RNil
buttonState = WidgetState (ddw <+> but) buttonState = WidgetState (ddw <+> but)
......
...@@ -39,7 +39,7 @@ mkColorPicker = do ...@@ -39,7 +39,7 @@ mkColorPicker = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let ddw = defaultDescriptionWidget "ColorPickerView" "ColorPickerModel" layout dstyle let ddw = defaultDescriptionWidget "ColorPickerView" "ColorPickerModel" layout $ StyleWidget dstyle
color = (StringValue =:: "black") color = (StringValue =:: "black")
:& (Concise =:: False) :& (Concise =:: False)
:& (Disabled =:: False) :& (Disabled =:: False)
......
...@@ -111,13 +111,10 @@ pattern Axes = S.SAxes ...@@ -111,13 +111,10 @@ pattern Axes = S.SAxes
pattern ButtonColor = S.SButtonColor pattern ButtonColor = S.SButtonColor
pattern FontWeight = S.SFontWeight pattern FontWeight = S.SFontWeight
pattern DescriptionWidth = S.SDescriptionWidth pattern DescriptionWidth = S.SDescriptionWidth
pattern BarColor = S.SBarColor
pattern StyleButton = S.SStyleButton pattern HandleColor = S.SHandleColor
pattern StyleDescription = S.SStyleDescription pattern ButtonWidth = S.SButtonWidth
pattern StyleProgress = S.SStyleProgress pattern Style = S.SStyle
pattern StyleSlider = S.SStyleSlider
pattern StyleToggleButton = S.SStyleToggleButton
-- | Close a widget's comm -- | Close a widget's comm
closeWidget :: IHaskellWidget w => w -> IO () closeWidget :: IHaskellWidget w => w -> IO ()
closeWidget w = widgetSendClose w emptyObject closeWidget w = widgetSendClose w emptyObject
......
...@@ -41,7 +41,7 @@ mkDatePicker = do ...@@ -41,7 +41,7 @@ mkDatePicker = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let ddw = defaultDescriptionWidget "DatePickerView" "DatePickerModel" layout dstyle let ddw = defaultDescriptionWidget "DatePickerView" "DatePickerModel" layout $ StyleWidget dstyle
date = (DateValue =:: defaultDate) date = (DateValue =:: defaultDate)
:& (Disabled =:: False) :& (Disabled =:: False)
:& RNil :& RNil
......
...@@ -41,7 +41,7 @@ mkBoundedFloatText = do ...@@ -41,7 +41,7 @@ mkBoundedFloatText = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatTextView" "BoundedFloatTextModel" layout dstyle let boundedFloatAttrs = defaultBoundedFloatWidget "FloatTextView" "BoundedFloatTextModel" layout $ StyleWidget dstyle
textAttrs = (Disabled =:: False) textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False) :& (ContinuousUpdate =:: False)
:& (StepFloat =:: Nothing) :& (StepFloat =:: Nothing)
......
...@@ -41,7 +41,7 @@ mkFloatLogSlider = do ...@@ -41,7 +41,7 @@ mkFloatLogSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedLogFloatAttrs = defaultBoundedLogFloatWidget "FloatLogSliderView" "FloatLogSliderModel" layout dstyle let boundedLogFloatAttrs = defaultBoundedLogFloatWidget "FloatLogSliderView" "FloatLogSliderModel" layout $ StyleWidget dstyle
sliderAttrs = (StepFloat =:: Just 0.1) sliderAttrs = (StepFloat =:: Just 0.1)
:& (Orientation =:: HorizontalOrientation) :& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -26,7 +26,7 @@ import IHaskell.IPython.Message.UUID as U ...@@ -26,7 +26,7 @@ import IHaskell.IPython.Message.UUID as U
import IHaskell.Display.Widgets.Types import IHaskell.Display.Widgets.Types
import IHaskell.Display.Widgets.Common import IHaskell.Display.Widgets.Common
import IHaskell.Display.Widgets.Layout.LayoutWidget import IHaskell.Display.Widgets.Layout.LayoutWidget
import IHaskell.Display.Widgets.Style.DescriptionStyle import IHaskell.Display.Widgets.Style.ProgressStyle
-- | 'FloatProgress' represents an FloatProgress widget from IPython.html.widgets. -- | 'FloatProgress' represents an FloatProgress widget from IPython.html.widgets.
type FloatProgress = IPythonWidget 'FloatProgressType type FloatProgress = IPythonWidget 'FloatProgressType
...@@ -37,9 +37,9 @@ mkFloatProgress = do ...@@ -37,9 +37,9 @@ mkFloatProgress = do
-- Default properties, with a random uuid -- Default properties, with a random uuid
wid <- U.random wid <- U.random
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle pstyle <- mkProgressStyle
let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView" "FloatProgressModel" layout dstyle let boundedFloatAttrs = defaultBoundedFloatWidget "ProgressView" "FloatProgressModel" layout $ StyleWidget pstyle
progressAttrs = (Orientation =:: HorizontalOrientation) progressAttrs = (Orientation =:: HorizontalOrientation)
:& (BarStyle =:: DefaultBar) :& (BarStyle =:: DefaultBar)
:& RNil :& RNil
......
...@@ -41,7 +41,7 @@ mkFloatSlider = do ...@@ -41,7 +41,7 @@ mkFloatSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" "FloatSliderModel" layout dstyle let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" "FloatSliderModel" layout $ StyleWidget dstyle
sliderAttrs = (StepFloat =:: Just 0.1) sliderAttrs = (StepFloat =:: Just 0.1)
:& (Orientation =:: HorizontalOrientation) :& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -42,7 +42,7 @@ mkFloatRangeSlider = do ...@@ -42,7 +42,7 @@ mkFloatRangeSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatRangeSliderView" "FloatRangeSliderModel" layout dstyle let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatRangeSliderView" "FloatRangeSliderModel" layout $ StyleWidget dstyle
sliderAttrs = (StepFloat =:: Just 0.1) sliderAttrs = (StepFloat =:: Just 0.1)
:& (Orientation =:: HorizontalOrientation) :& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -41,7 +41,7 @@ mkFloatText = do ...@@ -41,7 +41,7 @@ mkFloatText = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let floatAttrs = defaultFloatWidget "FloatTextView" "FloatTextModel" layout dstyle let floatAttrs = defaultFloatWidget "FloatTextView" "FloatTextModel" layout $ StyleWidget dstyle
textAttrs = (Disabled =:: False) textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False) :& (ContinuousUpdate =:: False)
:& (StepFloat =:: Nothing) :& (StepFloat =:: Nothing)
......
...@@ -41,7 +41,7 @@ mkBoundedIntText = do ...@@ -41,7 +41,7 @@ mkBoundedIntText = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "IntTextView" "BoundedIntTextModel" layout dstyle let boundedIntAttrs = defaultBoundedIntWidget "IntTextView" "BoundedIntTextModel" layout $ StyleWidget dstyle
textAttrs = (Disabled =:: False) textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False) :& (ContinuousUpdate =:: False)
:& (StepInt =:: Just 1) :& (StepInt =:: Just 1)
......
...@@ -39,7 +39,7 @@ mkIntProgress = do ...@@ -39,7 +39,7 @@ mkIntProgress = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "ProgressView" "IntProgressModel" layout dstyle let boundedIntAttrs = defaultBoundedIntWidget "ProgressView" "IntProgressModel" layout $ StyleWidget dstyle
progressAttrs = (Orientation =:: HorizontalOrientation) progressAttrs = (Orientation =:: HorizontalOrientation)
:& (BarStyle =:: DefaultBar) :& (BarStyle =:: DefaultBar)
:& RNil :& RNil
......
...@@ -41,7 +41,7 @@ mkIntSlider = do ...@@ -41,7 +41,7 @@ mkIntSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" "IntSliderModel" layout dstyle let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" "IntSliderModel" layout $ StyleWidget dstyle
sliderAttrs = (StepInt =:: Just 1) sliderAttrs = (StepInt =:: Just 1)
:& (Orientation =:: HorizontalOrientation) :& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -41,7 +41,7 @@ mkPlay = do ...@@ -41,7 +41,7 @@ mkPlay = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntWidget "PlayView" "PlayModel" layout dstyle let boundedIntAttrs = defaultBoundedIntWidget "PlayView" "PlayModel" layout $ StyleWidget dstyle
playAttrs = (Playing =:: True) playAttrs = (Playing =:: True)
:& (Repeat =:: True) :& (Repeat =:: True)
:& (Interval =:: 100) :& (Interval =:: 100)
......
...@@ -42,7 +42,7 @@ mkIntRangeSlider = do ...@@ -42,7 +42,7 @@ mkIntRangeSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let boundedIntAttrs = defaultBoundedIntRangeWidget "IntRangeSliderView" "IntRangeSliderModel" layout dstyle let boundedIntAttrs = defaultBoundedIntRangeWidget "IntRangeSliderView" "IntRangeSliderModel" layout $ StyleWidget dstyle
sliderAttrs = (StepInt =:: Just 1) sliderAttrs = (StepInt =:: Just 1)
:& (Orientation =:: HorizontalOrientation) :& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
......
...@@ -41,7 +41,7 @@ mkIntText = do ...@@ -41,7 +41,7 @@ mkIntText = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let intAttrs = defaultIntWidget "IntTextView" "IntTextModel" layout dstyle let intAttrs = defaultIntWidget "IntTextView" "IntTextModel" layout $ StyleWidget dstyle
textAttrs = (Disabled =:: False) textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False) :& (ContinuousUpdate =:: False)
:& (StepInt =:: Just 1) :& (StepInt =:: Just 1)
......
...@@ -41,7 +41,7 @@ mkDropdown = do ...@@ -41,7 +41,7 @@ mkDropdown = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultSelectionWidget "DropdownView" "DropdownModel" layout dstyle let widgetState = WidgetState $ defaultSelectionWidget "DropdownView" "DropdownModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -40,7 +40,7 @@ mkRadioButtons = do ...@@ -40,7 +40,7 @@ mkRadioButtons = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultSelectionWidget "RadioButtonsView" "RadioButtonsModel" layout dstyle let widgetState = WidgetState $ defaultSelectionWidget "RadioButtonsView" "RadioButtonsModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -41,7 +41,7 @@ mkSelect = do ...@@ -41,7 +41,7 @@ mkSelect = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let selectionAttrs = defaultSelectionWidget "SelectView" "SelectModel" layout dstyle let selectionAttrs = defaultSelectionWidget "SelectView" "SelectModel" layout $ StyleWidget dstyle
selectAttrs = (Rows =:: Just 5) selectAttrs = (Rows =:: Just 5)
:& RNil :& RNil
widgetState = WidgetState $ selectionAttrs <+> selectAttrs widgetState = WidgetState $ selectionAttrs <+> selectAttrs
......
...@@ -42,7 +42,7 @@ mkSelectMultiple = do ...@@ -42,7 +42,7 @@ mkSelectMultiple = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let multipleSelectionAttrs = defaultMultipleSelectionWidget "SelectMultipleView" "SelectMultipleModel" layout dstyle let multipleSelectionAttrs = defaultMultipleSelectionWidget "SelectMultipleView" "SelectMultipleModel" layout $ StyleWidget dstyle
selectMultipleAttrs = (Rows =:: Just 5) selectMultipleAttrs = (Rows =:: Just 5)
:& RNil :& RNil
widgetState = WidgetState $ multipleSelectionAttrs <+> selectMultipleAttrs widgetState = WidgetState $ multipleSelectionAttrs <+> selectMultipleAttrs
......
...@@ -41,7 +41,7 @@ mkSelectionRangeSlider = do ...@@ -41,7 +41,7 @@ mkSelectionRangeSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let selectionAttrs = defaultMultipleSelectionWidget "SelectionRangeSliderView" "SelectionRangeSliderModel" layout dstyle let selectionAttrs = defaultMultipleSelectionWidget "SelectionRangeSliderView" "SelectionRangeSliderModel" layout $ StyleWidget dstyle
selectionRangeSliderAttrs = (Orientation =:: HorizontalOrientation) selectionRangeSliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
:& (ContinuousUpdate =:: True) :& (ContinuousUpdate =:: True)
......
...@@ -40,7 +40,7 @@ mkSelectionSlider = do ...@@ -40,7 +40,7 @@ mkSelectionSlider = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let selectionAttrs = defaultSelectionNonemptyWidget "SelectionSliderView" "SelectionSliderModel" layout dstyle let selectionAttrs = defaultSelectionNonemptyWidget "SelectionSliderView" "SelectionSliderModel" layout $ StyleWidget dstyle
selectionSliderAttrs = (Orientation =:: HorizontalOrientation) selectionSliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True) :& (ReadOut =:: True)
:& (ContinuousUpdate =:: True) :& (ContinuousUpdate =:: True)
......
...@@ -41,7 +41,7 @@ mkToggleButtons = do ...@@ -41,7 +41,7 @@ mkToggleButtons = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let selectionAttrs = defaultSelectionWidget "ToggleButtonsView" "ToggleButtonsModel" layout dstyle let selectionAttrs = defaultSelectionWidget "ToggleButtonsView" "ToggleButtonsModel" layout $ StyleWidget dstyle
toggleButtonsAttrs = (Tooltips =:: []) toggleButtonsAttrs = (Tooltips =:: [])
:& (Icons =:: []) :& (Icons =:: [])
:& (ButtonStyle =:: DefaultButton) :& (ButtonStyle =:: DefaultButton)
......
...@@ -119,12 +119,10 @@ singletons ...@@ -119,12 +119,10 @@ singletons
| ButtonColor | ButtonColor
| FontWeight | FontWeight
| DescriptionWidth | DescriptionWidth
-- Singletons for child style widgets | BarColor
| StyleButton | HandleColor
| StyleDescription | ButtonWidth
| StyleProgress | Style
| StyleSlider
| StyleToggleButton
-- Now the ones for layout -- Now the ones for layout
-- Every layout property comes with an L before the name to avoid conflict -- Every layout property comes with an L before the name to avoid conflict
-- The patterns from Layout.Common remove that leading L -- The patterns from Layout.Common remove that leading L
......
...@@ -40,7 +40,7 @@ mkComboboxWidget = do ...@@ -40,7 +40,7 @@ mkComboboxWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let txtWidget = defaultTextWidget "ComboboxView" "ComboboxModel" layout dstyle let txtWidget = defaultTextWidget "ComboboxView" "ComboboxModel" layout $ StyleWidget dstyle
boxWidget = (Options =:: []) boxWidget = (Options =:: [])
:& (EnsureOption =:: False) :& (EnsureOption =:: False)
:& RNil :& RNil
......
...@@ -37,7 +37,7 @@ mkHTMLWidget = do ...@@ -37,7 +37,7 @@ mkHTMLWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultStringWidget "HTMLView" "HTMLModel" layout dstyle let widgetState = WidgetState $ defaultStringWidget "HTMLView" "HTMLModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -37,7 +37,7 @@ mkHTMLMathWidget = do ...@@ -37,7 +37,7 @@ mkHTMLMathWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultStringWidget "HTMLMathView" "HTMLMathModel" layout dstyle let widgetState = WidgetState $ defaultStringWidget "HTMLMathView" "HTMLMathModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -37,7 +37,7 @@ mkLabelWidget = do ...@@ -37,7 +37,7 @@ mkLabelWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultStringWidget "LabelView" "LabelModel" layout dstyle let widgetState = WidgetState $ defaultStringWidget "LabelView" "LabelModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -40,7 +40,7 @@ mkPasswordWidget = do ...@@ -40,7 +40,7 @@ mkPasswordWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultTextWidget "PasswordView" "PasswordModel" layout dstyle let widgetState = WidgetState $ defaultTextWidget "PasswordView" "PasswordModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -40,7 +40,7 @@ mkTextWidget = do ...@@ -40,7 +40,7 @@ mkTextWidget = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let widgetState = WidgetState $ defaultTextWidget "TextView" "TextModel" layout dstyle let widgetState = WidgetState $ defaultTextWidget "TextView" "TextModel" layout $ StyleWidget dstyle
stateIO <- newIORef widgetState stateIO <- newIORef widgetState
......
...@@ -39,7 +39,7 @@ mkTextArea = do ...@@ -39,7 +39,7 @@ mkTextArea = do
layout <- mkLayout layout <- mkLayout
dstyle <- mkDescriptionStyle dstyle <- mkDescriptionStyle
let strAttrs = defaultStringWidget "TextareaView" "TextareaModel" layout dstyle let strAttrs = defaultStringWidget "TextareaView" "TextareaModel" layout $ StyleWidget dstyle
wgtAttrs = (Rows =:: Nothing) wgtAttrs = (Rows =:: Nothing)
:& (Disabled =:: False) :& (Disabled =:: False)
:& (ContinuousUpdate =:: True) :& (ContinuousUpdate =:: True)
......
...@@ -34,10 +34,8 @@ mkDescriptionStyle :: IO DescriptionStyle ...@@ -34,10 +34,8 @@ mkDescriptionStyle :: IO DescriptionStyle
mkDescriptionStyle = do mkDescriptionStyle = do
wid <- U.random wid <- U.random
let stl = defaultStyleWidget "DescriptionStyleModel" let stl = defaultDescriptionStyleWidget "DescriptionStyleModel"
but = (DescriptionWidth =:: "") btnStlState = WidgetState stl
:& RNil
btnStlState = WidgetState (stl <+> but)
stateIO <- newIORef btnStlState stateIO <- newIORef btnStlState
......
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module IHaskell.Display.Widgets.Style.ProgressStyle
( -- * Progress style
ProgressStyle
-- * Create a new progress style
, mkProgressStyle
) 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 'ProgressStyle' represents a Button Style from IPython.html.widgets.
type ProgressStyle = IPythonWidget 'ProgressStyleType
-- | Create a new button style
mkProgressStyle :: IO ProgressStyle
mkProgressStyle = do
wid <- U.random
let stl = defaultDescriptionStyleWidget "ProgressStyleModel"
but = (BarColor =:: Nothing)
:& RNil
btnStlState = WidgetState (stl <+> but)
stateIO <- newIORef btnStlState
let style = IPythonWidget wid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen style $ toJSON btnStlState
-- Return the style widget
return style
instance IHaskellWidget ProgressStyle where
getCommUUID = uuid
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module IHaskell.Display.Widgets.Style.SliderStyle
( -- * Slider style
SliderStyle
-- * Create a new slider style
, mkSliderStyle
) 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 'SliderStyle' represents a Button Style from IPython.html.widgets.
type SliderStyle = IPythonWidget 'SliderStyleType
-- | Create a new button style
mkSliderStyle :: IO SliderStyle
mkSliderStyle = do
wid <- U.random
let stl = defaultDescriptionStyleWidget "SliderStyleModel"
but = (HandleColor =:: Nothing)
:& RNil
btnStlState = WidgetState (stl <+> but)
stateIO <- newIORef btnStlState
let style = IPythonWidget wid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen style $ toJSON btnStlState
-- Return the style widget
return style
instance IHaskellWidget SliderStyle where
getCommUUID = uuid
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module IHaskell.Display.Widgets.Style.ToggleButtonsStyle
( -- * ToggleButtons style
ToggleButtonsStyle
-- * Create a new toggle buttons style
, mkToggleButtonsStyle
) 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 'ToggleButtonsStyle' represents a Button Style from IPython.html.widgets.
type ToggleButtonsStyle = IPythonWidget 'ToggleButtonsStyleType
-- | Create a new button style
mkToggleButtonsStyle :: IO ToggleButtonsStyle
mkToggleButtonsStyle = do
wid <- U.random
let stl = defaultDescriptionStyleWidget "ToggleButtonsStyleModel"
but = (ButtonWidth =:: "")
:& (FontWeight =:: DefaultWeight)
:& RNil
btnStlState = WidgetState (stl <+> but)
stateIO <- newIORef btnStlState
let style = IPythonWidget wid stateIO
-- Open a comm for this widget, and store it in the kernel state
widgetSendOpen style $ toJSON btnStlState
-- Return the style widget
return style
instance IHaskellWidget ToggleButtonsStyle where
getCommUUID = uuid
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment