]> git.donarmstrong.com Git - lilypond.git/blob - lily/vertical-align-engraver.cc
release: 1.3.36
[lilypond.git] / lily / vertical-align-engraver.cc
1 /*
2   vertical-align-grav.cc -- implement Vertical_align_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "translator-group.hh"
9 #include "axis-group-engraver.hh"
10 #include "paper-column.hh"
11 #include "vertical-align-engraver.hh"
12 #include "axis-align-spanner.hh"
13 #include "axis-group-spanner.hh"
14 #include "span-bar.hh"
15 #include "axis-group-interface.hh"
16
17 Vertical_align_engraver::Vertical_align_engraver()
18 {
19   valign_p_ =0;
20 }
21
22 void
23 Vertical_align_engraver::do_creation_processing()
24 {
25   valign_p_ =new Axis_align_spanner;
26   valign_p_->set_axis (Y_AXIS);
27   valign_p_->set_elt_property ("stacking-dir",  gh_int2scm (DOWN));
28   
29   valign_p_->set_bound(LEFT,get_staff_info().command_pcol_l ());
30   announce_element (Score_element_info (valign_p_ , 0));
31 }
32
33 void
34 Vertical_align_engraver::do_removal_processing()
35 {
36   SCM min = get_property ("maxVerticalAlign");
37   SCM max = get_property ("minVerticalAlign");
38
39   if (gh_number_p (min) || gh_number_p (max))
40   {
41     min = gh_number_p (min) ? min : gh_double2scm (0.0);
42     max = gh_number_p (max) ? max : gh_double2scm (infinity_f);    
43     
44     valign_p_->set_elt_property ("threshold",
45                                  gh_cons (min,max));
46   }
47   valign_p_->set_bound(RIGHT,get_staff_info().command_pcol_l ());
48   typeset_element (valign_p_);
49   valign_p_ =0;
50 }
51
52
53 bool
54 Vertical_align_engraver::qualifies_b (Score_element_info i) const
55 {
56   int sz = i.origin_trans_l_arr ((Translator*)this).size()  ;
57
58
59   Axis_group_interface agi(i.elem_l_);
60
61   return sz > 1 && agi.has_interface_b ()
62     && !i.elem_l_->parent_l (Y_AXIS) && agi.axis_b (Y_AXIS);
63 }
64
65 void
66 Vertical_align_engraver::acknowledge_element (Score_element_info i)
67 {
68   if (qualifies_b (i))
69     {
70       valign_p_->add_element (i.elem_l_);
71     }
72   /*
73     ? huh
74    */
75   else if (dynamic_cast<Span_bar*>(i.elem_l_) && i.origin_trans_l_arr (this).size ())
76     {
77       i.elem_l_->add_dependency (valign_p_);
78     }  
79 }
80
81
82
83 ADD_THIS_TRANSLATOR(Vertical_align_engraver);