]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/time-signature.cc
(text_dimension): only multiply with
[lilypond.git] / lily / time-signature.cc
index 187b88b832f34099f71231dc8f00577688f3afe1..bef6078c75b5f3a3cb644f67df497c0b71bc8169 100644 (file)
@@ -1,14 +1,14 @@
 /*   
-  time-signature.cc --  implement Time_signature
+  time-signature.cc -- implement Time_signature
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 
-#include "molecule.hh"
+#include "stencil.hh"
 #include "text-item.hh"
 #include "time-signature.hh"
 #include "paper-def.hh"
 #include "warn.hh"
 #include "staff-symbol-referencer.hh"
 
-MAKE_SCHEME_CALLBACK (Time_signature, brew_molecule, 1);
-/* TODO: make different functions for special and normal timesigs. */
+
+/*
+  TODO:
+
+  this file should go ; The formatting can completely be done with
+  markups.
+  
+ */
+
+MAKE_SCHEME_CALLBACK (Time_signature, print, 1);
 SCM
-Time_signature::brew_molecule (SCM smob) 
+Time_signature::print (SCM smob) 
 {
   Grob * me = unsmob_grob (smob);
-  SCM st = me->get_grob_property ("style");
-  SCM frac = me->get_grob_property ("fraction");
+  SCM st = me->get_property ("style");
+  SCM frac = me->get_property ("fraction");
   int n = 4;
   int d = 4;
-  if (gh_pair_p (frac))
+  if (ly_pair_p (frac))
     {
-      n = gh_scm2int (ly_car (frac));
-      d = gh_scm2int (ly_cdr (frac));
+      n = ly_scm2int (ly_car (frac));
+      d = ly_scm2int (ly_cdr (frac));
     }
 
-  Molecule m;
-  if (gh_symbol_p (st))
+  Stencil m;
+  if (ly_symbol_p (st))
     {
       String style (ly_scm2string (scm_symbol_to_string (st)));
       if (style[0]=='1')
@@ -54,7 +62,7 @@ Time_signature::brew_molecule (SCM smob)
   return m.smobbed_copy ();
 }
 
-Molecule
+Stencil
 Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d)
 {
   String style = ly_scm2string (scm_symbol_to_string (scm_style));
@@ -76,10 +84,10 @@ Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d)
     }
 
   String char_name = style + to_string (n) + "/" + to_string (d);
-  me->set_grob_property ("font-family", ly_symbol2scm ("music"));
-  Molecule out = Font_interface::get_default_font (me)
+  me->set_property ("font-encoding", ly_symbol2scm ("music"));
+  Stencil out = Font_interface::get_default_font (me)
     ->find_by_name ("timesig-" + char_name);
-  if (!out.empty_b ())
+  if (!out.is_empty ())
     return out;
 
   /* If there is no such symbol, we default to the numbered style.
@@ -89,25 +97,25 @@ Time_signature::special_time_signature (Grob *me, SCM scm_style, int n, int d)
   return numbered_time_signature (me, n, d);
 }
 
-Molecule
+Stencil
 Time_signature::numbered_time_signature (Grob*me,int num, int den)
 {
-  SCM chain = Font_interface::font_alist_chain (me);
-  me->set_grob_property ("font-family", ly_symbol2scm ("number"));
-
-SCM sn =
-    Text_item::interpret_markup (me->self_scm(), chain,
-                                scm_makfrom0str (to_string (num).to_str0 ()));
-SCM sd =
-    Text_item::interpret_markup (me->self_scm(), chain,
-                                scm_makfrom0str (to_string (den).to_str0 ()));
-
-  Molecule n = *unsmob_molecule (sn);
-  Molecule d = *unsmob_molecule (sd);
+  SCM chain = me->get_property_alist_chain (Font_interface::text_font_alist_chain (me));
+  chain = scm_cons (scm_list_1 (scm_cons (ly_symbol2scm ("font-encoding"),
+                                        ly_symbol2scm ("number"))),
+                   chain);
+                               
+  SCM sn = Text_item::interpret_markup (me->get_paper ()->self_scm (), chain,
+                                       scm_makfrom0str (to_string (num).to_str0 ()));
+  SCM sd = Text_item::interpret_markup (me->get_paper ()->self_scm (), chain,
+                                       scm_makfrom0str (to_string (den).to_str0 ()));
+
+  Stencil n = *unsmob_stencil (sn);
+  Stencil d = *unsmob_stencil (sd);
                              
   n.align_to (X_AXIS, CENTER);
   d.align_to (X_AXIS, CENTER);
-  Molecule m;
+  Stencil m;
   if (den)
     {
       m.add_at_edge (Y_AXIS, UP, n, 0.0, 0);