2 local-key-item.cc -- implement Local_key_item, Musical_pitch
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "local-key-item.hh"
12 #include "paper-def.hh"
13 #include "musical-request.hh"
14 #include "note-head.hh"
17 Local_key_item::Local_key_item ()
23 Local_key_item::add_pitch (Musical_pitch p, bool cautionary, bool natural)
25 for (int i=0; i< accidental_arr_.size(); i++)
26 if (!Musical_pitch::compare (p, accidental_arr_[i].pitch_))
28 /* maybe natural (and cautionary) should be modif. nonetheless? */
30 Local_key_cautionary_tuple t;
32 t.cautionary_b_ = cautionary;
33 t.natural_b_ = natural;
34 accidental_arr_.push (t);
40 Local_key_item::do_pre_processing()
42 accidental_arr_.sort (Local_key_cautionary_tuple::compare);
43 Note_head_side::do_pre_processing ();
47 Local_key_item::accidental (int j, bool cautionary) const
49 Molecule m (lookup_l ()->afm_find (String ("accidentals-") + to_str (j)));
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);
62 Local_key_item::do_brew_molecule_p() const
64 Molecule*output = new Molecule;
65 Real note_distance = staff_line_leading_f ()/2;
66 Molecule *octave_mol_p = 0;
69 for (int i = 0; i < accidental_arr_.size(); i++)
71 Musical_pitch p (accidental_arr_[i].pitch_);
73 if (p.octave_i_ != lastoct)
77 Real dy =lastoct*7* note_distance;
78 octave_mol_p->translate_axis (dy, Y_AXIS);
79 output->add_molecule (*octave_mol_p);
82 octave_mol_p= new Molecule;
85 lastoct = p.octave_i_;
87 (c0_position_i_ + p.notename_i_)
90 Molecule m (accidental (p.accidental_i_, accidental_arr_[i].cautionary_b_));
92 m.translate_axis (dy, Y_AXIS);
93 octave_mol_p->add_at_edge (X_AXIS, RIGHT, m, 0);
98 Real dy =lastoct*7*note_distance;
99 octave_mol_p->translate_axis (dy, Y_AXIS);
100 output->add_molecule (*octave_mol_p);
104 if (accidental_arr_.size())
106 Box b(Interval (0, 0.6 * note_distance), Interval (0,0));
107 Molecule m (lookup_l ()->fill (b));
108 output->add_at_edge (X_AXIS, RIGHT, m, 0);
115 Local_key_item::do_substitute_element_pointer (Score_element *o, Score_element*n)
117 Note_head_side::do_substitute_element_pointer (o,n);
118 Staff_symbol_referencer::do_substitute_element_pointer (o,n);