]> git.donarmstrong.com Git - lilypond.git/blob - lily/hara-kiri-engraver.cc
fcf4b8671679e218d3dd760992fb55710c42243a
[lilypond.git] / lily / hara-kiri-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "axis-group-engraver.hh"
21 #include "hara-kiri-group-spanner.hh"
22 #include "rhythmic-head.hh"
23 #include "spanner.hh"
24
25 #include "translator.icc"
26
27 /*
28   TODO: fold together with axis_group_engraver?
29  */
30
31 class Hara_kiri_engraver : public Axis_group_engraver
32 {
33 protected:
34   virtual Spanner *get_spanner ();
35   DECLARE_ACKNOWLEDGER (grob);
36   virtual void add_element (Grob *e);
37   void process_music ();
38   virtual void derived_mark () const;
39   SCM interesting_;
40 public:
41   TRANSLATOR_DECLARATIONS (Hara_kiri_engraver);
42 };
43
44 Hara_kiri_engraver::Hara_kiri_engraver ()
45 {
46   interesting_ = SCM_EOL;
47 }
48
49 void
50 Hara_kiri_engraver::derived_mark () const
51 {
52   scm_gc_mark (interesting_);
53 }
54
55 void
56 Hara_kiri_engraver::process_music ()
57 {
58   Axis_group_engraver::process_music ();
59   interesting_ = get_property ("keepAliveInterfaces");
60 }
61
62 void
63 Hara_kiri_engraver::add_element (Grob *e)
64 {
65   Axis_group_engraver::add_element (e);
66 }
67
68 Spanner *
69 Hara_kiri_engraver::get_spanner ()
70 {
71   Spanner *sp = make_spanner ("VerticalAxisGroup", SCM_EOL);
72   return sp;
73 }
74
75 void
76 Hara_kiri_engraver::acknowledge_grob (Grob_info i)
77 {
78   Axis_group_engraver::acknowledge_grob (i);
79   if (staffline_)
80     {
81       for (SCM s = interesting_; scm_is_pair (s); s = scm_cdr (s))
82         {
83           if (i.grob ()->internal_has_interface (scm_car (s)))
84             Hara_kiri_group_spanner::add_interesting_item (staffline_, i.grob ());
85         }
86     }
87 }
88
89 ADD_ACKNOWLEDGER (Hara_kiri_engraver, grob);
90 ADD_TRANSLATOR (Hara_kiri_engraver,
91                 /* doc */
92                 "Like @code{Axis_group_engraver}, but make a hara-kiri"
93                 " spanner, and add interesting items (i.e., note heads, lyric"
94                 " syllables, and normal rests).",
95
96                 /* create */
97                 "VerticalAxisGroup ",
98
99                 /* read */
100                 "keepAliveInterfaces ",
101
102                 /* write */
103                 ""
104                );
105