]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-item.cc
patch::: 1.3.18.jcn3
[lilypond.git] / lily / key-item.cc
index 7fc7f2accfc438c2837309f3b7ef6ab9e679ba7f..43ddc6931fb598fa0ed05385d0d107ee96941634 100644 (file)
 #include "paper-def.hh"
 #include "lookup.hh"
 #include "musical-pitch.hh"
+#include "staff-symbol-referencer.hh"
 
 const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */
 const int SHARP_TOP_PITCH=4; /*  ais and bis typeset in lower octave */
 
 Key_item::Key_item ()
 {
-  multi_octave_b_ = false;
-  set_elt_property (breakable_scm_sym, SCM_BOOL_T);
+  set_elt_property ("breakable", SCM_BOOL_T);
   set_c_position (0);
 }
 
@@ -62,7 +62,7 @@ Key_item::add_old (int p, int a)
 int
 Key_item::calculate_position(int p, int a) const
 {
-  if (multi_octave_b_) 
+  if (to_boolean (get_elt_property ("multi-octave")))
     {
       return p + c0_position_;
     }
@@ -73,6 +73,17 @@ Key_item::calculate_position(int p, int a) const
       {
        p -= 7; /* Typeset below c_position */
       }
+    /* Provide for the four cases in which there's a glitch */
+    /* it's a hack, but probably not worth */
+    /* the effort of finding a nicer solution. dl. */
+    if (get_c_position ()==2 && a>0 && p==3)
+      p -= 7;
+    if (get_c_position ()==-3 && a>0 && p==-1)
+      p += 7;
+    if (get_c_position ()==-4 && a<0 && p==-1)
+      p += 7;
+    if (get_c_position ()==-2 && a<0 && p==-3)
+      p += 7;
     return p + get_c_position ();
   }
 }
@@ -86,7 +97,9 @@ Molecule*
 Key_item::do_brew_molecule_p() const
 {
   Molecule*output = new Molecule;
-  Real inter = staff_line_leading_f ()/2.0;
+
+  Staff_symbol_referencer_interface si (this);
+  Real inter = si.staff_space ()/2.0;
   
   int j;
   if ((break_status_dir () == LEFT || break_status_dir () == CENTER)
@@ -102,7 +115,8 @@ Key_item::do_brew_molecule_p() const
              || (old_pitch_arr_[i] == pitch_arr_[j]
                  && old_acc_arr_[i] != acc_arr_[j]))
             {
-              Molecule m =lookup_l ()->accidental (0,false);
+              Molecule m =lookup_l ()->afm_find ("accidentals-0");
+
               m.translate_axis (calculate_position(old_pitch_arr_[i], old_acc_arr_[i]) * inter, Y_AXIS);
               output->add_at_edge (X_AXIS, RIGHT, m,0);        
             }
@@ -121,20 +135,14 @@ Key_item::do_brew_molecule_p() const
  
   for (int i =0; i < pitch_arr_.size(); i++) 
     {
-      Molecule m =lookup_l ()->accidental (acc_arr_[i],false);
+      Molecule m = lookup_l ()->afm_find ("accidentals-" + to_str (acc_arr_[i]));
       m.translate_axis (calculate_position(pitch_arr_[i], acc_arr_[i]) * inter, Y_AXIS);
       output->add_at_edge (X_AXIS, RIGHT, m, 0);
     }
-  if (pitch_arr_.size()) 
-    {
-      Molecule m (lookup_l ()->fill (Box (
-                                         Interval (0, paper_l ()->note_width ()),
-                                         Interval (0,0))));
-      
-      output->add_at_edge (X_AXIS, RIGHT, m,0 );
-    }
+
   return output;
 }
 
 
 
+