]> git.donarmstrong.com Git - lilypond.git/blob - lily/vertical-align-engraver.cc
* lily/engraver.cc (internal_make_item): centralize item/spanner
[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--2003 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_;
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 process_music ();
25   virtual void finalize ();
26 };
27
28 Vertical_align_engraver::Vertical_align_engraver ()
29 {
30   valign_ =0;
31 }
32
33 void
34 Vertical_align_engraver::process_music ()
35 {
36   if (!valign_)
37     {
38       valign_ =make_spanner ("VerticalAlignment");
39       valign_->set_bound (LEFT,unsmob_grob (get_property ("currentCommandColumn")));
40       announce_grob(valign_ , SCM_EOL);
41     }
42 }
43
44 void
45 Vertical_align_engraver::finalize ()
46 {
47   valign_->set_bound (RIGHT,unsmob_grob (get_property ("currentCommandColumn")));
48   typeset_grob (valign_);
49   valign_ =0;
50 }
51
52
53 bool
54 Vertical_align_engraver::qualifies_b (Grob_info i) const
55 {
56   int sz = i.origin_transes ((Translator*)this).size ()  ;
57
58   return sz > 1 && Axis_group_interface::has_interface (i.grob_)
59     && !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::axis_b (i.grob_, Y_AXIS);
60 }
61
62 void
63 Vertical_align_engraver::acknowledge_grob (Grob_info i)
64 {
65   if (qualifies_b (i))
66     {
67       Align_interface::add_element (valign_,i.grob_, get_property ("verticalAlignmentChildCallback"));
68     }
69 }
70
71
72 ENTER_DESCRIPTION(Vertical_align_engraver,
73 /* descr */       "Catch Vertical axis groups and stack them.",
74 /* creats*/       "VerticalAlignment",
75 /* accepts */     "",
76 /* acks  */      "axis-group-interface",
77 /* reads */       "",
78 /* write */       "");