2 ' separating-line-group-engraver.cc -- implement Separating_line_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "separating-group-spanner.hh"
10 #include "separation-item.hh"
11 #include "paper-column.hh"
12 #include "output-def.hh"
13 #include "engraver.hh"
14 #include "axis-group-interface.hh"
15 #include "note-spacing.hh"
16 #include "accidental-placement.hh"
22 Link_array<Item> note_spacings_;
29 bool is_empty () const
31 return !staff_spacing_ && !note_spacings_.size ();
36 note_spacings_.clear ();
40 class Separating_line_group_engraver : public Engraver
45 Item *last_musical_item_;
47 Spacings current_spacings_;
48 Spacings last_spacings_;
52 virtual void acknowledge_grob (Grob_info);
53 virtual void process_music ();
54 virtual void finalize ();
55 virtual void stop_translation_timestep ();
56 virtual void start_translation_timestep ();
58 TRANSLATOR_DECLARATIONS (Separating_line_group_engraver);
61 Separating_line_group_engraver::Separating_line_group_engraver ()
69 Separating_line_group_engraver::process_music ()
74 sep_span_ = make_spanner ("SeparatingGroupSpanner", SCM_EOL);
76 sep_span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
80 Separating_line_group_engraver::finalize ()
85 SCM ccol = get_property ("currentCommandColumn");
86 Grob *column = unsmob_grob (ccol);
88 sep_span_->set_bound (RIGHT, unsmob_grob (ccol));
91 for (int i = 0; i < last_spacings_.note_spacings_.size (); i++)
93 Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
94 ly_symbol2scm ("right-items"),
98 if (last_spacings_.staff_spacing_
99 && last_spacings_.staff_spacing_->get_column () == column)
101 last_spacings_.staff_spacing_->suicide ();
106 Separating_line_group_engraver::acknowledge_grob (Grob_info i)
108 Item *it = dynamic_cast<Item *> (i.grob ());
111 if (it->get_parent (X_AXIS)
112 && it->get_parent (X_AXIS)
113 ->has_extent_callback (Axis_group_interface::group_extent_callback_proc, X_AXIS))
116 if (to_boolean (it->get_property ("no-spacing-rods")))
119 if (Note_spacing::has_interface (it))
121 current_spacings_.note_spacings_.push (it);
125 bool ib = Item::is_breakable (it);
126 Item *&p_ref_ (ib ? break_item_
131 p_ref_ = make_item ("SeparationItem", SCM_EOL);
135 p_ref_->set_property ("breakable", SCM_BOOL_T);
136 context ()->set_property ("breakableSeparationItem", p_ref_->self_scm ());
139 if (to_boolean (get_property ("createSpacing"))
140 && p_ref_ == break_item_)
142 Item *it = make_item ("StaffSpacing", SCM_EOL);
143 current_spacings_.staff_spacing_ = it;
144 it->set_property ("left-items", scm_cons (break_item_->self_scm (), SCM_EOL));
146 if (int i = last_spacings_.note_spacings_.size ())
149 Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
150 ly_symbol2scm ("right-items"),
153 else if (last_spacings_.staff_spacing_)
155 last_spacings_.staff_spacing_->set_property ("right-items",
156 scm_cons (break_item_->self_scm (), SCM_EOL));
161 if (Accidental_placement::has_interface (it))
162 Separation_item::add_conditional_item (p_ref_, it);
164 Separation_item::add_item (p_ref_, it);
168 Separating_line_group_engraver::start_translation_timestep ()
171 context ()->unset_property (ly_symbol2scm ("breakableSeparationItem"));
176 Separating_line_group_engraver::stop_translation_timestep ()
180 Separating_group_spanner::add_spacing_unit (sep_span_, break_item_);
183 if (Item *sp = current_spacings_.staff_spacing_)
186 TODO: should really look at the left-items of following
190 Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"),
194 if (!current_spacings_.is_empty ())
196 last_spacings_ = current_spacings_;
199 current_spacings_.clear ();
203 Separating_group_spanner::add_spacing_unit (sep_span_, musical_item_);
209 ADD_TRANSLATOR (Separating_line_group_engraver,
210 /* descr */ "Generates objects for computing spacing parameters.",
211 /* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing",
213 /* acks */ "item-interface",
214 /* reads */ "createSpacing",
215 /* write */ "breakableSeparationItem");