Commit c05da985 authored by David Davó's avatar David Davó

Adding new fields to widgets

parent 792ac0ef
......@@ -31,7 +31,7 @@ The initial state must *at least* have the following fields in the `data.state`
- `_view_module_version`
- `_view_name`
You can see more info on the model state of widgets [here](https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/jupyterwidgetmodels.v8.md).
You can see more info on the model state of widgets [here](https://github.com/jupyter-widgets/ipywidgets/blob/master/packages/schema/jupyterwidgetmodels.v8.md), or as a json definition [here](https://github.com/jupyter-widgets/ipywidgets/blob/79312fb164e058c3a2fddd9f3ef35493515ed64b/packages/schema/jupyterwidgetmodels.latest.json)
> Warning!: By default there are two widgets modules: `@jupyter-widgets/controls` and `@jupyter-widgets/base`.
......
......@@ -13,4 +13,10 @@ then remove the output from the Nootebooks with:
```bash
jupyter nbconvert *.ipynb --to notebook --inplace --clear-output
```
\ No newline at end of file
```
## Things to do
- [ ] Validate the JSON implementation of widgets against the MsgSpec schema
- [ ] Create integration tests for the widgets
- [ ] Make the `output` widget work
- [ ] Processing of widget messages concurrently
\ No newline at end of file
......@@ -18,6 +18,7 @@ import Prelude
import Control.Monad (void)
import Data.Aeson
import Data.IORef (newIORef)
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -35,7 +36,10 @@ mkCheckBox = do
-- Default properties, with a random uuid
wid <- U.random
let widgetState = WidgetState $ defaultBoolWidget "CheckboxView" "CheckboxModel"
let boolAttrs = defaultBoolWidget "CheckboxView" "CheckboxModel"
checkBoxAttrs = (Indent =:: True)
:& RNil
widgetState = WidgetState $ boolAttrs <+> checkBoxAttrs
stateIO <- newIORef widgetState
......
......@@ -37,8 +37,7 @@ mkToggleButton = do
wid <- U.random
let boolState = defaultBoolWidget "ToggleButtonView" "ToggleButtonModel"
toggleState = (Tooltip =:: "")
:& (Icon =:: "")
toggleState = (Icon =:: "")
:& (ButtonStyle =:: DefaultButton)
:& RNil
widgetState = WidgetState (boolState <+> toggleState)
......
......@@ -35,15 +35,13 @@ mkButton = do
-- Default properties, with a random uuid
wid <- U.random
let dom = defaultDOMWidget "ButtonView" "ButtonModel"
but = (Description =:: "")
:& (Tooltip =:: "")
:& (Disabled =:: False)
let ddw = defaultDescriptionWidget "ButtonView" "ButtonModel"
but = (Disabled =:: False)
:& (Icon =:: "")
:& (ButtonStyle =:: DefaultButton)
:& (ClickHandler =:: return ())
:& RNil
buttonState = WidgetState (dom <+> but)
buttonState = WidgetState (ddw <+> but)
stateIO <- newIORef buttonState
......
......@@ -32,23 +32,9 @@ pattern ModelModule = S.SModelModule
pattern ModelModuleVersion = S.SModelModuleVersion
pattern ModelName = S.SModelName
pattern DisplayHandler = S.SDisplayHandler
pattern Visible = S.SVisible
pattern CSS = S.SCSS
pattern DOMClasses = S.SDOMClasses
pattern Width = S.SWidth
pattern Height = S.SHeight
pattern Padding = S.SPadding
pattern Margin = S.SMargin
pattern Color = S.SColor
pattern BackgroundColor = S.SBackgroundColor
pattern BorderColor = S.SBorderColor
pattern BorderWidth = S.SBorderWidth
pattern BorderRadius = S.SBorderRadius
pattern BorderStyle = S.SBorderStyle
pattern FontStyle = S.SFontStyle
pattern FontWeight = S.SFontWeight
pattern FontSize = S.SFontSize
pattern FontFamily = S.SFontFamily
pattern Description = S.SDescription
pattern ClickHandler = S.SClickHandler
pattern SubmitHandler = S.SSubmitHandler
......@@ -83,9 +69,8 @@ pattern LowerFloat = S.SLowerFloat
pattern UpperFloat = S.SUpperFloat
pattern Orientation = S.SOrientation
pattern BaseFloat = S.SBaseFloat
pattern ShowRange = S.SShowRange
pattern ReadOut = S.SReadOut
pattern SliderColor = S.SSliderColor
pattern ReadOutFormat = S.SReadOutFormat
pattern BarStyle = S.SBarStyle
pattern ChangeHandler = S.SChangeHandler
pattern Children = S.SChildren
......@@ -98,8 +83,12 @@ pattern Align = S.SAlign
pattern Titles = S.STitles
pattern SelectedIndex = S.SSelectedIndex
pattern ReadOutMsg = S.SReadOutMsg
pattern Indent = S.SIndent
pattern Child = S.SChild
pattern Selector = S.SSelector
pattern ContinuousUpdate = S.SContinuousUpdate
pattern Tabbable = S.STabbable
pattern Rows = S.SRows
-- | Close a widget's comm
closeWidget :: IHaskellWidget w => w -> IO ()
......
......@@ -19,6 +19,7 @@ import Control.Monad (void)
import Data.Aeson
import Data.IORef (newIORef)
import qualified Data.Scientific as Sci
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -36,7 +37,12 @@ mkBoundedFloatText = do
-- Default properties, with a random uuid
wid <- U.random
let widgetState = WidgetState $ defaultBoundedFloatWidget "FloatTextView" "BoundedFloatTextModel"
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatTextView" "BoundedFloatTextModel"
textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False)
:& (StepFloat =:: Nothing)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> textAttrs
stateIO <- newIORef widgetState
......
......@@ -19,7 +19,7 @@ import Control.Monad (void)
import Data.Aeson
import Data.IORef (newIORef)
import qualified Data.Scientific as Sci
import Data.Vinyl (Rec(..), (<+>), rput)
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -37,15 +37,16 @@ mkFloatLogSlider = do
-- Default properties, with a random uuid
wid <- U.random
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatLogSliderView" "FloatLogSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False)
let boundedLogFloatAttrs = defaultBoundedLogFloatWidget "FloatLogSliderView" "FloatLogSliderModel"
sliderAttrs = (StepFloat =:: Just 0.1)
:& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True)
:& (SliderColor =:: "")
:& (ReadOutFormat =:: ".3g")
:& (ContinuousUpdate =:: True)
:& (Disabled =:: False)
:& (BaseFloat =:: 10.0)
:& RNil
widgetState = WidgetState $ rput (MaxFloat =:: 4.0)
$ boundedFloatAttrs <+> sliderAttrs
widgetState = WidgetState $ boundedLogFloatAttrs <+> sliderAttrs
stateIO <- newIORef widgetState
......
......@@ -38,10 +38,12 @@ mkFloatSlider = do
wid <- U.random
let boundedFloatAttrs = defaultBoundedFloatWidget "FloatSliderView" "FloatSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False)
sliderAttrs = (StepFloat =:: Just 0.1)
:& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True)
:& (SliderColor =:: "")
:& (ReadOutFormat =:: ".2f")
:& (ContinuousUpdate =:: True)
:& (Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> sliderAttrs
......
......@@ -39,10 +39,12 @@ mkFloatRangeSlider = do
wid <- U.random
let boundedFloatAttrs = defaultBoundedFloatRangeWidget "FloatRangeSliderView" "FloatRangeSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: True)
sliderAttrs = (StepFloat =:: Just 0.1)
:& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True)
:& (SliderColor =:: "")
:& (ReadOutFormat =:: ".2f")
:& (ContinuousUpdate =:: True)
:& (Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedFloatAttrs <+> sliderAttrs
......
......@@ -38,7 +38,9 @@ mkFloatText = do
wid <- U.random
let floatAttrs = defaultFloatWidget "FloatTextView" "FloatTextModel"
textAttrs = (StepFloat =:+ 0.1)
textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False)
:& (StepFloat =:: Nothing)
:& RNil
widgetState = WidgetState $ floatAttrs <+> textAttrs
......
......@@ -19,6 +19,7 @@ import Control.Monad (void)
import Data.Aeson
import Data.IORef (newIORef)
import qualified Data.Scientific as Sci
import Data.Vinyl (Rec(..), (<+>))
import IHaskell.Display
import IHaskell.Eval.Widgets
......@@ -36,7 +37,12 @@ mkBoundedIntText = do
-- Default properties, with a random uuid
wid <- U.random
let widgetState = WidgetState $ defaultBoundedIntWidget "IntTextView" "BoundedIntTextModel"
let boundedIntAttrs = defaultBoundedIntWidget "IntTextView" "BoundedIntTextModel"
textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False)
:& (StepInt =:: Just 1)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> textAttrs
stateIO <- newIORef widgetState
......
......@@ -38,10 +38,12 @@ mkIntSlider = do
wid <- U.random
let boundedIntAttrs = defaultBoundedIntWidget "IntSliderView" "IntSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: False)
sliderAttrs = (StepInt =:: Just 1)
:& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True)
:& (SliderColor =:: "")
:& (ReadOutFormat =:: "d")
:& (ContinuousUpdate =:: True)
:& (Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> sliderAttrs
......
......@@ -39,10 +39,12 @@ mkIntRangeSlider = do
wid <- U.random
let boundedIntAttrs = defaultBoundedIntRangeWidget "IntRangeSliderView" "IntRangeSliderModel"
sliderAttrs = (Orientation =:: HorizontalOrientation)
:& (ShowRange =:: True)
sliderAttrs = (StepInt =:: Just 1)
:& (Orientation =:: HorizontalOrientation)
:& (ReadOut =:: True)
:& (SliderColor =:: "")
:& (ReadOutFormat =:: "d")
:& (ContinuousUpdate =:: True)
:& (Disabled =:: False)
:& RNil
widgetState = WidgetState $ boundedIntAttrs <+> sliderAttrs
......
......@@ -38,7 +38,9 @@ mkIntText = do
wid <- U.random
let intAttrs = defaultIntWidget "IntTextView" "IntTextModel"
textAttrs = (StepInt =:+ 1)
textAttrs = (Disabled =:: False)
:& (ContinuousUpdate =:: False)
:& (StepInt =:: Just 1)
:& RNil
widgetState = WidgetState $ intAttrs <+> textAttrs
......
......@@ -163,7 +163,7 @@ liftToWidgets func rc initvals = do
-- Set initial values for all widgets
setInitialValues initializers widgets initvals
-- applyValueSetters valueSetters widgets $ getList defvals
setField out Width 500
-- setField out Width 500
-- TODO This can't be set right now since we switched FlexBox to a regular
-- Box. This is a styling/layout parameter now but these haven't been implemented yet.
-- setField bx Orientation VerticalOrientation
......
......@@ -38,23 +38,9 @@ singletons
| ModelModuleVersion
| ModelName
| DisplayHandler
| Visible
| CSS
| DOMClasses
| Width
| Height
| Padding
| Margin
| Color
| BackgroundColor
| BorderColor
| BorderWidth
| BorderRadius
| BorderStyle
| FontStyle
| FontWeight
| FontSize
| FontFamily
| Description
| ClickHandler
| SubmitHandler
......@@ -89,9 +75,8 @@ singletons
| UpperFloat
| Orientation
| BaseFloat
| ShowRange
| ReadOut
| SliderColor
| ReadOutFormat
| BarStyle
| ChangeHandler
| Children
......@@ -104,7 +89,11 @@ singletons
| Titles
| SelectedIndex
| ReadOutMsg
| Indent
| Child
| Selector
| ContinuousUpdate
| Tabbable
| Rows
deriving (Eq, Ord, Show)
|]
......@@ -36,7 +36,11 @@ mkTextWidget = do
-- Default properties, with a random uuid
wid <- U.random
let strWidget = defaultStringWidget "TextView" "TextModel"
txtWidget = (SubmitHandler =:: return ()) :& (ChangeHandler =:: return ()) :& RNil
txtWidget = (Disabled =:: False)
:& (ContinuousUpdate =:: True)
:& (SubmitHandler =:: return ())
:& (ChangeHandler =:: return ())
:& RNil
widgetState = WidgetState $ strWidget <+> txtWidget
stateIO <- newIORef widgetState
......
......@@ -35,7 +35,11 @@ mkTextArea = do
-- Default properties, with a random uuid
wid <- U.random
let strAttrs = defaultStringWidget "TextareaView" "TextareaModel"
wgtAttrs = (ChangeHandler =:: return ()) :& RNil
wgtAttrs = (Rows =:: Nothing)
:& (Disabled =:: False)
:& (ContinuousUpdate =:: True)
:& (ChangeHandler =:: return ())
:& RNil
widgetState = WidgetState $ strAttrs <+> wgtAttrs
stateIO <- newIORef widgetState
......
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