2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
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
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
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/>.
20 #include "change-iterator.hh"
22 #include "direction.hh"
23 #include "international.hh"
25 #include "music-wrapper-iterator.hh"
27 class Auto_change_iterator : public Music_wrapper_iterator
30 DECLARE_SCHEME_CALLBACK (constructor, ());
32 Auto_change_iterator ();
35 virtual void construct_children ();
36 virtual void process (Moment);
43 Auto_change_iterator::process (Moment m)
45 // TODO: It seems strange that this occurs before consulting the split list.
46 Music_wrapper_iterator::process (m);
50 for (; scm_is_pair (split_list_); split_list_ = scm_cdr (split_list_))
52 splitm = unsmob<Moment> (scm_caar (split_list_));
56 SCM tag = scm_cdar (split_list_);
57 Direction d = to_dir (tag);
59 if (d && d != where_dir_)
61 // TODO: The function of where_dir_ in choosing the direction should
62 // be built into split-list generation so that this iterator merely
63 // effects a sequence of context changes.
65 string to_id = (d >= 0) ? "up" : "down";
66 // N.B. change_to() returns an error message. Silence is the legacy
67 // behavior here, but maybe that should be changed.
68 Change_iterator::change_to (*child_iter_,
69 ly_symbol2scm ("Staff"),
75 Auto_change_iterator::Auto_change_iterator ()
78 split_list_ = SCM_EOL;
82 Auto_change_iterator::construct_children ()
84 split_list_ = get_music ()->get_property ("split-list");
86 Context *voice = get_outlet()->find_create_context (ly_symbol2scm ("Voice"),
89 Music_wrapper_iterator::construct_children ();
92 IMPLEMENT_CTOR_CALLBACK (Auto_change_iterator);