2 notehead.cc -- implement Note_head
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "note-head.hh"
14 #include "molecule.hh"
15 #include "musical-request.hh"
17 #include "dimension-cache.hh"
20 Note_head::flip_around_stem (Direction d)
22 Real l= make_molecule ().dim_[X_AXIS].length ();
23 translate_axis (l * d, X_AXIS);
27 Note_head::dim_callback (Dimension_cache const * c)
29 Note_head* n = dynamic_cast<Note_head*> (c->element_l ());
30 return n->make_molecule ().dim_[X_AXIS];
33 Note_head::Note_head ()
35 dim_cache_[X_AXIS]->callback_l_ = dim_callback;
39 Note_head::do_pre_processing ()
41 Rhythmic_head::do_pre_processing ();
43 // 8 ball looks the same as 4 ball:
45 SCM style = get_elt_property ("style");
46 if (style != SCM_UNDEFINED)
48 type = ly_scm2string (style);
52 if (balltype_i_ > 2 || type == "harmonic" || type == "cross")
55 if (dots_l_) // move into Rhythmic_head?
56 dots_l_->set_position(int (position_f ()));
64 Note_head::compare (Note_head *const &a, Note_head * const &b)
66 return sign(a->position_f () - b->position_f ());
72 Note_head::make_molecule () const
75 SCM style = get_elt_property ("style");
76 if (style != SCM_UNDEFINED)
78 type = ly_scm2string (style);
81 return lookup_l()->afm_find (String ("noteheads-")
82 + to_str (balltype_i_) + type);
86 Note_head::do_brew_molecule_p() const
88 Real inter_f = staff_line_leading_f ()/2;
89 int sz = lines_i ()-1;
91 int streepjes_i = abs (position_f ()) < sz
93 : (abs((int)position_f ()) - sz) /2;
95 Molecule* out = new Molecule (make_molecule ());
101 Direction dir = (Direction)sign (position_f ());
102 Interval hd = out->dim_[X_AXIS];
103 Real hw = hd.length ()/4;
106 = lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
109 int parity = abs(int (position_f ())) % 2;
111 for (int i=0; i < streepjes_i; i++)
114 s.translate_axis (-dir * inter_f * (i*2 + parity),
116 out->add_molecule (s);