2 local-key-item.cc -- implement Local_key_item, Musical_pitch
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "local-key-item.hh"
10 #include "staff-symbol-referencer.hh"
12 #include "paper-def.hh"
13 #include "musical-request.hh"
14 #include "note-head.hh"
19 Local_key_item::add_pitch (Musical_pitch p, bool cautionary, bool natural)
21 for (int i=0; i< accidental_arr_.size(); i++)
22 if (!Musical_pitch::compare (p, accidental_arr_[i].pitch_))
24 /* maybe natural (and cautionary) should be modif. nonetheless? */
26 Local_key_cautionary_tuple t;
28 t.cautionary_b_ = cautionary;
29 t.natural_b_ = natural;
30 accidental_arr_.push (t);
36 Local_key_item::before_line_breaking ()
38 accidental_arr_.sort (Local_key_cautionary_tuple::compare);
42 Local_key_item::accidental (int j, bool cautionary, bool natural) const
44 Molecule m (lookup_l ()->afm_find (String ("accidentals-") + to_str (j)));
47 Molecule prefix = lookup_l ()->afm_find (String ("accidentals-0"));
48 m.add_at_edge(X_AXIS, LEFT, Molecule(prefix), 0);
52 Molecule open = lookup_l ()->afm_find (String ("accidentals-("));
53 Molecule close = lookup_l ()->afm_find (String ("accidentals-)"));
54 m.add_at_edge(X_AXIS, LEFT, Molecule(open), 0);
55 m.add_at_edge(X_AXIS, RIGHT, Molecule(close), 0);
64 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Local_key_item)
66 Local_key_item::do_brew_molecule () const
69 Staff_symbol_referencer_interface si (this);
70 Real note_distance = si.staff_space ()/2;
75 for (int i = 0; i < accidental_arr_.size(); i++)
77 Musical_pitch p (accidental_arr_[i].pitch_);
79 if (p.octave_i_ != lastoct)
83 Real dy =lastoct*7* note_distance;
84 octave_mol.translate_axis (dy, Y_AXIS);
85 mol.add_molecule (octave_mol);
86 octave_mol = Molecule ();
91 lastoct = p.octave_i_;
93 SCM c0 = get_elt_property ("c0-position");
94 Real dy = (gh_number_p (c0) ? gh_scm2int (c0) : 0 + p.notename_i_)
97 Molecule m (accidental (p.accidental_i_,
98 accidental_arr_[i].cautionary_b_,
99 accidental_arr_[i].natural_b_));
101 m.translate_axis (dy, Y_AXIS);
102 octave_mol.add_at_edge (X_AXIS, RIGHT, m, 0);
107 Real dy =lastoct*7*note_distance;
108 octave_mol.translate_axis (dy, Y_AXIS);
109 mol.add_molecule (octave_mol);
110 octave_mol = Molecule ();
113 if (accidental_arr_.size())
115 Drul_array<SCM> pads;
120 pads[RIGHT] = get_elt_property ("right-padding");
121 pads[LEFT] = get_elt_property ("left-padding");
127 if (!gh_number_p (pads[d]))
130 Box b(Interval (0, gh_scm2double (pads[d]) * note_distance),
132 Molecule m (lookup_l ()->blank (b));
133 mol.add_at_edge (X_AXIS, d, m, 0);
134 } while ( flip (&d)!= LEFT);
140 Local_key_item::Local_key_item (SCM s)