]> git.donarmstrong.com Git - lilypond.git/blob - lily/vertical-align-engraver.cc
(postscript->png): call lilypond-ps2png
[lilypond.git] / lily / vertical-align-engraver.cc
1 /*
2   vertical-align-engraver.cc -- implement Vertical_align_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "context.hh"
10 #include "paper-column.hh"
11 #include "align-interface.hh"
12 #include "span-bar.hh"
13 #include "axis-group-interface.hh"
14 #include "engraver.hh"
15 #include "spanner.hh"
16
17 class Vertical_align_engraver : public Engraver
18 {
19   Spanner *valign_;
20   bool qualifies (Grob_info) const;
21
22 public:
23   TRANSLATOR_DECLARATIONS (Vertical_align_engraver);
24
25 protected:
26   virtual void acknowledge_grob (Grob_info);
27   virtual void process_music ();
28   virtual void finalize ();
29 };
30
31 Vertical_align_engraver::Vertical_align_engraver ()
32 {
33   valign_ = 0;
34 }
35
36 void
37 Vertical_align_engraver::process_music ()
38 {
39   if (!valign_)
40     {
41       valign_ = make_spanner ("VerticalAlignment", SCM_EOL);
42       valign_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
43     }
44 }
45
46 void
47 Vertical_align_engraver::finalize ()
48 {
49   if (valign_)
50     {
51       valign_->set_bound (RIGHT, unsmob_grob (get_property ("currentCommandColumn")));
52       valign_ = 0;
53     }
54 }
55
56 bool
57 Vertical_align_engraver::qualifies (Grob_info i) const
58 {
59   int sz = i.origin_contexts ((Translator *)this).size ();
60
61   return sz > 0 && Axis_group_interface::has_interface (i.grob_)
62     && !i.grob_->get_parent (Y_AXIS) && Axis_group_interface::has_axis (i.grob_, Y_AXIS);
63 }
64
65 void
66 Vertical_align_engraver::acknowledge_grob (Grob_info i)
67 {
68   if (qualifies (i))
69     {
70       Align_interface::add_element (valign_, i.grob_, get_property ("verticalAlignmentChildCallback"));
71     }
72 }
73
74 ADD_TRANSLATOR (Vertical_align_engraver,
75                 /* descr */ "Catch Vertical axis groups and stack them.",
76                 /* creats*/ "VerticalAlignment",
77                 /* accepts */ "",
78                 /* acks  */ "axis-group-interface",
79                 /* reads */ "",
80                 /* write */ "");