]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/clef-item.cc
release: 1.3.147
[lilypond.git] / lily / clef-item.cc
index a95c54d454f1206995d619d9868ee2f373d42af3..d7c323ee609b38d463ecbc5e6de38aa6394c2eee 100644 (file)
@@ -1,55 +1,75 @@
 /*
   clef-item.cc -- implement Clef_item
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--2001 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-reg.hh"
+#include "item.hh"
+#include "font-interface.hh"
 
+/*
+ FIXME: should use symbol for #'style.
+*/
+MAKE_SCHEME_CALLBACK (Clef,before_line_breaking,1);
+SCM
+Clef::before_line_breaking (SCM smob)
+{
+  Item * s = dynamic_cast<Item*> (unsmob_grob (smob));
 
+  SCM glyph = s->get_grob_property ("glyph-name");
+  
+  if (gh_string_p (glyph))
+    {
+      String str = ly_scm2string (glyph);
 
-Clef_item::Clef_item()
-{
-    change = true;
-    read("violin");
+      if (to_boolean (s->get_grob_property ("non-default"))
+         && s->break_status_dir () != RIGHT
+         && !to_boolean (s->get_grob_property ("full-size-change")))
+       {
+         str += "_change";
+         s->set_grob_property ("glyph-name", ly_str02scm (str.ch_C ()));         
+       }
+    }
+  else
+    {
+      s->suicide ();
+      return SCM_UNSPECIFIED;
+    }
+
+  return SCM_UNSPECIFIED;
 }
 
-void
-Clef_item::read(String t)
+bool
+Clef::has_interface (Grob* me)
 {
-    type = t;
-    if (type == "violin")
-       y_off = 2;
-    if (type == "alto")
-       y_off = 4;
-    if (type == "tenor")
-       y_off = 6;
-    if (type == "bass")
-       y_off = 6;
+  return me->has_interface (ly_symbol2scm ("clef-interface"));
 }
+
+
 void
-Clef_item::read(Clef_register const &k)
+Clef::set_interface (Grob* me)
 {
-    read(k.clef_type_str_);
+  me->set_interface (ly_symbol2scm ("clef-interface"));
 }
 
-Molecule*
-Clef_item::brew_molecule_p()const
+MAKE_SCHEME_CALLBACK (Clef,brew_molecule,1)
+SCM
+Clef::brew_molecule (SCM smob) 
 {
-    String t = type;
-    if  (change)
-       t += "_change";
-    Symbol s = paper()->lookup_l()->clef(t);
-    Molecule*output = new Molecule(Atom(s));
-    output->translate(Offset(0, paper()->internote() * y_off));
-    return output;
+  Grob * sc = unsmob_grob (smob);
+  SCM glyph = sc->get_grob_property ("glyph-name");
+  if (gh_string_p (glyph))
+    {
+      return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).smobbed_copy ();
+    }
+  else
+    {
+      return SCM_EOL;
+    }
 }
-
-IMPLEMENT_STATIC_NAME(Clef_item);