OLD | NEW |
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) 1999--2011 Jan Nieuwenhuizen <janneke@gnu.org> | 4 Copyright (C) 1999--2011 Jan Nieuwenhuizen <janneke@gnu.org> |
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 |
11 LilyPond is distributed in the hope that it will be useful, | 11 LilyPond is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 16 You should have received a copy of the GNU General Public License |
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. | 17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>. |
18 */ | 18 */ |
19 | 19 |
20 #include "bar-line.hh" | 20 #include "bar-line.hh" |
21 #include "beaming-pattern.hh" | 21 #include "beaming-pattern.hh" |
22 #include "beam.hh" | 22 #include "beam.hh" |
23 #include "context.hh" | 23 #include "context.hh" |
| 24 #include "context-handle.hh" |
24 #include "duration.hh" | 25 #include "duration.hh" |
25 #include "engraver.hh" | 26 #include "engraver.hh" |
26 #include "item.hh" | 27 #include "item.hh" |
27 #include "rest.hh" | 28 #include "rest.hh" |
28 #include "spanner.hh" | 29 #include "spanner.hh" |
29 #include "stream-event.hh" | 30 #include "stream-event.hh" |
30 #include "stem.hh" | 31 #include "stem.hh" |
31 #include "warn.hh" | 32 #include "warn.hh" |
32 | 33 |
33 #include "translator.icc" | 34 #include "translator.icc" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 vector<Item *> *stems_; | 74 vector<Item *> *stems_; |
74 | 75 |
75 int process_acknowledged_count_; | 76 int process_acknowledged_count_; |
76 Moment last_add_mom_; | 77 Moment last_add_mom_; |
77 /* | 78 /* |
78 Projected ending of the beam we're working on. | 79 Projected ending of the beam we're working on. |
79 */ | 80 */ |
80 Moment extend_mom_; | 81 Moment extend_mom_; |
81 Moment beam_start_moment_; | 82 Moment beam_start_moment_; |
82 Moment beam_start_location_; | 83 Moment beam_start_location_; |
83 Context *beam_start_context_; | 84 /* |
| 85 Handle on the starting staff keeps it alive until beam is comlete |
| 86 */ |
| 87 Context_handle beam_start_context_; |
84 | 88 |
85 // We act as if beam were created, and start a grouping anyway. | 89 // We act as if beam were created, and start a grouping anyway. |
86 Beaming_pattern *grouping_; | 90 Beaming_pattern *grouping_; |
87 SCM beam_settings_; | 91 SCM beam_settings_; |
88 | 92 |
89 Beaming_pattern *finished_grouping_; | 93 Beaming_pattern *finished_grouping_; |
90 | 94 |
91 Beaming_options beaming_options_; | 95 Beaming_options beaming_options_; |
92 Beaming_options finished_beaming_options_; | 96 Beaming_options finished_beaming_options_; |
93 | 97 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 /* | 216 /* |
213 Can't use make_spanner () because we have to use | 217 Can't use make_spanner () because we have to use |
214 beam_settings_. | 218 beam_settings_. |
215 */ | 219 */ |
216 Spanner *beam = new Spanner (beam_settings_); | 220 Spanner *beam = new Spanner (beam_settings_); |
217 | 221 |
218 for (vsize i = 0; i < stems_->size (); i++) | 222 for (vsize i = 0; i < stems_->size (); i++) |
219 Beam::add_stem (beam, (*stems_)[i]); | 223 Beam::add_stem (beam, (*stems_)[i]); |
220 | 224 |
221 Grob_info i = make_grob_info (beam, (*stems_)[0]->self_scm ()); | 225 Grob_info i = make_grob_info (beam, (*stems_)[0]->self_scm ()); |
222 i.rerouting_daddy_context_ = beam_start_context_; | 226 i.rerouting_daddy_context_ = beam_start_context_.get_context (); |
223 announce_grob (i); | 227 announce_grob (i); |
224 | 228 |
225 return beam; | 229 return beam; |
226 } | 230 } |
227 | 231 |
228 void | 232 void |
229 Auto_beam_engraver::begin_beam () | 233 Auto_beam_engraver::begin_beam () |
230 { | 234 { |
231 if (stems_ || grouping_) | 235 if (stems_ || grouping_) |
232 { | 236 { |
233 programming_error ("already have autobeam"); | 237 programming_error ("already have autobeam"); |
234 return; | 238 return; |
235 } | 239 } |
236 | 240 |
237 stems_ = new vector<Item *>; | 241 stems_ = new vector<Item *>; |
238 grouping_ = new Beaming_pattern (); | 242 grouping_ = new Beaming_pattern (); |
239 beaming_options_.from_context (context ()); | 243 beaming_options_.from_context (context ()); |
240 beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam")); | 244 beam_settings_ = updated_grob_properties (context (), ly_symbol2scm ("Beam")); |
241 | 245 |
242 beam_start_context_ = context ()->get_parent_context (); | 246 beam_start_context_.set_context (context ()->get_parent_context ()); |
243 beam_start_moment_ = now_mom (); | 247 beam_start_moment_ = now_mom (); |
244 beam_start_location_ | 248 beam_start_location_ |
245 = robust_scm2moment (get_property ("measurePosition"), Moment (0)); | 249 = robust_scm2moment (get_property ("measurePosition"), Moment (0)); |
246 } | 250 } |
247 | 251 |
248 void | 252 void |
249 Auto_beam_engraver::junk_beam () | 253 Auto_beam_engraver::junk_beam () |
250 { | 254 { |
251 if (!stems_) | 255 if (!stems_) |
252 return; | 256 return; |
(...skipping 12 matching lines...) Expand all Loading... |
265 { | 269 { |
266 if (stems_->size () < 2) | 270 if (stems_->size () < 2) |
267 junk_beam (); | 271 junk_beam (); |
268 else | 272 else |
269 { | 273 { |
270 finished_beam_ = create_beam (); | 274 finished_beam_ = create_beam (); |
271 | 275 |
272 if (finished_beam_) | 276 if (finished_beam_) |
273 { | 277 { |
274 Grob_info i = make_grob_info (finished_beam_, SCM_EOL); | 278 Grob_info i = make_grob_info (finished_beam_, SCM_EOL); |
275 i.rerouting_daddy_context_ = beam_start_context_; | 279 i.rerouting_daddy_context_ = beam_start_context_.get_context (); |
276 | 280 |
277 announce_end_grob (i); | 281 announce_end_grob (i); |
278 finished_grouping_ = grouping_; | 282 finished_grouping_ = grouping_; |
279 finished_beaming_options_ = beaming_options_; | 283 finished_beaming_options_ = beaming_options_; |
280 } | 284 } |
281 delete stems_; | 285 delete stems_; |
282 stems_ = 0; | 286 stems_ = 0; |
283 grouping_ = 0; | 287 grouping_ = 0; |
284 beam_settings_ = SCM_EOL; | 288 beam_settings_ = SCM_EOL; |
285 } | 289 } |
286 | 290 |
| 291 beam_start_context_.set_context (NULL); |
287 shortest_mom_ = Moment (Rational (1, 4)); | 292 shortest_mom_ = Moment (Rational (1, 4)); |
288 } | 293 } |
289 | 294 |
290 void | 295 void |
291 Auto_beam_engraver::typeset_beam () | 296 Auto_beam_engraver::typeset_beam () |
292 { | 297 { |
293 if (finished_beam_) | 298 if (finished_beam_) |
294 { | 299 { |
295 if (!finished_beam_->get_bound (RIGHT)) | 300 if (!finished_beam_->get_bound (RIGHT)) |
296 finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); | 301 finished_beam_->set_bound (RIGHT, finished_beam_->get_bound (LEFT)); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 /* read */ | 552 /* read */ |
548 "autoBeaming " | 553 "autoBeaming " |
549 "baseMoment " | 554 "baseMoment " |
550 "beamExceptions " | 555 "beamExceptions " |
551 "beatStructure " | 556 "beatStructure " |
552 "subdivideBeams ", | 557 "subdivideBeams ", |
553 | 558 |
554 /* write */ | 559 /* write */ |
555 "" | 560 "" |
556 ); | 561 ); |
OLD | NEW |