LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 b.translate_axis (beam_translation * i * stemdir * -1, Y_AXIS); | 140 b.translate_axis (beam_translation * i * stemdir * -1, Y_AXIS); |
141 mol.add_stencil (b); | 141 mol.add_stencil (b); |
142 } | 142 } |
143 return mol; | 143 return mol; |
144 } | 144 } |
145 | 145 |
146 MAKE_SCHEME_CALLBACK (Stem_tremolo, pure_height, 3); | 146 MAKE_SCHEME_CALLBACK (Stem_tremolo, pure_height, 3); |
147 SCM | 147 SCM |
148 Stem_tremolo::pure_height (SCM smob, SCM, SCM) | 148 Stem_tremolo::pure_height (SCM smob, SCM, SCM) |
149 { | 149 { |
150 Grob *me = unsmob_grob (smob); | 150 Item *me = unsmob_item (smob); |
151 | 151 |
152 /* | 152 /* |
153 Cannot use the real slope, since it looks at the Beam. | 153 Cannot use the real slope, since it looks at the Beam. |
154 */ | 154 */ |
155 Stencil s1 (untranslated_stencil (me, 0.35)); | 155 Stencil s1 (untranslated_stencil (me, 0.35)); |
156 | 156 Item *stem = unsmob_item (me->get_object ("stem")); |
157 return ly_interval2scm (s1.extent (Y_AXIS)); | 157 if (!stem) |
| 158 return ly_interval2scm (s1.extent (Y_AXIS)); |
| 159 |
| 160 Direction stemdir = get_grob_direction (stem); |
| 161 if (stemdir == 0) |
| 162 stemdir = UP; |
| 163 |
| 164 Spanner *beam = Stem::get_beam (stem); |
| 165 |
| 166 if (!beam) |
| 167 return ly_interval2scm (s1.extent (Y_AXIS)); |
| 168 |
| 169 Interval ph = stem->pure_height (stem, 0, INT_MAX); |
| 170 Stem_info si = Stem::get_stem_info (stem); |
| 171 ph[-stemdir] = si.shortest_y_; |
| 172 int beam_count = Stem::beam_multiplicity (stem).length () + 1; |
| 173 Real beam_translation = get_beam_translation (me); |
| 174 |
| 175 ph = ph - stemdir * max (beam_count, 1) * beam_translation; |
| 176 ph = ph - ph.center (); |
| 177 |
| 178 return ly_interval2scm (ph); |
158 } | 179 } |
159 | 180 |
160 MAKE_SCHEME_CALLBACK (Stem_tremolo, width, 1); | 181 MAKE_SCHEME_CALLBACK (Stem_tremolo, width, 1); |
161 SCM | 182 SCM |
162 Stem_tremolo::width (SCM smob) | 183 Stem_tremolo::width (SCM smob) |
163 { | 184 { |
164 Grob *me = unsmob_grob (smob); | 185 Grob *me = unsmob_grob (smob); |
165 | 186 |
166 /* | 187 /* |
167 Cannot use the real slope, since it looks at the Beam. | 188 Cannot use the real slope, since it looks at the Beam. |
(...skipping 24 matching lines...) Expand all Loading... |
192 stemdir = UP; | 213 stemdir = UP; |
193 | 214 |
194 bool whole_note = Stem::duration_log (stem) <= 0; | 215 bool whole_note = Stem::duration_log (stem) <= 0; |
195 | 216 |
196 /* for a whole note, we position relative to the notehead, so we want the | 217 /* for a whole note, we position relative to the notehead, so we want the |
197 stencil aligned on the flag closest to the head */ | 218 stencil aligned on the flag closest to the head */ |
198 Direction stencil_dir = whole_note ? -stemdir : stemdir; | 219 Direction stencil_dir = whole_note ? -stemdir : stemdir; |
199 return raw_stencil (me, slope, stencil_dir); | 220 return raw_stencil (me, slope, stencil_dir); |
200 } | 221 } |
201 | 222 |
202 Stencil | 223 MAKE_SCHEME_CALLBACK (Stem_tremolo, calc_y_offset, 1); |
203 Stem_tremolo::translated_stencil (Grob *me, Real slope) | 224 SCM |
204 { | 225 Stem_tremolo::calc_y_offset (SCM smob) |
205 Stencil mol = untranslated_stencil (me, slope); | 226 { |
206 | 227 Grob *me = unsmob_grob (smob); |
207 Grob *stem = unsmob_grob (me->get_object ("stem")); | 228 return scm_from_double (y_offset (me, false)); |
| 229 } |
| 230 |
| 231 MAKE_SCHEME_CALLBACK (Stem_tremolo, pure_calc_y_offset, 3); |
| 232 SCM |
| 233 Stem_tremolo::pure_calc_y_offset (SCM smob, |
| 234 SCM, /* start */ |
| 235 SCM /* end */) |
| 236 { |
| 237 Grob *me = unsmob_grob (smob); |
| 238 return scm_from_double (y_offset (me, true)); |
| 239 } |
| 240 |
| 241 Real |
| 242 Stem_tremolo::y_offset (Grob *me, bool pure) |
| 243 { |
| 244 Item *stem = unsmob_item (me->get_object ("stem")); |
208 if (!stem) | 245 if (!stem) |
209 return Stencil (); | 246 return 0.0; |
210 | 247 |
211 Direction stemdir = get_grob_direction (stem); | 248 Direction stemdir = get_grob_direction (stem); |
212 if (stemdir == 0) | 249 if (stemdir == 0) |
213 stemdir = UP; | 250 stemdir = UP; |
214 | 251 |
215 Spanner *beam = Stem::get_beam (stem); | 252 Spanner *beam = Stem::get_beam (stem); |
216 Real beam_translation = get_beam_translation (me); | 253 Real beam_translation = get_beam_translation (me); |
217 | 254 |
218 int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0; | 255 int beam_count = beam ? (Stem::beam_multiplicity (stem).length () + 1) : 0; |
| 256 |
| 257 if (pure && beam) |
| 258 { |
| 259 Interval ph = stem->pure_height (stem, 0, INT_MAX); |
| 260 Stem_info si = Stem::get_stem_info (stem); |
| 261 ph[-stemdir] = si.shortest_y_; |
| 262 |
| 263 return (ph - stemdir * max (beam_count, 1) * beam_translation)[stemdir] -
stemdir * 0.5 * me->pure_height (me, 0, INT_MAX).length (); |
| 264 } |
219 | 265 |
220 Real end_y | 266 Real end_y |
221 = stem->extent (stem, Y_AXIS)[stemdir] | 267 = stem->extent (stem, Y_AXIS)[stemdir] |
222 - stemdir * max (beam_count, 1) * beam_translation; | 268 - stemdir * max (beam_count, 1) * beam_translation; |
223 | 269 |
224 if (!beam && Stem::duration_log (stem) >= 3) | 270 if (!beam && Stem::duration_log (stem) >= 3) |
225 { | 271 { |
226 end_y -= stemdir * (Stem::duration_log (stem) - 2) * beam_translation; | 272 end_y -= stemdir * (Stem::duration_log (stem) - 2) * beam_translation; |
227 if (stemdir == UP) | 273 if (stemdir == UP) |
228 end_y -= stemdir * beam_translation * 0.5; | 274 end_y -= stemdir * beam_translation * 0.5; |
229 } | 275 } |
230 | 276 |
231 bool whole_note = Stem::duration_log (stem) <= 0; | 277 bool whole_note = Stem::duration_log (stem) <= 0; |
232 if (whole_note) | 278 if (whole_note) |
233 { | 279 { |
234 /* we shouldn't position relative to the end of the stem since the stem | 280 /* we shouldn't position relative to the end of the stem since the stem |
235 is invisible */ | 281 is invisible */ |
236 Real ss = Staff_symbol_referencer::staff_space (me); | 282 Real ss = Staff_symbol_referencer::staff_space (me); |
237 vector<int> nhp = Stem::note_head_positions (stem); | 283 vector<int> nhp = Stem::note_head_positions (stem); |
238 Real note_head = (stemdir == UP ? nhp.back () : nhp[0]) * ss / 2; | 284 Real note_head = (stemdir == UP ? nhp.back () : nhp[0]) * ss / 2; |
239 end_y = note_head + stemdir * 1.5; | 285 end_y = note_head + stemdir * 1.5; |
240 } | 286 } |
241 mol.translate_axis (end_y, Y_AXIS); | 287 |
242 | 288 return end_y; |
243 return mol; | |
244 } | 289 } |
245 | 290 |
246 MAKE_SCHEME_CALLBACK (Stem_tremolo, print, 1); | 291 MAKE_SCHEME_CALLBACK (Stem_tremolo, print, 1); |
247 SCM | 292 SCM |
248 Stem_tremolo::print (SCM grob) | 293 Stem_tremolo::print (SCM grob) |
249 { | 294 { |
250 Grob *me = unsmob_grob (grob); | 295 Grob *me = unsmob_grob (grob); |
251 | 296 |
252 Stencil s = translated_stencil (me, robust_scm2double (me->get_property ("slop
e"), 0.25)); | 297 Stencil s = untranslated_stencil (me, robust_scm2double (me->get_property ("sl
ope"), 0.25)); |
253 return s.smobbed_copy (); | 298 return s.smobbed_copy (); |
254 } | 299 } |
255 | 300 |
256 ADD_INTERFACE (Stem_tremolo, | 301 ADD_INTERFACE (Stem_tremolo, |
257 "A beam slashing a stem to indicate a tremolo. The property" | 302 "A beam slashing a stem to indicate a tremolo. The property" |
258 " @code{style} can be @code{default} or @code{rectangle}.", | 303 " @code{style} can be @code{default} or @code{rectangle}.", |
259 | 304 |
260 /* properties */ | 305 /* properties */ |
261 "beam-thickness " | 306 "beam-thickness " |
262 "beam-width " | 307 "beam-width " |
263 "flag-count " | 308 "flag-count " |
264 "length-fraction " | 309 "length-fraction " |
265 "stem " | 310 "stem " |
266 "style " | 311 "style " |
267 "slope " | 312 "slope " |
268 ); | 313 ); |
LEFT | RIGHT |