lilypond-1.4.4
[lilypond.git] / lily / separating-line-group-engraver.cc
blob73e0f2e16070f2f85ccbc11a3b081552e2c9f3d6
1 /*
2 ' separating-line-group-engraver.cc -- implement Separating_line_group_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
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"
17 class Separating_line_group_engraver : public Engraver
19 protected:
20 Item * break_malt_p_;
21 Item * nobreak_malt_p_;
22 Spanner * sep_span_p_;
24 virtual void acknowledge_grob (Grob_info);
25 virtual void initialize ();
26 virtual void finalize ();
27 virtual void stop_translation_timestep ();
28 public:
29 Separating_line_group_engraver ();
30 VIRTUAL_COPY_CONS (Translator);
33 Separating_line_group_engraver::Separating_line_group_engraver ()
35 sep_span_p_ = 0;
36 break_malt_p_ = 0;
37 nobreak_malt_p_ =0;
40 void
41 Separating_line_group_engraver::initialize ()
43 sep_span_p_ = new Spanner (get_property ("SeparatingGroupSpanner"));
45 announce_grob (sep_span_p_, 0);
46 sep_span_p_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
49 void
50 Separating_line_group_engraver::finalize ()
52 sep_span_p_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
53 typeset_grob (sep_span_p_);
54 sep_span_p_ =0;
57 void
58 Separating_line_group_engraver::acknowledge_grob (Grob_info i)
60 Item * it = dynamic_cast <Item *> (i.elem_l_);
61 if (!it)
62 return;
63 if (it->parent_l (X_AXIS)
64 && it->parent_l (X_AXIS)->has_extent_callback_b
65 (Axis_group_interface::group_extent_callback_proc, X_AXIS))
66 return;
69 bool ib =Item::breakable_b (it);
70 Item *&p_ref_ (ib ? break_malt_p_
71 : nobreak_malt_p_);
73 if (!p_ref_)
75 p_ref_ = new Item
76 (get_property ("SeparationItem"));
78 if (ib)
79 p_ref_->set_grob_property ("breakable", SCM_BOOL_T);
80 announce_grob (p_ref_, 0);
82 Separation_item::add_item (p_ref_,it);
85 void
86 Separating_line_group_engraver::stop_translation_timestep ()
88 if (break_malt_p_)
90 Separating_group_spanner::add_spacing_unit (sep_span_p_, break_malt_p_);
92 typeset_grob (break_malt_p_);
93 break_malt_p_ =0;
95 if (nobreak_malt_p_)
97 Separating_group_spanner::add_spacing_unit (sep_span_p_, nobreak_malt_p_);
98 typeset_grob (nobreak_malt_p_);
99 nobreak_malt_p_ =0;
105 ADD_THIS_TRANSLATOR (Separating_line_group_engraver);