@@ -13,6 +13,7 @@ import Effect.Class (class MonadEffect)
1313import Halogen as H
1414import Halogen.HTML as HH
1515import Halogen.HTML.Core as HC
16+ import Halogen.HTML.Events as HE
1617import Halogen.HTML.Properties as HP
1718import Halogen.Query.Input (Input (..))
1819import Halogen.Svg.Attributes as SA
@@ -38,11 +39,13 @@ type SVGInput = { modelInfo :: ModelInfo, settings :: AppSettings }
3839data SVGAction
3940 = SVGRegisterElt Element
4041 | SVGReceive SVGInput
42+ | SVGToggleSurface
4143
4244type SVGState =
4345 { scoreElt :: Maybe Element
4446 , modelInfo :: ModelInfo
4547 , settings :: AppSettings
48+ , showSurface :: Boolean
4649 }
4750
4851svgComponent
@@ -58,35 +61,53 @@ svgComponent = H.mkComponent
5861 }
5962 }
6063 where
61- initialState { modelInfo, settings } = { modelInfo, settings, scoreElt: Nothing }
64+ initialState { modelInfo, settings } = { modelInfo, settings, scoreElt: Nothing , showSurface: true }
6265
63- render { modelInfo, settings } = HH .div [ class_ " wide" ]
64- [ svgContainer settings modelInfo ]
66+ render :: SVGState -> _
67+ render { modelInfo, settings, showSurface } = HH .div_
68+ [ HH .div [ class_ " content-np tab pure-form pure-g" ]
69+ [ HH .div [ class_ " pure-u-3-4" ]
70+ [ HH .input
71+ [ HP .type_ $ HP.InputCheckbox
72+ , HP .checked showSurface
73+ , HE .onChange \_ -> SVGToggleSurface
74+ , HP .id " showSurface"
75+ ]
76+ , HH .label [ HP .for " showSurface" ] [ HH .text " show full surface below graph" ]
77+ ]
78+ ]
79+ , HH .div [ class_ " wide" ]
80+ [ svgContainer settings showSurface modelInfo ]
81+ ]
6582
6683 handleSVGAction action = do
6784 case action of
68- SVGRegisterElt elt -> do
85+ SVGRegisterElt elt ->
6986 H .modify_ \st -> st { scoreElt = Just elt }
7087 SVGReceive { modelInfo, settings } ->
7188 H .modify_ \st -> st { modelInfo = modelInfo, settings = settings }
89+ SVGToggleSurface ->
90+ H .modify_ \st -> st { showSurface = not st.showSurface }
7291 redrawGraph
7392
7493svgContainer
7594 :: forall p
7695 . AppSettings
96+ -> Boolean
7797 -> ModelInfo
7898 -> HH.HTML p SVGAction
79- svgContainer sett { model, graph } =
99+ svgContainer sett showSurface { model, graph } =
80100 let
81101 isComplete = L .length model.reduction.segments == 1
82102 width = scalex sett (graph.maxx + 1.0 ) + sliceDistance / 2.0
83103 staff = model.styles.staff
84104 systemHeight = if staff == GrandStaff then scoreHeightGrand else scoreHeightSingle
85105 extraRows = if isComplete then 0.0 else 1.0
86- height = systemHeight * (graph.maxd + 1.0 + extraRows) + axisHeight
106+ surfaceRows = if showSurface then 1.0 else 0.0
107+ height = systemHeight * (graph.maxd + surfaceRows + extraRows) + axisHeight
87108 in
88109 HH .div
89- [ HP .style " overflow: scroll; position: relative; left: 50%; transform: translateX(-50%); width: auto; "
110+ [ HP .style " overflow: scroll;"
90111 ]
91112 [ SE .svg
92113 [ SA .width width
@@ -105,7 +126,7 @@ svgContainer sett { model, graph } =
105126
106127redrawGraph :: forall o m s . (MonadEffect m ) => H.HalogenM SVGState SVGAction s o m Unit
107128redrawGraph = do
108- { modelInfo: { model, graph, surface }, settings, scoreElt } <- H .get
129+ { modelInfo: { model, graph, surface }, settings, scoreElt, showSurface } <- H .get
109130 case scoreElt of
110131 Nothing -> pure unit
111132 Just elt ->
@@ -114,4 +135,4 @@ redrawGraph = do
114135 toX x = scalex settings x -- - (noteSize / 2.0)
115136 in
116137 H .liftEffect $ do
117- insertScore elt $ renderGraph graph model.piece surface model.styles Nothing Nothing toX totalWidth scoreScale
138+ insertScore elt $ renderGraph graph model.piece surface model.styles Nothing Nothing toX totalWidth scoreScale showSurface
0 commit comments