2 vertical-align-grav.cc -- implement Vertical_align_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "translator-group.hh"
9 #include "axis-group-engraver.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"
17 class Vertical_align_engraver
: public Engraver
20 bool qualifies_b (Score_element_info
) const;
22 VIRTUAL_COPY_CONS(Translator
);
24 Vertical_align_engraver();
27 virtual void acknowledge_element (Score_element_info
);
28 virtual void do_creation_processing();
29 virtual void do_removal_processing();
32 Vertical_align_engraver::Vertical_align_engraver()
38 Vertical_align_engraver::do_creation_processing()
40 valign_p_
=new Spanner (SCM_EOL
); // todo -> basic props
41 Align_interface::set_interface (valign_p_
);
42 Align_interface::set_axis (valign_p_
,Y_AXIS
);
43 valign_p_
->set_elt_property ("stacking-dir",
46 valign_p_
->set_bound(LEFT
,unsmob_element (get_property ("currentCommandColumn")));
47 announce_element (Score_element_info (valign_p_
, 0));
51 Vertical_align_engraver::do_removal_processing()
53 SCM min
= get_property ("maxVerticalAlign");
54 SCM max
= get_property ("minVerticalAlign");
56 if (gh_number_p (min
) || gh_number_p (max
))
58 min
= gh_number_p (min
) ? min
: gh_double2scm (0.0);
59 max
= gh_number_p (max
) ? max
: gh_double2scm (infinity_f
);
61 valign_p_
->set_elt_property ("threshold",
64 valign_p_
->set_bound(RIGHT
,unsmob_element (get_property ("currentCommandColumn")));
65 typeset_element (valign_p_
);
71 Vertical_align_engraver::qualifies_b (Score_element_info i
) const
73 int sz
= i
.origin_trans_l_arr ((Translator
*)this).size() ;
75 return sz
> 1 && Axis_group_interface::has_interface (i
.elem_l_
)
76 && !i
.elem_l_
->parent_l (Y_AXIS
) && Axis_group_interface::axis_b (i
.elem_l_
, Y_AXIS
);
80 Vertical_align_engraver::acknowledge_element (Score_element_info i
)
84 Align_interface::add_element (valign_p_
,i
.elem_l_
);
88 ADD_THIS_TRANSLATOR(Vertical_align_engraver
);