Skip to content

Commit cf75287

Browse files
committed
add initial styling support (notes and slices)
1 parent e7753e7 commit cf75287

29 files changed

+2966
-1676
lines changed

annotation-tool/package-lock.json

Lines changed: 30 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

annotation-tool/spago.dhall

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You can edit this file as you like.
2323
, "maybe"
2424
, "numbers"
2525
, "ordered-collections"
26+
, "unordered-collections"
2627
, "partial"
2728
, "pitches"
2829
, "prelude"

annotation-tool/src/App/Common.purs

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
module App.Common where
22

33
import Prelude
4+
45
import Data.Generic.Rep (class Generic)
56
import Data.List as L
67
import Data.Maybe (Maybe(..), maybe)
78
import Data.Pitches (SPitch)
89
import Data.Show.Generic (genericShow)
910
import Halogen as H
10-
import ProtoVoices.Model (Model, Note, NoteExplanation, Parents(..), Piece, SliceId, StartStop(..), TransId, setHoriExplParent, setLeftExplParent, setRightExplParent)
11+
import ProtoVoices.Folding (Graph)
12+
import ProtoVoices.Model (Model, Note, NoteExplanation, Parents(..), Piece, SliceId, StartStop(..), Styles, TransId, BottomSurface, setHoriExplParent, setLeftExplParent, setRightExplParent)
13+
import ProtoVoices.Validation (Validation)
1114
import Web.DOM.Element (Element)
1215
import Web.UIEvent.KeyboardEvent (KeyboardEvent)
1316
import Web.UIEvent.WheelEvent (WheelEvent)
@@ -18,22 +21,31 @@ data Selection
1821
| SelTrans TransId
1922
| SelNote { note :: Note, expl :: NoteExplanation, parents :: Parents SliceId, slice :: SliceId }
2023

21-
type AppState
22-
= { selected :: Selection
23-
, model :: Maybe Model
24-
, name :: String
25-
, undoStack :: L.List { m :: Model, name :: String }
26-
, redoStack :: L.List { m :: Model, name :: String }
27-
, tab :: Maybe Tab
28-
, settings :: AppSettings
29-
, scoreElt :: Maybe Element
30-
}
31-
32-
type AppSlots
33-
= ( exportTab :: forall query. H.Slot query Void Int
34-
, importTab :: forall query. H.Slot query ImportOutput Int
35-
, settingsTab :: forall query. H.Slot query AppSettings Int
36-
)
24+
type AppState =
25+
{ selected :: Selection
26+
, loaded :: Maybe { model :: Model, surface :: BottomSurface }
27+
, name :: String
28+
, undoStack :: L.List { m :: Model, name :: String }
29+
, redoStack :: L.List { m :: Model, name :: String }
30+
, tab :: Maybe Tab
31+
, settings :: AppSettings
32+
, scoreElt :: Maybe Element
33+
}
34+
35+
type ModelInfo =
36+
{ model :: Model
37+
, graph :: Graph
38+
, validation :: Validation
39+
, surface :: BottomSurface
40+
}
41+
42+
type AppSlots =
43+
( exportTab :: forall query. H.Slot query Void Int
44+
, importTab :: forall query. H.Slot query ImportOutput Int
45+
, styleTab :: forall query. H.Slot query Styles Int
46+
, settingsTab :: forall query. H.Slot query AppSettings Int
47+
, svgTab :: forall query. H.Slot query Void Int
48+
)
3749

3850
derive instance eqOuterSelection :: Eq Selection
3951

@@ -80,20 +92,21 @@ outerSelected = case _ of
8092

8193
addParentToNote :: Selection -> SliceId -> Note -> GraphAction
8294
addParentToNote sel sliceId parNote
83-
| SelNote { note: selNote, parents, expl } <- sel = case parents of
84-
MergeParents { left, right }
85-
| sliceId == left
86-
, Just expl' <- setLeftExplParent selNote.pitch (Just parNote) expl -> setExpl expl'
87-
| sliceId == right
88-
, Just expl' <- setRightExplParent selNote.pitch (Just parNote) expl -> setExpl expl'
89-
| otherwise -> NoOp
90-
VertParent vslice
91-
| sliceId == vslice
92-
, Just expl' <- setHoriExplParent selNote.pitch (Just parNote) expl -> setExpl expl'
93-
| otherwise -> NoOp
94-
NoParents -> NoOp
95-
where
96-
setExpl e = SetNoteExplanation { noteId: selNote.id, expl: e }
95+
| SelNote { note: selNote, parents, expl } <- sel =
96+
case parents of
97+
MergeParents { left, right }
98+
| sliceId == left
99+
, Just expl' <- setLeftExplParent selNote.pitch (Just parNote) expl -> setExpl expl'
100+
| sliceId == right
101+
, Just expl' <- setRightExplParent selNote.pitch (Just parNote) expl -> setExpl expl'
102+
| otherwise -> NoOp
103+
VertParent vslice
104+
| sliceId == vslice
105+
, Just expl' <- setHoriExplParent selNote.pitch (Just parNote) expl -> setExpl expl'
106+
| otherwise -> NoOp
107+
NoParents -> NoOp
108+
where
109+
setExpl e = SetNoteExplanation { noteId: selNote.id, expl: e }
97110
| otherwise = NoOp
98111

99112
removeParent :: Note -> NoteExplanation -> (SPitch -> Maybe Note -> NoteExplanation -> Maybe NoteExplanation) -> GraphAction
@@ -105,7 +118,9 @@ data Tab
105118
= HelpTab
106119
| ImportTab
107120
| ExportTab
121+
| StyleTab
108122
| SettingsTab
123+
| SVGTab
109124
| DebugTab
110125

111126
derive instance eqTab :: Eq Tab
@@ -115,21 +130,20 @@ data ImportThing
115130
-- | ImportCurrentSurface
116131
| ImportModel Model
117132

118-
type ImportOutput
119-
= { name :: String, thing :: ImportThing }
133+
type ImportOutput = { name :: String, thing :: ImportThing }
120134

121-
type AppSettings
122-
= { flatHori :: Boolean
123-
, showAllEdges :: Boolean
124-
, showScore :: Boolean
125-
, xscale :: Number
126-
, yscale :: Number
127-
}
135+
type AppSettings =
136+
{ flatHori :: Boolean
137+
, showAllEdges :: Boolean
138+
, showScore :: Boolean
139+
, xscale :: Number
140+
, yscale :: Number
141+
}
128142

129143
defaultSettings :: AppSettings
130144
defaultSettings =
131145
{ flatHori: true
132-
, showAllEdges: false
146+
, showAllEdges: true
133147
, showScore: true
134148
, xscale: 0.0
135149
, yscale: 0.0
@@ -140,6 +154,7 @@ data GraphAction
140154
| Init
141155
| HandleImport ImportOutput
142156
| HandleSettings AppSettings
157+
| HandleStyle Styles
143158
| SwitchTab (Maybe Tab)
144159
| HandleKey KeyboardEvent
145160
| HandleScroll WheelEvent

0 commit comments

Comments
 (0)