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 "paper-def.hh"
14 #include "engraver.hh"
15 #include "axis-group-interface.hh"
16 #include "note-spacing.hh"
17 #include "group-interface.hh"
18 #include "accidental-placement.hh"
25 Item * staff_spacing_;
26 Link_array<Item> note_spacings_;
33 bool is_empty () const
35 return !staff_spacing_ && !note_spacings_.size ();
39 note_spacings_.clear ();
44 class Separating_line_group_engraver : public Engraver
49 Item * last_musical_item_;
51 Spacings current_spacings_;
52 Spacings last_spacings_;
56 virtual void acknowledge_grob (Grob_info);
57 virtual void process_music ();
58 virtual void finalize ();
59 virtual void stop_translation_timestep ();
60 virtual void start_translation_timestep ();
62 TRANSLATOR_DECLARATIONS (Separating_line_group_engraver);
65 Separating_line_group_engraver::Separating_line_group_engraver ()
73 Separating_line_group_engraver::process_music ()
78 sep_span_ = make_spanner ("SeparatingGroupSpanner");
80 announce_grob (sep_span_, SCM_EOL);
81 sep_span_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
85 Separating_line_group_engraver::finalize ()
90 SCM ccol = get_property ("currentCommandColumn");
91 Grob *column = unsmob_grob (ccol);
93 sep_span_->set_bound (RIGHT, unsmob_grob (ccol));
94 typeset_grob (sep_span_);
97 for (int i= 0 ; i < last_spacings_.note_spacings_.size (); i++)
99 Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
100 ly_symbol2scm ("right-items" ),
104 if (last_spacings_.staff_spacing_
105 && last_spacings_.staff_spacing_->get_column () == column)
107 last_spacings_.staff_spacing_->suicide ();
112 Separating_line_group_engraver::acknowledge_grob (Grob_info i)
114 Item * it = dynamic_cast <Item *> (i.grob_);
117 if (it->get_parent (X_AXIS)
118 && it->get_parent (X_AXIS)
119 ->has_extent_callback (Axis_group_interface::group_extent_callback_proc, X_AXIS))
123 if (to_boolean (it->get_property ("no-spacing-rods")))
126 if (Note_spacing::has_interface (it))
128 current_spacings_.note_spacings_.push (it);
132 bool ib =Item::is_breakable (it);
133 Item *&p_ref_ (ib ? break_item_
138 p_ref_ = make_item ("SeparationItem");
142 p_ref_->set_property ("breakable", SCM_BOOL_T);
143 daddy_context_->set_property ("breakableSeparationItem", p_ref_->self_scm ());
145 announce_grob (p_ref_, SCM_EOL);
147 if (to_boolean (get_property ("createSpacing"))
148 && p_ref_ == break_item_)
150 Item *it = make_item ("StaffSpacing");
151 current_spacings_.staff_spacing_ = it;
152 it->set_property ("left-items", gh_cons (break_item_->self_scm (), SCM_EOL));
154 announce_grob (it, SCM_EOL);
156 if (int i = last_spacings_.note_spacings_.size ())
159 Pointer_group_interface::add_grob (last_spacings_.note_spacings_[i],
160 ly_symbol2scm ("right-items"),
164 else if (last_spacings_.staff_spacing_)
167 last_spacings_.staff_spacing_->set_property ("right-items",
168 gh_cons (break_item_->self_scm (), SCM_EOL));
173 if (Accidental_placement::has_interface (it))
174 Separation_item::add_conditional_item (p_ref_, it);
176 Separation_item::add_item (p_ref_,it);
180 Separating_line_group_engraver::start_translation_timestep ()
183 daddy_context_->unset_property (ly_symbol2scm ("breakableSeparationItem"));
188 Separating_line_group_engraver::stop_translation_timestep ()
192 Separating_group_spanner::add_spacing_unit (sep_span_, break_item_);
193 typeset_grob (break_item_);
196 if (Item * sp = current_spacings_.staff_spacing_)
199 TODO: should really look at the left-items of following
203 Pointer_group_interface::add_grob (sp, ly_symbol2scm ("right-items"),
210 if (!current_spacings_.is_empty ())
212 last_spacings_ = current_spacings_;
215 current_spacings_.clear ();
219 Separating_group_spanner::add_spacing_unit (sep_span_, musical_item_);
220 typeset_grob (musical_item_);
227 ENTER_DESCRIPTION (Separating_line_group_engraver,
228 /* descr */ "Generates objects for computing spacing parameters.",
229 /* creats*/ "SeparationItem SeparatingGroupSpanner StaffSpacing",
231 /* acks */ "item-interface",
232 /* reads */ "createSpacing",
233 /* write */ "breakableSeparationItem");