2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2004--2010 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 "pointer-group-interface.hh"
22 #include "engraver.hh"
23 #include "staff-symbol.hh"
25 class Ledger_line_engraver
: public Engraver
28 vector
<Grob
*> ledgered_grobs_
;
31 TRANSLATOR_DECLARATIONS (Ledger_line_engraver
);
34 virtual void finalize ();
35 void process_music ();
37 DECLARE_ACKNOWLEDGER (ledgered
);
38 DECLARE_ACKNOWLEDGER (staff_symbol
);
40 void start_spanner ();
42 void stop_translation_timestep ();
45 Ledger_line_engraver::Ledger_line_engraver ()
51 Ledger_line_engraver::start_spanner ()
55 span_
= make_spanner ("LedgerLineSpanner", SCM_EOL
);
56 span_
->set_bound (LEFT
, unsmob_grob (get_property ("currentCommandColumn")));
60 Ledger_line_engraver::stop_translation_timestep ()
64 for (vsize i
= 0; i
< ledgered_grobs_
.size (); i
++)
66 if (!to_boolean (ledgered_grobs_
[i
]->get_property ("no-ledgers")))
67 Pointer_group_interface::add_grob (span_
,
68 ly_symbol2scm ("note-heads"),
73 ledgered_grobs_
.clear ();
77 Ledger_line_engraver::process_music ()
80 Need to do this, otherwise the first note might miss ledgers.
87 Ledger_line_engraver::finalize ()
93 Ledger_line_engraver::stop_spanner ()
97 span_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
98 Pointer_group_interface::set_ordered (span_
, ly_symbol2scm ("elements"), false);
104 Ledger_line_engraver::acknowledge_staff_symbol (Grob_info s
)
106 Spanner
*sym
= dynamic_cast<Spanner
*> (s
.grob ());
109 || (span_
->get_bound (LEFT
) != sym
->get_bound (LEFT
)))
117 Ledger_line_engraver::acknowledge_ledgered (Grob_info s
)
119 ledgered_grobs_
.push_back (s
.grob ());
122 #include "translator.icc"
124 ADD_ACKNOWLEDGER (Ledger_line_engraver
, ledgered
);
125 ADD_ACKNOWLEDGER (Ledger_line_engraver
, staff_symbol
);
126 ADD_TRANSLATOR (Ledger_line_engraver
,
128 "Create the spanner to draw ledger lines, and notices"
129 " objects that need ledger lines.",
132 "LedgerLineSpanner ",