]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/clef-engraver.cc
Imported sources
[lilypond.git] / lily / clef-engraver.cc
index b36fc2dc8aba81cd337d54b71a8c7af98ce1796d..76c814444f48f23c19e0689ff0d43bef56f18525 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>,
 
   Mats Bengtsson <matsb@s3.kth.se>
 */
 #include <ctype.h>
 
 #include "translator-group.hh"
-
 #include "bar-line.hh"
 #include "staff-symbol-referencer.hh"
-
 #include "engraver.hh"
 #include "direction.hh"
 #include "side-position-interface.hh"
 #include "item.hh"
 
-
 class Clef_engraver : public  Engraver
 {
 public:
@@ -30,7 +27,6 @@ public:
 
 protected:
   virtual void stop_translation_timestep ();
-  virtual void start_translation_timestep ();
   virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
 private:
@@ -65,8 +61,8 @@ Clef_engraver::set_glyph ()
 
   SCM basic = ly_symbol2scm ("Clef");
   
-  daddy_trans_->execute_single_pushpop_property (basic, glyph_sym, SCM_UNDEFINED);
-  daddy_trans_->execute_single_pushpop_property (basic, glyph_sym, glyph);
+  execute_pushpop_property (daddy_trans_, basic, glyph_sym, SCM_UNDEFINED);
+  execute_pushpop_property (daddy_trans_, basic, glyph_sym, glyph);
 }
 
 /** 
@@ -82,7 +78,6 @@ Clef_engraver::acknowledge_grob (Grob_info info)
       if (Bar_line::has_interface (info.grob_)
          && gh_string_p (get_property ("clefGlyph")))
        create_clef ();
-
     } 
 }
 
@@ -91,32 +86,37 @@ Clef_engraver::create_clef ()
 {
   if (!clef_)
     {
-      Item *c= new Item (get_property ("Clef"));
+      Item *c= make_item ("Clef");
       announce_grob(c, SCM_EOL);
 
       clef_ = c;
-    }
-  SCM cpos = get_property ("clefPosition");
-
-  if (gh_number_p (cpos))
-    Staff_symbol_referencer::set_position (clef_, gh_scm2int (cpos));
-
-  SCM oct =  get_property ("clefOctavation");
-  if (gh_number_p (oct) && gh_scm2int (oct))
-    {
-      Item * g = new Item (get_property ("OctavateEight"));
+      SCM cpos = get_property ("clefPosition");
 
-      Side_position_interface::add_support (g,clef_);      
+      if (gh_number_p (cpos))
+       Staff_symbol_referencer::set_position (clef_, gh_scm2int (cpos));
 
-      g->set_parent (clef_, Y_AXIS);
-      g->set_parent (clef_, X_AXIS);
-
-      g->set_grob_property ("direction", gh_int2scm (sign (gh_scm2int (oct))));
-      octavate_ = g;
-      announce_grob(octavate_, SCM_EOL);
+      SCM oct =  get_property ("clefOctavation");
+      if (gh_number_p (oct) && gh_scm2int (oct))
+       {
+         Item * g = make_item ("OctavateEight");
+
+         int abs_oct = gh_scm2int (oct) ;
+         int dir = sign (abs_oct);
+         abs_oct = abs (abs_oct)  + 1;
+           
+         g->set_grob_property ("text",
+                               scm_number_to_string (gh_int2scm (abs_oct),
+                                                     SCM_MAKINUM (10)));
+         Side_position_interface::add_support (g,clef_);      
+
+         g->set_parent (clef_, Y_AXIS);
+         g->set_parent (clef_, X_AXIS);
+         g->set_grob_property ("direction", scm_int2num (dir));
+         octavate_ = g;
+         announce_grob(octavate_, SCM_EOL);
+       }
     }
 }
-
 void
 Clef_engraver::process_music ()
 {
@@ -135,8 +135,7 @@ Clef_engraver::inspect_clef_properties ()
       || scm_equal_p (glyph, prev_glyph_) == SCM_BOOL_F
       || scm_equal_p (clefpos, prev_cpos_) == SCM_BOOL_F
       || scm_equal_p (octavation, prev_octavation_) == SCM_BOOL_F
-      || to_boolean (force_clef)
-)
+      || to_boolean (force_clef))
     {
       set_glyph ();
       create_clef ();
@@ -182,7 +181,6 @@ Clef_engraver::stop_translation_timestep ()
 
       if (octavate_)
        {
-         Side_position_interface::add_staff_support (octavate_);         
          typeset_grob (octavate_);
        }
 
@@ -190,16 +188,12 @@ Clef_engraver::stop_translation_timestep ()
     }
 }
 
-void
-Clef_engraver::start_translation_timestep ()
-{
-}
-
 
 
 ENTER_DESCRIPTION(Clef_engraver,
 /* descr */       "Determine and set reference point for pitches",
 /* creats*/       "Clef OctavateEight",
-/* acks  */       "bar-line-interface",
+/* accepts */     "",
+/* acks  */      "bar-line-interface",
 /* reads */       "clefPosition clefGlyph centralCPosition clefOctavation explicitClefVisibility",
 /* write */       "");