2 horizontal-bracket-engraver.cc -- implement
3 Horizontal_bracket_engraver
5 source file of the GNU LilyPond music typesetter
7 (c) 2002--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "engraver.hh"
11 #include "international.hh"
12 #include "note-column.hh"
13 #include "pointer-group-interface.hh"
14 #include "side-position-interface.hh"
15 #include "stream-event.hh"
19 #include "translator.icc"
21 class Horizontal_bracket_engraver : public Engraver
24 TRANSLATOR_DECLARATIONS (Horizontal_bracket_engraver);
25 vector<Spanner*> bracket_stack_;
26 vector<Stream_event*> events_;
30 void stop_translation_timestep ();
31 void process_music ();
32 DECLARE_ACKNOWLEDGER (note_column);
33 DECLARE_TRANSLATOR_LISTENER (note_grouping);
36 ADD_ACKNOWLEDGER (Horizontal_bracket_engraver, note_column);
37 ADD_TRANSLATOR (Horizontal_bracket_engraver,
39 "Create horizontal brackets over notes for musical analysis"
52 Horizontal_bracket_engraver::Horizontal_bracket_engraver ()
58 IMPLEMENT_TRANSLATOR_LISTENER (Horizontal_bracket_engraver, note_grouping);
60 Horizontal_bracket_engraver::listen_note_grouping (Stream_event *ev)
62 Direction d = to_dir (ev->get_property ("span-direction"));
67 if (pop_count_ > bracket_stack_.size ())
68 ev->origin ()->warning (_ ("do not have that many brackets"));
73 events_.push_back (ev);
76 if (pop_count_ && push_count_)
77 ev->origin ()->warning (_ ("conflicting note group events"));
81 Horizontal_bracket_engraver::acknowledge_note_column (Grob_info gi)
83 for (vsize i = 0; i < bracket_stack_.size (); i++)
85 Side_position_interface::add_support (bracket_stack_[i], gi.grob ());
86 Pointer_group_interface::add_grob (bracket_stack_[i],
87 ly_symbol2scm ("columns"), gi.grob ());
88 add_bound_item (bracket_stack_[i],
94 Horizontal_bracket_engraver::process_music ()
96 for (vsize k = 0; k < push_count_; k++)
98 Spanner *sp = make_spanner ("HorizontalBracket", events_[k]->self_scm ());
100 for (vsize i = 0; i < bracket_stack_.size (); i++)
101 /* sp is the smallest, it should be added to the bigger brackets. */
102 Side_position_interface::add_support (bracket_stack_[i], sp);
103 bracket_stack_.push_back (sp);
108 Horizontal_bracket_engraver::stop_translation_timestep ()
110 for (int i = pop_count_; i--;)
111 if (bracket_stack_.size ())
112 bracket_stack_.pop_back ();