]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/clef-item.cc
release: 1.3.69
[lilypond.git] / lily / clef-item.cc
index b3b468047f9761507ab4b28ab4a00cbff159881c..9c1179333d1adad3dd1d75b29fd5aff28a0dc83b 100644 (file)
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "clef-item.hh"
+
+#include "clef.hh"
 #include "string.hh"
 #include "molecule.hh"
-#include "paper-def.hh"
-#include "lookup.hh"
-#include "clef-grav.hh"
+#include "item.hh"
 
+/*
+FIXME: should use symbol.
 
-void
-Clef_item::do_pre_processing()
+*/
+MAKE_SCHEME_CALLBACK(Clef,before_line_breaking);
+SCM
+Clef::before_line_breaking (SCM smob)
 {
-  change_b_ = ! (break_status_i() == 1);
+  Item * s = dynamic_cast<Item*> (unsmob_element (smob));
 
-  if (default_b_)
-    {
-      set_empty(break_status_i() != 1);
-      transparent_b_ = (break_status_i() != 1);
-    }
-}
+  SCM style_sym =s->get_elt_property ("style");
+  String style;
+  if (gh_string_p (style_sym))
+    style = ly_scm2string (style_sym);
 
-Clef_item::Clef_item()
-{
-  breakable_b_ =true;
-  default_b_ = false;
-  change_b_ = true;
-  read ("violin");
-}
-
-void
-Clef_item::read (String t)
-{
-  symbol_= t;
-  if (t == "violin") 
-    {
-      y_position_i_ = -2;
-    }
-  else if (t == "french") 
-    {
-      symbol_="violin";
-      y_position_i_ = -4;
-    }
-  else if (t == "soprano") 
+  SCM glyph = s->get_elt_property ("glyph");
+  
+  if (gh_string_p (glyph))
     {
-      symbol_="alto";
-      y_position_i_ = -4;
-    }
-  else if (t == "mezzosoprano")
-    {
-      symbol_ = "alto";
-      y_position_i_ = -2;
-    }
-  else if (t == "alto") 
-    {
-      y_position_i_ = 0;
-    }
-  else if (t == "tenor") 
-    {
-      symbol_="alto";
-      y_position_i_ = 2;
-    }
-  else if (t == "baritone")
-    {
-      symbol_ = "alto";
-      y_position_i_ = 4;
-    }
-  else if (t == "varbaritone")
-    {
-      symbol_ = "bass";
-      y_position_i_ = 0;
-    }
-  else if (t == "bass") 
-    {
-      y_position_i_ = 2;
+      String str = ly_scm2string (glyph);
+
+      /*
+       FIXME: should use fontsize property to set clef changes.
+       */
+      if (s->get_elt_property ("non-default") &&
+         s->break_status_dir() != RIGHT && style != "fullSizeChanges")
+       {
+         str += "_change";
+         s->set_elt_property ("glyph", ly_str02scm (str.ch_C()));        
+       }
     }
-  else if (t == "subbass")
+  else
     {
-      symbol_ = "bass";
-      y_position_i_ = 4;
+      s->suicide ();
+      return SCM_UNDEFINED;
     }
+
+  return SCM_UNDEFINED;
 }
 
-void
-Clef_item::read (Clef_engraver const &k)
+bool
+Clef::has_interface (Score_element* me)
 {
-  read (k.clef_type_str_);
+  return me->has_interface (ly_symbol2scm ("clef-interface"));
 }
 
-Molecule*
-Clef_item::brew_molecule_p() const
+
+void
+Clef::set_interface (Score_element* me)
 {
-  String t = symbol_;
-  if  (change_b_)
-    t += "_change";
-  Atom s = paper()->lookup_l ()->clef (t);
-  Molecule*output = new Molecule (Atom (s));
-  output->translate_axis (paper()->internote_f () * y_position_i_, Y_AXIS);
-  return output;
+  me->set_interface (ly_symbol2scm ("clef-interface"));
 }
 
 
-IMPLEMENT_IS_TYPE_B1(Clef_item,Item);