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"
19 Note_column::rest_b () const
21 return unsmob_element (get_elt_pointer ("rest"));
25 Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2)
27 SCM s1 = p1->get_elt_property ("horizontal-shift");
28 SCM s2 = p2->get_elt_property ("horizontal-shift");
30 int h1 = (gh_number_p (s1))? gh_scm2int (s1) :0;
31 int h2 = (gh_number_p (s2)) ? gh_scm2int (s2):0;
35 Note_column::Note_column( SCM s)
38 set_elt_pointer ("note-heads", SCM_EOL);
39 Axis_group_interface (this).set_interface ();
40 Axis_group_interface (this).set_axes (X_AXIS, Y_AXIS);
41 Group_interface (this, "interfaces").add_thing (ly_symbol2scm ("Note_column"));
45 Note_column::stem_l () const
47 SCM s = get_elt_pointer ("stem");
48 return dynamic_cast<Stem*> (unsmob_element (s));
53 Note_column::head_positions_interval(Score_element *me)
59 SCM h = me->get_elt_pointer ("note-heads");
60 for (; gh_pair_p (h); h = gh_cdr (h))
62 Score_element *se = unsmob_element (gh_car (h));
63 Staff_symbol_referencer_interface si (se);
65 int j = int (si.position_f ());
66 iv.unite (Slice (j,j));
72 Note_column::static_dir (Score_element* me)
74 Score_element *stem = unsmob_element (me->get_elt_pointer ("stem"));
75 if (dynamic_cast<Stem*> (stem))
76 return dynamic_cast<Stem*> (stem)->get_direction ();
77 else if (gh_pair_p (me->get_elt_pointer ("note-heads")))
78 return (Direction)sign (head_positions_interval (me).center ());
80 programming_error ("Note column without heads and stem!");
86 Note_column::dir () const
88 return static_dir ((Score_element*) this);
92 Note_column::set_stem (Score_element * stem_l)
94 set_elt_pointer ("stem", stem_l->self_scm_);
96 add_dependency (stem_l);
97 Axis_group_interface (this).add_element (stem_l);
101 Note_column::add_head (Score_element *h)
103 if (to_boolean (h->get_elt_property ("rest-interface")))
105 this->set_elt_pointer ("rest", h->self_scm_);
107 else if (to_boolean (h->get_elt_property ("note-head-interface")))
109 Pointer_group_interface gi (this, "note-heads");
112 Axis_group_interface (this).add_element (h);
116 translate the rest symbols vertically by amount DY_I.
119 Note_column::translate_rests (int dy_i)
121 Score_element * r = unsmob_element (get_elt_pointer ("rest"));
124 Staff_symbol_referencer_interface si (r);
125 r->translate_axis (dy_i * si.staff_space ()/2.0, Y_AXIS);
131 Note_column::set_dotcol (Score_element *d)
133 Axis_group_interface (this).add_element (d);
139 Note_column::rest_dim () const
141 Score_element * r = unsmob_element (get_elt_pointer ("rest"));
142 return r->extent (Y_AXIS);
146 Note_column::first_head () const
148 Stem * st = stem_l ();
149 return st? st->first_head (): 0;