]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/local-key-item.cc
release: 1.3.131
[lilypond.git] / lily / local-key-item.cc
index 1b37fb22a3d8c80e36f57f0b42b43d6b32249e93..e815098effcb3929302390a99c006e6fa0e7715a 100644 (file)
@@ -1,9 +1,9 @@
 /*
-  local-key-item.cc -- implement Local_key_item, Musical_pitch
+  local-key-item.cc -- implement Local_key_item, Pitch
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include "local-key-item.hh"
 #include "molecule.hh"
 #include "misc.hh"
 #include "lookup.hh"
 
-SCM
+static SCM
 pitch_less  (SCM p1, SCM p2)
 {
-  for (int i = 3; i--; p1 = gh_cdr (p1), p2 = gh_cdr (p2))
-    {
-      if (scm_less_p (gh_car (p1), gh_car (p2)))
-       return SCM_BOOL_T;
-      if (gh_car (p1) != gh_car (p2))
-       return SCM_BOOL_F;
-    }
-  return SCM_BOOL_T;
+  return Pitch::less_p (gh_car (p1),  gh_car (p2));
 }
 
-SCM pitch_less_proc;
-
+static SCM pitch_less_proc;
 
 void
 init_pitch_funcs ()
 {
-  pitch_less_proc = gh_new_procedure2_0 ("pitch-less", &pitch_less);
+  pitch_less_proc = gh_new_procedure2_0 ("pits-less", &pitch_less);
 }
 
-ADD_SCM_INIT_FUNC(pitch,init_pitch_funcs);
+ADD_SCM_INIT_FUNC(lkpitch,init_pitch_funcs);
 
 
 void
-Local_key_item::add_pitch (Score_element*me, Musical_pitch p, bool cautionary, bool natural)
+Local_key_item::add_pitch (Grob*me, Pitch p, bool cautionary, bool natural)
 {
-  SCM acs = me->get_elt_property ("accidentals");
-  SCM pitch = p.to_scm ();
+  SCM acs = me->get_grob_property ("accidentals");
+  SCM pitch = p.smobbed_copy ();
   SCM opts = SCM_EOL;
   if (cautionary)
     opts = gh_cons (ly_symbol2scm ("cautionary"), opts);
   if (natural)
     opts = gh_cons (ly_symbol2scm ("natural"), opts);
 
-  pitch = gh_append2 (pitch, opts);
+  pitch = gh_cons (pitch, opts);
   acs = scm_merge_x (acs, gh_cons (pitch, SCM_EOL), pitch_less_proc);
 
-  me->set_elt_property ("accidentals", acs);
+  me->set_grob_property ("accidentals", acs);
 }
 
 Molecule
-Local_key_item::parenthesize (Score_element*me, Molecule m)
+Local_key_item::parenthesize (Grob*me, Molecule m)
 {
   Molecule open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-("));
   Molecule close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-)"));
@@ -77,7 +69,7 @@ MAKE_SCHEME_CALLBACK(Local_key_item,brew_molecule,1);
 SCM
 Local_key_item::brew_molecule (SCM smob)
 {
-  Score_element* me = unsmob_element (smob);
+  Grob* me = unsmob_grob (smob);
   
   Molecule mol;
 
@@ -86,14 +78,15 @@ Local_key_item::brew_molecule (SCM smob)
   bool oct_b = false;
   int lastoct = -100;
 
-  SCM accs = me->get_elt_property ("accidentals");
+  SCM accs = me->get_grob_property ("accidentals");
   for  (SCM s = accs;
        gh_pair_p (s); s = gh_cdr (s))
     {
-      Musical_pitch p (gh_car (s));
+      Pitch p (*unsmob_pitch (gh_caar (s)));
+      SCM opts = gh_cdar (s);
       
       // do one octave
-      if (p.octave_i_ != lastoct) 
+      if (p.octave_i ()  != lastoct) 
        {
          if (oct_b)
            {
@@ -105,22 +98,22 @@ Local_key_item::brew_molecule (SCM smob)
          oct_b = true; 
        }
       
-      lastoct = p.octave_i_;
+      lastoct = p.octave_i () ;
 
-      SCM c0 =  me->get_elt_property ("c0-position");
+      SCM c0 =  me->get_grob_property ("c0-position");
       Real dy = (gh_number_p (c0) ? gh_scm2int (c0) : 0 + p.notename_i_)
        * note_distance;
       
       Molecule acc (Font_interface::get_default_font (me)->find_by_name (String ("accidentals-")
-                                              + to_str (p.accidental_i_)));
+                                              + to_str (p.alteration_i_)));
       
-      if (scm_memq (ly_symbol2scm ("natural"), gh_car (s)) != SCM_BOOL_F)
+      if (scm_memq (ly_symbol2scm ("natural"), opts) != SCM_BOOL_F)
        {
          Molecule prefix = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-0"));
          acc.add_at_edge(X_AXIS, LEFT, Molecule(prefix), 0);
        }
 
-      if (scm_memq (ly_symbol2scm ("cautionary"), gh_car (s)) != SCM_BOOL_F)
+      if (scm_memq (ly_symbol2scm ("cautionary"), opts) != SCM_BOOL_F)
        acc = parenthesize (me, acc);
 
       acc.translate_axis (dy, Y_AXIS);
@@ -142,8 +135,8 @@ Local_key_item::brew_molecule (SCM smob)
       /*
        Use a cons?
        */
-      pads[RIGHT] = me->get_elt_property ("right-padding");
-      pads[LEFT] = me->get_elt_property ("left-padding");
+      pads[RIGHT] = me->get_grob_property ("right-padding");
+      pads[LEFT] = me->get_grob_property ("left-padding");
 
 
       // unused ?
@@ -163,12 +156,12 @@ Local_key_item::brew_molecule (SCM smob)
 }
 
 bool
-Local_key_item::has_interface (Score_element*m)
+Local_key_item::has_interface (Grob*m)
 {
   return m && m->has_interface (ly_symbol2scm ("accidentals-interface"));
 }
 void
-Local_key_item::set_interface (Score_element*m)
+Local_key_item::set_interface (Grob*m)
 {
   m->set_interface (ly_symbol2scm ("accidentals-interface"));
 }