]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/local-key-item.cc
patch::: 1.1.52.mb2
[lilypond.git] / lily / local-key-item.cc
index a78ec7a371f9cc4012ab5ea668281f64bbed7adb..9953c7550d1efe5d1f94794529f02e5b628a5d64 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include "local-key-item.hh"
 #include "molecule.hh"
@@ -20,45 +20,43 @@ Local_key_item::Local_key_item ()
 }
 
 void
-Local_key_item::add_support (Item*head_l)
+Local_key_item::add_pitch (Musical_pitch p, bool cautionary)
 {
-  if (support_items_.find_l(head_l))
-    return ;
-  support_items_.push (head_l);
-  add_dependency (head_l);
-}
-
-void
-Local_key_item::add (Musical_pitch p)
-{
-  for (int i=0; i< accidental_pitch_arr_.size(); i++)
-    if (!Musical_pitch::compare (p, accidental_pitch_arr_[i]))
+  for (int i=0; i< accidental_arr_.size(); i++)
+    if (!Musical_pitch::compare (p, accidental_arr_[i].pitch_))
       return;
-  
-  accidental_pitch_arr_.push (p);
+
+  Local_key_cautionary_tuple t;
+  t.pitch_ = p;
+  t.cautionary_b_ = cautionary;
+  accidental_arr_.push (t);
 }
 
+
 void
 Local_key_item::do_pre_processing()
 {
-  accidental_pitch_arr_.sort (Musical_pitch::compare);
+  accidental_arr_.sort (Local_key_cautionary_tuple::compare);
+  Note_head_side::do_pre_processing ();
 }
 
 Molecule*
-Local_key_item::brew_molecule_p() const
+Local_key_item::do_brew_molecule_p() const
 {
   Molecule*output = new Molecule;
-
+  Real note_distance = staff_line_leading_f ()/2;
   Molecule *octave_mol_p = 0;
   int lastoct = -100;
-  for  (int i = 0; i <  accidental_pitch_arr_.size(); i++) 
+  
+  for  (int i = 0; i <  accidental_arr_.size(); i++) 
     {
+      Musical_pitch p (accidental_arr_[i].pitch_);
       // do one octave
-      if (accidental_pitch_arr_[i].octave_i_ != lastoct) 
+      if (p.octave_i_ != lastoct) 
        {
          if (octave_mol_p)
            {
-             Real dy =lastoct*7*paper()->internote_f ();
+             Real dy =lastoct*7* note_distance;
              octave_mol_p->translate_axis (dy, Y_AXIS);
              output->add_molecule (*octave_mol_p);
              delete octave_mol_p;
@@ -66,58 +64,39 @@ Local_key_item::brew_molecule_p() const
          octave_mol_p= new Molecule;
        }
       
-      lastoct = accidental_pitch_arr_[i].octave_i_;
+      lastoct = p.octave_i_;
       Real dy =
-       (c0_position_i_ + accidental_pitch_arr_[i].notename_i_)
-       * paper()->internote_f ();
-      Molecule m (lookup_l ()->accidental (accidental_pitch_arr_[i].accidental_i_, 
-             accidental_pitch_arr_[i].cautionary_b_));
+       (c0_position_i_ + p.notename_i_)
+       * note_distance;
+      Molecule m (lookup_l ()->accidental (p.accidental_i_, 
+                                          accidental_arr_[i].cautionary_b_));
 
       m.translate_axis (dy, Y_AXIS);
-      octave_mol_p->add_at_edge (X_AXIS, RIGHT, m);
+      octave_mol_p->add_at_edge (X_AXIS, RIGHT, m, 0);
     }
 
   if (octave_mol_p)
     {
-      Real dy =lastoct*7*paper()->internote_f ();
+      Real dy =lastoct*7*note_distance;
       octave_mol_p->translate_axis (dy, Y_AXIS);
       output->add_molecule (*octave_mol_p);
       delete octave_mol_p;
     }
   
- if (accidental_pitch_arr_.size()) 
+ if (accidental_arr_.size()) 
     {
-      Box b(Interval (0, paper()->internote_f ()), Interval (0,0));
+      Box b(Interval (0, 0.6 * note_distance), Interval (0,0));
       Molecule m (lookup_l ()->fill (b));
-      output->add_at_edge (X_AXIS, RIGHT, m);
+      output->add_at_edge (X_AXIS, RIGHT, m, 0);
     }
 
-  Interval x_int;
-  for (int i=0; i < support_items_.size(); i++) 
-    {
-      Graphical_axis_group *common = 
-       common_group (support_items_[i], X_AXIS);
-
-      Real x = support_items_[i]->relative_coordinate (common, X_AXIS)  
-       -relative_coordinate (common, X_AXIS);
-
-      x_int.unite (x + support_items_[i]->width());
-    }
-  if (x_int.empty_b ())
-    x_int = Interval(0,0);
-  
-  output->translate_axis (-output->extent()[X_AXIS][RIGHT] + x_int[LEFT], X_AXIS);
-  
   return output;
 }
 
-IMPLEMENT_IS_TYPE_B1(Local_key_item,Item);
-
 void
-Local_key_item::do_substitute_dependency (Score_element*o,Score_element*n)
+Local_key_item::do_substitute_element_pointer (Score_element *o, Score_element*n)
 {
-  Item* o_l = dynamic_cast <Item *> (o);
-  Item* n_l = n?dynamic_cast <Item *> (n):0;
-
-  support_items_.substitute (o_l, n_l);
+  Note_head_side::do_substitute_element_pointer (o,n);
+  Staff_symbol_referencer::do_substitute_element_pointer (o,n);
+  
 }