]> git.donarmstrong.com Git - lilypond.git/blob - lily/vertical-align-engraver.cc
release: 1.5.29
[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--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "translator-group.hh"
9 #include "paper-column.hh"
10 #include "align-interface.hh"
11 #include "span-bar.hh"
12 #include "axis-group-interface.hh"
13 #include "engraver.hh"
14 #include "spanner.hh"
15
16 class Vertical_align_engraver : public Engraver
17 {
18   Spanner * valign_p_;
19   bool qualifies_b (Grob_info) const;  
20 public:
21   TRANSLATOR_DECLARATIONS(Vertical_align_engraver);
22 protected:
23   virtual void acknowledge_grob (Grob_info);
24   virtual void initialize ();
25   virtual void finalize ();
26 };
27
28 Vertical_align_engraver::Vertical_align_engraver ()
29 {
30   valign_p_ =0;
31 }
32
33 void
34 Vertical_align_engraver::initialize ()
35 {
36   valign_p_ =new Spanner (get_property ("VerticalAlignment"));
37   valign_p_->set_bound (LEFT,unsmob_grob (get_property ("currentCommandColumn")));
38   announce_grob (valign_p_ , 0);
39 }
40
41 void
42 Vertical_align_engraver::finalize ()
43 {
44   valign_p_->set_bound (RIGHT,unsmob_grob (get_property ("currentCommandColumn")));
45   typeset_grob (valign_p_);
46   valign_p_ =0;
47 }
48
49
50 bool
51 Vertical_align_engraver::qualifies_b (Grob_info i) const
52 {
53   int sz = i.origin_trans_l_arr ((Translator*)this).size ()  ;
54
55   return sz > 1 && Axis_group_interface::has_interface (i.grob_l_)
56     && !i.grob_l_->get_parent (Y_AXIS) && Axis_group_interface::axis_b (i.grob_l_, Y_AXIS);
57 }
58
59 void
60 Vertical_align_engraver::acknowledge_grob (Grob_info i)
61 {
62   if (qualifies_b (i))
63     {
64       Align_interface::add_element (valign_p_,i.grob_l_, get_property ("verticalAlignmentChildCallback"));
65     }
66 }
67
68
69 ENTER_DESCRIPTION(Vertical_align_engraver,
70 /* descr */       "Catch Vertical axis groups and stack them.",
71 /* creats*/       "VerticalAlignment",
72 /* acks  */       "axis-group-interface",
73 /* reads */       "",
74 /* write */       "");