2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2011 Mike Solomon <mike@apollinemike.com>
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/>.
25 #include "pointer-group-interface.hh"
26 #include "pure-from-neighbor-interface.hh"
27 #include "engraver.hh"
29 class Pure_from_neighbor_engraver : public Engraver
31 vector<Grob *> items_then_;
32 vector<Grob *> items_now_;
33 vector<Grob *> pures_then_;
34 vector<Grob *> pures_now_;
37 TRANSLATOR_DECLARATIONS (Pure_from_neighbor_engraver);
39 DECLARE_ACKNOWLEDGER (pure_from_neighbor);
40 DECLARE_ACKNOWLEDGER (item);
41 void stop_translation_timestep ();
44 Pure_from_neighbor_engraver::Pure_from_neighbor_engraver ()
49 Pure_from_neighbor_engraver::acknowledge_item (Grob_info i)
51 SCM pure_relevant_p = ly_lily_module_constant ("pure-relevant?");
52 if (!Pure_from_neighbor_interface::has_interface (i.grob ())
53 && to_boolean (scm_call_1 (pure_relevant_p, i.item ()->self_scm ())))
54 items_now_.push_back (i.item ());
57 // note that this can get out of hand if there are lots of vertical axis groups...
60 Pure_from_neighbor_engraver::acknowledge_pure_from_neighbor (Grob_info i)
62 pures_now_.push_back (i.item ());
66 Pure_from_neighbor_engraver::stop_translation_timestep ()
68 if (pures_now_.size ())
70 for (vsize i = 0; i < pures_now_.size (); i++)
71 for (vsize j = 0; j < items_then_.size (); j++)
72 Pointer_group_interface::add_grob (pures_now_[i], ly_symbol2scm ("elements"), items_then_[j]);
74 for (vsize i = 0; i < pures_then_.size (); i++)
75 for (vsize j = 0; j < items_now_.size (); j++)
76 Pointer_group_interface::add_grob (pures_then_[i], ly_symbol2scm ("elements"), items_now_[j]);
79 items_then_.insert (items_then_.end (), items_now_.begin (), items_now_.end ());
83 pures_then_.insert (pures_then_.end (), pures_now_.begin (), pures_now_.end ());
88 #include "translator.icc"
90 ADD_ACKNOWLEDGER (Pure_from_neighbor_engraver, item);
91 ADD_ACKNOWLEDGER (Pure_from_neighbor_engraver, pure_from_neighbor);
92 ADD_TRANSLATOR (Pure_from_neighbor_engraver,
94 "Coordinates items that get their pure heights from their neighbors.",