]> git.donarmstrong.com Git - lilypond.git/blob - lily/separating-line-group-engraver.cc
release: 1.1.35
[lilypond.git] / lily / separating-line-group-engraver.cc
1 /*   
2   separating-line-group-grav.cc --  implement Separating_line_group_engraver
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "separating-line-group-engraver.hh"
11 #include "separating-group-spanner.hh"
12 #include "single-malt-grouping-item.hh"
13 #include "p-col.hh"
14 #include "paper-def.hh"
15
16 Separating_line_group_engraver::Separating_line_group_engraver ()
17 {
18   sep_span_p_ = 0;
19   break_malt_p_ = 0;
20   nobreak_malt_p_ =0;
21 }
22
23 void
24 Separating_line_group_engraver::do_creation_processing ()
25 {
26   sep_span_p_ = new Separating_group_spanner;
27   announce_element (Score_element_info (sep_span_p_, 0));
28   sep_span_p_->set_bounds (LEFT, get_staff_info ().command_pcol_l ());
29 }
30
31 void
32 Separating_line_group_engraver::do_removal_processing ()
33 {
34   Scalar sz (get_property ("postBreakPadding", 0));
35   if (!sz.empty_b () && sz.isnum_b ())
36     {
37       sep_span_p_->padding_f_ = Real(sz);
38     }
39   else
40     {
41       sep_span_p_->padding_f_ = 1.5 * paper_l ()->get_realvar (interline_scm_sym);
42     }
43
44   sep_span_p_->set_bounds (RIGHT, get_staff_info ().command_pcol_l ());
45   typeset_element (sep_span_p_);
46   sep_span_p_ =0;
47 }
48
49 void
50 Separating_line_group_engraver::acknowledge_element (Score_element_info i)
51 {
52   Item * it = dynamic_cast <Item *> (i.elem_l_);
53   if (it && !it->parent_l (X_AXIS))
54     {
55       bool ib =it->breakable_b ();
56       Single_malt_grouping_item *&p_ref_ (ib ? break_malt_p_
57                                           : nobreak_malt_p_);
58
59       if (!p_ref_)
60         {
61           p_ref_ = new Single_malt_grouping_item;
62           if (ib)
63             p_ref_->set_elt_property (breakable_scm_sym, SCM_BOOL_T);
64           announce_element (Score_element_info (p_ref_, 0));
65         }
66       p_ref_->add_item (it);
67     }
68 }
69
70 void
71 Separating_line_group_engraver::do_pre_move_processing ()
72 {
73   if (break_malt_p_)
74     {
75       sep_span_p_->add_spacing_unit (break_malt_p_);
76       
77       typeset_element (break_malt_p_);
78       break_malt_p_ =0;
79     }
80   if (nobreak_malt_p_)
81     {
82       sep_span_p_->add_spacing_unit (nobreak_malt_p_);
83       typeset_element (nobreak_malt_p_);
84       nobreak_malt_p_ =0;
85     }
86 }
87
88
89
90 ADD_THIS_TRANSLATOR( Separating_line_group_engraver);