2 key-item.cc -- implement Key_item
4 source file of the GNU LilyPond music typesetter
6 (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 keyplacement by Mats Bengtsson
11 #include "key-item.hh"
14 #include "molecule.hh"
15 #include "paper-def.hh"
18 #include "key-grav.hh"
20 const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */
21 const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */
23 Key_item::Key_item (int c)
31 Key_item::read (Key_engraver const & key_grav_r)
33 assert (!key_grav_r.key_.multi_octave_b_);
34 const Array<int> &idx_arr =key_grav_r.accidental_idx_arr_;
35 for (int i = 0 ; i< idx_arr.size(); i++) {
36 int note = idx_arr[i];
37 int acc = ((Key &) key_grav_r.key_).oct (0).acc (note);
44 Key_item::set_c_position (int c0)
46 int octaves =(abs (c0) / 7) +1 ;
47 c_position=(c0 + 7*octaves)%7;
52 Key_item::add (int p, int a)
54 if ((a<0 && p>FLAT_TOP_PITCH) ||
55 (a>0 && p>SHARP_TOP_PITCH)) {
56 p -= 7; /* Typeset below c_position */
64 Key_item::brew_molecule_p()const
66 Molecule*output = new Molecule;
67 Real inter = paper()->internote_f ();
69 for (int i =0; i < pitch.size(); i++) {
70 Symbol s= paper()->lookup_l ()->accidental (acc[i]);
72 a.translate ((c_position + pitch[i]) * inter, Y_AXIS);
74 output->add_right (m);
77 Molecule m (paper()->lookup_l ()->fill (Box (
78 Interval (0, paper()->note_width ()),
81 output->add_right (m);
86 IMPLEMENT_IS_TYPE_B1(Key_item,Item);
89 Key_item::do_pre_processing()
92 empty_b_ = transparent_b_ = (break_status_i() != 1);