2 ledger-line-engraver.cc -- implement Ledger_line_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "pointer-group-interface.hh"
11 #include "engraver.hh"
12 #include "staff-symbol.hh"
14 class Ledger_line_engraver
: public Engraver
17 vector
<Grob
*> ledgered_grobs_
;
20 TRANSLATOR_DECLARATIONS (Ledger_line_engraver
);
23 virtual void finalize ();
24 void process_music ();
26 DECLARE_ACKNOWLEDGER (ledgered
);
27 DECLARE_ACKNOWLEDGER (staff_symbol
);
29 void start_spanner ();
31 void stop_translation_timestep ();
34 Ledger_line_engraver::Ledger_line_engraver ()
40 Ledger_line_engraver::start_spanner ()
44 span_
= make_spanner ("LedgerLineSpanner", SCM_EOL
);
45 span_
->set_bound (LEFT
, unsmob_grob (get_property ("currentCommandColumn")));
49 Ledger_line_engraver::stop_translation_timestep ()
53 for (vsize i
= 0; i
< ledgered_grobs_
.size (); i
++)
55 if (!to_boolean (ledgered_grobs_
[i
]->get_property ("no-ledgers")))
56 Pointer_group_interface::add_grob (span_
,
57 ly_symbol2scm ("note-heads"),
62 ledgered_grobs_
.clear ();
66 Ledger_line_engraver::process_music ()
69 Need to do this, otherwise the first note might miss ledgers.
76 Ledger_line_engraver::finalize ()
82 Ledger_line_engraver::stop_spanner ()
86 span_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
87 Pointer_group_interface::set_ordered (span_
, ly_symbol2scm ("elements"), false);
93 Ledger_line_engraver::acknowledge_staff_symbol (Grob_info s
)
95 Spanner
*sym
= dynamic_cast<Spanner
*> (s
.grob ());
98 || (span_
->get_bound (LEFT
) != sym
->get_bound (LEFT
)))
106 Ledger_line_engraver::acknowledge_ledgered (Grob_info s
)
108 ledgered_grobs_
.push_back (s
.grob ());
111 #include "translator.icc"
113 ADD_ACKNOWLEDGER (Ledger_line_engraver
, ledgered
);
114 ADD_ACKNOWLEDGER (Ledger_line_engraver
, staff_symbol
);
115 ADD_TRANSLATOR (Ledger_line_engraver
,
117 "Create the spanner to draw ledger lines, and notices"
118 " objects that need ledger lines.",
121 "LedgerLineSpanner ",