2 note-column.cc -- implement Note_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include <math.h> // ceil
10 #include "axis-group-interface.hh"
11 #include "note-column.hh"
14 #include "paper-def.hh"
15 #include "group-interface.hh"
16 #include "staff-symbol-referencer.hh"
18 #include "note-head.hh"
21 Note_column::rest_b () const
23 return unsmob_element (get_elt_property ("rest"));
27 Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2)
29 SCM s1 = p1->get_elt_property ("horizontal-shift");
30 SCM s2 = p2->get_elt_property ("horizontal-shift");
32 int h1 = (gh_number_p (s1))? gh_scm2int (s1) :0;
33 int h2 = (gh_number_p (s2)) ? gh_scm2int (s2):0;
37 Note_column::Note_column( SCM s)
40 Score_element* me = this;
41 me->set_elt_property ("note-heads", SCM_EOL);
42 me->set_interface (ly_symbol2scm ("note-column-interface"));
44 Axis_group_interface::set_interface (me);
45 Axis_group_interface::set_axes (me, X_AXIS, Y_AXIS);
49 Note_column::stem_l () const
51 SCM s = get_elt_property ("stem");
52 return dynamic_cast<Item*>(unsmob_element (s));
57 Note_column::head_positions_interval(Score_element *me)
63 SCM h = me->get_elt_property ("note-heads");
64 for (; gh_pair_p (h); h = gh_cdr (h))
66 Score_element *se = unsmob_element (gh_car (h));
68 int j = int (Staff_symbol_referencer::position_f (se));
69 iv.unite (Slice (j,j));
75 Note_column::static_dir (Score_element* me)
77 Score_element *stem = unsmob_element (me->get_elt_property ("stem"));
78 if (stem && Stem::has_interface (stem))
79 return Stem::get_direction (stem);
80 else if (gh_pair_p (me->get_elt_property ("note-heads")))
81 return (Direction)sign (head_positions_interval (me).center ());
83 programming_error ("Note column without heads and stem!");
89 Note_column::dir () const
91 return static_dir ((Score_element*) this);
95 Note_column::set_stem (Score_element * stem_l)
97 set_elt_property ("stem", stem_l->self_scm_);
99 add_dependency (stem_l);
100 Axis_group_interface::add_element (this, stem_l);
104 Note_column::add_head (Score_element *h)
106 if (Rest::has_interface (h))
108 this->set_elt_property ("rest", h->self_scm_);
110 else if (Note_head::has_interface (h))
112 Pointer_group_interface gi (this, "note-heads");
115 Axis_group_interface::add_element (this, h);
119 translate the rest symbols vertically by amount DY_I.
122 Note_column::translate_rests (int dy_i)
124 Score_element * r = unsmob_element (get_elt_property ("rest"));
127 r->translate_axis (dy_i * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS);
133 Note_column::set_dotcol (Score_element *d)
135 Axis_group_interface::add_element (this, d);
141 Note_column::rest_dim () const
143 Score_element * r = unsmob_element (get_elt_property ("rest"));
144 return r->extent (Y_AXIS);
148 Note_column::first_head () const
150 Score_element * st = stem_l ();
151 return st? Stem::first_head (st): 0;
155 Note_column::has_interface (Score_element*me)
157 return me && me->has_interface (ly_symbol2scm ("note-column-interface"));