2 local-key-item.cc -- implement Local_key_item, Local_acc
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "local-key-item.hh"
10 #include "molecule.hh"
13 #include "paper-def.hh"
14 #include "musical-request.hh"
15 #include "note-head.hh"
20 Local_key_item::Local_key_item(int i)
26 Local_key_item::add_support(Item*head_l)
28 support_items_.push(head_l);
29 add_dependency(head_l);
33 Local_key_item::add(Melodic_req*m_l)
35 add(m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_);
39 Local_key_item::add (int o, int p , int a)
45 for (int i=0; i< accs.size(); i++)
46 if (!Local_acc::compare(l, accs[i]))
53 Local_key_item::do_pre_processing()
55 accs.sort(Local_acc::compare);
59 Local_key_item::brew_molecule_p()const
61 Molecule* output = new Molecule;
64 for (int i = 0; i < accs.size(); i++) {
66 if (accs[i].octave_i_ != lastoct) {
68 Real dy =lastoct*7*paper()->internote_f();
69 octmol->translate_y( dy);
75 lastoct = accs[i].octave_i_;
76 Symbol s =paper()->lookup_l()->accidental(accs[i].accidental_i_);
78 Real dy = (accs[i].name_i_ + c0_position) * paper()->internote_f();
85 Real dy =lastoct*7*paper()->internote_f();
86 octmol->translate_y( dy);
91 Interval head_width=itemlist_width(support_items_);
92 output->translate_x(-output->extent().x.right + head_width.left );
98 Local_acc::compare(Local_acc&a, Local_acc&b)
100 if (a.octave_i_ - b.octave_i_)
101 return a.octave_i_ - b.octave_i_;
102 if (a.name_i_ - b.name_i_)
103 return a.name_i_ - b.name_i_;
105 return a.accidental_i_ - b.accidental_i_;
107 IMPLEMENT_STATIC_NAME(Local_key_item);
108 IMPLEMENT_IS_TYPE_B1(Local_key_item,Item);
111 Local_key_item::do_substitute_dependency(Score_elem*o,Score_elem*n)
113 Item* o_l = o->item();
114 Item* n_l = n?n->item():0;
116 support_items_.substitute(o_l, n_l);