]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/clef-engraver.cc
release: 1.5.19
[lilypond.git] / lily / clef-engraver.cc
index 013c5dac4b9a17e6da8230fa86cfb370f82b4bc7..6a4646f6cde93219227690a4ef66c1706d0b54fe 100644 (file)
@@ -24,8 +24,7 @@
 class Clef_engraver : public  Engraver
 {
 public:
-  VIRTUAL_COPY_CONS (Translator);
-  Clef_engraver ();
+  TRANSLATOR_DECLARATIONS(Clef_engraver);
 
   Direction octave_dir_;
 
@@ -34,7 +33,6 @@ protected:
   virtual void start_translation_timestep ();
   virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
-  virtual void do_creation_processing ();
 private:
   Item * clef_p_;
   Item * octavate_p_;
@@ -43,7 +41,6 @@ private:
   SCM prev_cpos_;
   SCM prev_octavation_;
   void create_clef ();
-  void set_central_c (SCM, SCM, SCM);
   void set_glyph ();
   void inspect_clef_properties ();
 };
@@ -60,37 +57,6 @@ Clef_engraver::Clef_engraver ()
   prev_cpos_ = prev_glyph_ = SCM_BOOL_F;
 }
 
-void
-Clef_engraver::set_central_c (SCM glyph,SCM clefpos, SCM octavation)
-{
-  prev_cpos_ = clefpos;
-  prev_glyph_ = glyph;
-  prev_octavation_ = octavation;
-
-  SCM p = get_property ("clefPitches");
-  int c0_position =  0;
-  if (gh_list_p (p))
-    {
-      SCM found = scm_assoc (glyph, p);
-      if (found == SCM_BOOL_F)
-       {
-         c0_position =0;
-       }
-      else
-       {
-         c0_position =  gh_scm2int (gh_cdr (found));
-
-         if (gh_number_p (octavation))
-             c0_position -= gh_scm2int (octavation);
-      
-         if (gh_number_p (clefpos))
-           c0_position += gh_scm2int (clefpos);
-       }
-      
-    }
-  daddy_trans_l_->set_property ("centralCPosition", gh_int2scm (c0_position));
-}
-
 void
 Clef_engraver::set_glyph ()
 {
@@ -110,23 +76,13 @@ Clef_engraver::set_glyph ()
 void
 Clef_engraver::acknowledge_grob (Grob_info info)
 {
-  Item * item =dynamic_cast <Item *> (info.elem_l_);
+  Item * item =dynamic_cast <Item *> (info.grob_l_);
   if (item)
     {
-      if (Bar::has_interface (info.elem_l_)
+      if (Bar::has_interface (info.grob_l_)
          && gh_string_p (get_property ("clefGlyph")))
        create_clef ();
 
-      if (Key_item::has_interface (item))
-       {
-         /*
-           Key_item adapts its formatting to make sure that the
-           accidentals stay in the upper half of the staff. It needs
-           to know c0-pos for this. (?)
-         */
-
-         item->set_grob_property ("c0-position", get_property ("centralCPosition"));
-       }
     } 
 }
 
@@ -142,8 +98,10 @@ Clef_engraver::create_clef ()
       
       clef_p_ = c;
     }
-  Staff_symbol_referencer::set_position (clef_p_,
-                                        gh_scm2int (get_property ("clefPosition")));
+  SCM cpos = get_property ("clefPosition");
+
+  if (gh_number_p (cpos))
+    Staff_symbol_referencer::set_position (clef_p_, gh_scm2int (cpos));
 
   SCM oct =  get_property ("clefOctavation");
   if (gh_number_p (oct) && gh_scm2int (oct))
@@ -167,18 +125,6 @@ Clef_engraver::process_music ()
   inspect_clef_properties ();
 }
 
-/*
-  this must be done in creation_proc() since grace notes will be
-  processed before Clef_engraver::prcoess_music()
-
-  Grace notes and clef changes are still broken.
-*/
-void
-Clef_engraver::do_creation_processing ()
-{
-  inspect_clef_properties ();
-}
-
 void
 Clef_engraver::inspect_clef_properties ()
 {
@@ -195,11 +141,13 @@ Clef_engraver::inspect_clef_properties ()
 )
     {
       set_glyph ();
-      set_central_c (glyph, clefpos, octavation);
-       
       create_clef ();
 
       clef_p_->set_grob_property ("non-default", SCM_BOOL_T);
+
+      prev_cpos_ = clefpos;
+      prev_glyph_ = glyph;
+      prev_octavation_ = octavation;
     }
 
   if (to_boolean (force_clef))
@@ -209,6 +157,7 @@ Clef_engraver::inspect_clef_properties ()
     }
 }
 
+
 void
 Clef_engraver::stop_translation_timestep ()
 {
@@ -242,5 +191,11 @@ Clef_engraver::start_translation_timestep ()
 {
 }
 
-ADD_THIS_TRANSLATOR (Clef_engraver);
 
+
+ENTER_DESCRIPTION(Clef_engraver,
+/* descr */       "Determine and set reference point for pitches",
+/* creats*/       "Clef OctavateEight",
+/* acks  */       "bar-line-interface",
+/* reads */       "clefPosition clefGlyph centralCPosition clefOctavation explicitClefVisibility",
+/* write */       "");