@@ -21,7 +21,7 @@ import Data.List.NonEmpty (head, length, toUnfoldable) as Nel
21
21
import Data.Maybe (Maybe , maybe , fromMaybe )
22
22
import Data.Int (round , toNumber )
23
23
import Data.Rational ((%), fromInt )
24
- import Prelude (class Monoid , class Semigroup , map , mempty , (*), (+), ($), (||), (==))
24
+ import Prelude (class Monoid , class Semigroup , map , mempty , not , (*), (+), ($), (||), (&& ), (==))
25
25
26
26
-- | The default horizontal separation between notes in a bar (measured
27
27
-- | in pixels at a standard scale of 1.0)
@@ -136,17 +136,13 @@ estimateBarWidth hasClef hasTimeSig maybeKeySig pixelsPerItem abcBar =
136
136
if hasTimeSig then 1.0 else 0.0
137
137
keySigSpace =
138
138
maybe 0.0 keySignatureWidth maybeKeySig
139
- -- offer a little more space if the bar only has a note or two
140
- smallBarSpace =
141
- if ((noteCount == 2 ) || (noteCount == 2 )) then 0.5 else 0.0
142
139
in
143
140
round $
144
141
( clefSpace
145
142
+ timeSigSpace
146
143
+ keySigSpace
147
- + (tickableCountWidth noteCount)
144
+ + (tickableCountWidth hasClef noteCount)
148
145
+ (0.5 * toNumber graceCount)
149
- + smallBarSpace
150
146
) * pixelsPerItem
151
147
152
148
-- heuristic to decide how much width to dedicate to a key signature
@@ -165,10 +161,15 @@ keySignatureWidth keySignature =
165
161
_ ->
166
162
2.0
167
163
168
- -- | heuristic to allocate width to 'tickables'
169
- tickableCountWidth :: Int -> Number
170
- tickableCountWidth n =
171
- case n of
172
- 1 -> 1.5 -- just 1.0 is too small
173
- 2 -> 2.5 -- just 2.0 is too small
174
- _ -> toNumber n
164
+ -- | heuristic to allocate width to note 'tickables'
165
+ -- | in a non-start bar (with no clef) we need to offer a bit more space
166
+ -- | if there are only one or two noted
167
+ tickableCountWidth :: Boolean -> Int -> Number
168
+ tickableCountWidth hasClef n =
169
+ if hasClef then
170
+ toNumber n
171
+ else
172
+ case n of
173
+ 1 -> 1.90 -- just 1.0 is too small
174
+ 2 -> 2.70 -- just 2.0 is too small
175
+ _ -> toNumber n
0 commit comments