]> git.donarmstrong.com Git - lilypond.git/blob - lily/vertical-align-engraver.cc
remove
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "context.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 (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", SCM_EOL);
39       valign_->set_bound (LEFT,unsmob_grob (get_property ("currentCommandColumn")));
40       
41     }
42 }
43
44 void
45 Vertical_align_engraver::finalize ()
46 {
47   if (valign_)
48     {
49       valign_->set_bound (RIGHT,unsmob_grob (get_property ("currentCommandColumn")));
50       valign_ =0;
51     }
52 }
53
54 bool
55 Vertical_align_engraver::qualifies (Grob_info i) const
56 {
57   int sz = i.origin_contexts ((Translator*)this).size ()  ;
58
59   return sz > 0 && Axis_group_interface::has_interface (i.grob_)
60     && !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::has_axis (i.grob_, Y_AXIS);
61 }
62
63 void
64 Vertical_align_engraver::acknowledge_grob (Grob_info i)
65 {
66   if (qualifies (i))
67     {
68       Align_interface::add_element (valign_,i.grob_, get_property ("verticalAlignmentChildCallback"));
69     }
70 }
71
72
73 ENTER_DESCRIPTION (Vertical_align_engraver,
74 /* descr */       "Catch Vertical axis groups and stack them.",
75 /* creats*/       "VerticalAlignment",
76 /* accepts */     "",
77 /* acks  */      "axis-group-interface",
78 /* reads */       "",
79 /* write */       "");