Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dktr0 committed Nov 7, 2018
2 parents 5068cf1 + b8e650a commit 93ad01e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
55 changes: 55 additions & 0 deletions client/src/Estuary/Tutorials/IntroTidalText.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,61 @@ import Estuary.Tidal.Types
introTidalText::MonadWidget t m => Tutorial t m
introTidalText = Tutorial IntroTidalText (const $ return (constDyn empty, never))


miniTidalWidget :: MonadWidget t m => Int -> String -> m (Dynamic t (Int, Definition),Event t Hint)
miniTidalWidget index initial = do








let deltaFuture = fmap forEditing delta
let textFuture = fmap snd deltaFuture

(evalButton,infoButton) <- divClass "fullWidthDiv" $ do
-- let initialParser = fst $ forEditing i
-- let parserMap = constDyn $ fromList $ fmap (\x -> (TidalTextNotation x,show x)) tidalParsers
-- d' <- dropdown initialParser parserMap $ (def :: DropdownConfig t TidalParser) & dropdownConfig_setValue .~ parserFuture
evalButton' <- divClass "textInputLabel" $ do
x <- button "eval"
dynText =<< mapDyn (maybe "" (const "!")) (nubDyn e)
return x
infoButton' <- divClass "referenceButton" $ button "?"
return (evalButton',infoButton')

(edit,eval) <- divClass "labelAndTextPattern" $ do
-- let parserValue = _dropdown_value d -- Dynamic t TidalParser
-- let parserEvent = _dropdown_change d
-- let initialText = snd $ forEditing i
textVisible <- toggle True infoButton
helpVisible <- toggle False infoButton
(textValue,textEvent,shiftEnter) <- hideableWidget textVisible "visibleArea" $ textAreaWidgetForPatternChain rows initialText textFuture
let languageToDisplayHelp = (TidalTextNotation MiniTidal)
-- let languageToDisplayHelp = ( _dropdown_value d)
hideableWidget helpVisible "visibleArea" $ languageHelpWidget' languageToDisplayHelp
v' <- mapDyn (\x-> (MiniTidal,)) textValue
let editEvent = tagDyn v' $ leftmost [() <$ textEvent]
let evalEvent = tagDyn v' $ leftmost [evalButton,shiftEnter]
return (editEvent,evalEvent)
let deltaPast = fmap forRendering delta
pastValue <- holdDyn (forRendering i) $ leftmost [deltaPast,eval]
futureValue <- holdDyn (forEditing i) $ leftmost [deltaFuture,edit]
value <- combineDyn f pastValue futureValue
let deltaUpEdit = tagDyn value edit
let deltaUpEval = tagDyn value eval
let deltaUp = leftmost [deltaUpEdit,deltaUpEval]
return (value,deltaUp,never)
where
f p x | p == x = Live p L3 -- *** TODO: this looks like it is a general pattern that should be with Live definitions
| otherwise = Edited p x




widget::(Dynamic t Context -> m (Dynamic t DefinitionMap, Event t Hint))
{- |
v1 :: Language -> (View, Definition)
v1 English = (LabelView 0, LabelText "Welcome to the introductory tutorial to Tidalcycles (or MiniTidal)")
Expand Down
11 changes: 9 additions & 2 deletions client/src/Estuary/Widgets/Sequencer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@ rowToGenPat' (val,pos) = Group (Live (fmap toAtom pos,Once) L4) Inert
parsed = maybe (maybe (Blank Inert) f $ readMaybe $ "\""++val++"\"") f $ readMaybe val
f x = Atom x Inert Once

{- sequencer' :: MonadWidget t m => [(String,[Bool])] -> Event t [(String,[Bool])] ->
m (Dynamic t [(String,[Bool])], Event t [(String,[Bool]), Event t Hint) -}

sequencer' ::MonadWidget t m => [(String, [Bool])] -> Event t [(String,[Bool])] -> m (Dynamic t ([(String,[Bool])], Event t [(String,[Bool])], Event t Hint))
sequencer' i update = do
let iVal = toGenPat $ fromList $ zip [0..] $ fmap (\(x,y)->(Just x,y)) i -- GeneralPattern String
let e = fmap (\(x,y) -> (Just x,y)) update
v <- sequencer Nothing iVal e
mapDyn (\(v,ev,h) -> (toSequence 0 v, fmap (toSequence 0) $ getChangeValues ev,h)) v
where
getChangeValues eve = fmapMaybe $ fmap (\x-> case x of ChangeValue a -> Just a; otherwise-> Nothing) eve


sequencer::(Read a, Ord a, MonadWidget t m, Show a, Eq a,T.Parseable a, T.Enumerable a) => Maybe a -> GeneralPattern a -> Event t (EditSignal (Sequence a)) -> m (Dynamic t (GeneralPattern a, Event t (EditSignal (GeneralPattern a)), Event t Hint))
Expand Down
11 changes: 11 additions & 0 deletions client/src/Estuary/Widgets/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,14 @@ viewWidget _ _ (EvaluableTextView n) i deltasDown = do
viewWidget _ _ SvgDisplayView _ _ = do
testOurDynSvg
return (constDyn Map.empty, never, never)


viewWidget ctx renderInfo (StructureView n) i deltasDown = do
let i' = f $ Map.findWithDefault (Structure EmptyTransformedPattern) n i
let deltasDown' = fmap (justStructures . justEditsInZone n) deltasDown
(value,edits,hints) <- topLevelTransformedPatternWidget i' deltasDown'
value' <- mapDyn (Map.singleton n . Structure) value
let edits' = fmap (ZoneRequest . Sited n . Edit . Structure) edits
return (value',edits',hints)
where f (Structure x) = x
f _ = EmptyTransformedPattern
2 changes: 1 addition & 1 deletion common/src/Estuary/Types/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ standardView = Views [
ViewDiv "eightMiddleL" (Views [LabelView 5, TidalTextView 6 3]),
ViewDiv "eightMiddleR" (Views [LabelView 7, TidalTextView 8 3]),
ViewDiv "eightBottomL" (Views [LabelView 9, TidalTextView 10 3]),
ViewDiv "eightBottomR" (Views [LabelView 11, SequenceView 12])
ViewDiv "eightBottomR" (Views [LabelView 11, SequenceView 12])
]

emptyView :: View
Expand Down

0 comments on commit 93ad01e

Please sign in to comment.