2 ' separating-line-group-engraver.cc -- implement Separating_line_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "separating-group-spanner.hh"
11 #include "separation-item.hh"
12 #include "paper-column.hh"
13 #include "output-def.hh"
14 #include "engraver.hh"
15 #include "axis-group-interface.hh"
16 #include "note-spacing.hh"
17 #include "accidental-placement.hh"
22 Item * staff_spacing_;
23 Link_array<Item> note_spacings_;
30 bool is_empty () const
32 return !staff_spacing_ && !note_spacings_.size ();
36 note_spacings_.clear ();
41 class Separating_line_group_engraver : public Engraver
46 Item * last_musical_item_;
48 Spacings current_spacings_;
49 Spacings last_spacings_;
53 virtual void acknowledge_grob (Grob_info);
54 virtual void process_music ();
55 virtual void finalize ();
56 virtual void stop_translation_timestep ();
57 virtual void start_translation_timestep ();
59 TRANSLATOR_DECLARATIONS (Separating_line_group_engraver);
62 Separating_line_group_engraver::Separating_line_group_engraver ()
70 Separating_line_group_engraver::process_music ()
75 sep_span_ = make_spanner ("SeparatingGroupSpanner", SCM_EOL);
78 sep_span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
82 Separating_line_group_engraver::finalize ()
87 SCM ccol = get_property ("currentCommandColumn");
88 Grob *column = unsmob_grob (ccol);
90 sep_span_->set_bound (RIGHT, unsmob_grob (ccol));
93 for (int i = 0 ; i < last_spacings_.note_spacings_.size (); i++)
95 Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
96 ly_symbol2scm ("right-items" ),
100 if (last_spacings_.staff_spacing_
101 && last_spacings_.staff_spacing_->get_column () == column)
103 last_spacings_.staff_spacing_->suicide ();
108 Separating_line_group_engraver::acknowledge_grob (Grob_info i)
110 Item * it = dynamic_cast <Item *> (i.grob_);
113 if (it->get_parent (X_AXIS)
114 && it->get_parent (X_AXIS)
115 ->has_extent_callback (Axis_group_interface::group_extent_callback_proc, X_AXIS))
119 if (to_boolean (it->get_property ("no-spacing-rods")))
122 if (Note_spacing::has_interface (it))
124 current_spacings_.note_spacings_.push (it);
128 bool ib = Item::is_breakable (it);
129 Item *&p_ref_ (ib ? break_item_
134 p_ref_ = make_item ("SeparationItem", SCM_EOL);
138 p_ref_->set_property ("breakable", SCM_BOOL_T);
139 context ()->set_property ("breakableSeparationItem", p_ref_->self_scm ());
143 if (to_boolean (get_property ("createSpacing"))
144 && p_ref_ == break_item_)
146 Item *it = make_item ("StaffSpacing", SCM_EOL);
147 current_spacings_.staff_spacing_ = it;
148 it->set_property ("left-items", scm_cons (break_item_->self_scm (), SCM_EOL));
152 if (int i = last_spacings_.note_spacings_.size ())
155 Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
156 ly_symbol2scm ("right-items"),
160 else if (last_spacings_.staff_spacing_)
162 last_spacings_.staff_spacing_->set_property ("right-items",
163 scm_cons (break_item_->self_scm (), SCM_EOL));
168 if (Accidental_placement::has_interface (it))
169 Separation_item::add_conditional_item (p_ref_, it);
171 Separation_item::add_item (p_ref_,it);
175 Separating_line_group_engraver::start_translation_timestep ()
178 context ()->unset_property (ly_symbol2scm ("breakableSeparationItem"));
183 Separating_line_group_engraver::stop_translation_timestep ()
187 Separating_group_spanner::add_spacing_unit (sep_span_, break_item_);
190 if (Item * sp = current_spacings_.staff_spacing_)
193 TODO: should really look at the left-items of following
197 Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"),
203 if (!current_spacings_.is_empty ())
205 last_spacings_ = current_spacings_;
208 current_spacings_.clear ();
212 Separating_group_spanner::add_spacing_unit (sep_span_, musical_item_);
219 ADD_TRANSLATOR (Separating_line_group_engraver,
220 /* descr */ "Generates objects for computing spacing parameters.",
221 /* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing",
223 /* acks */ "item-interface",
224 /* reads */ "createSpacing",
225 /* write */ "breakableSeparationItem");