]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.24
authorfred <fred>
Tue, 26 Mar 2002 22:45:23 +0000 (22:45 +0000)
committerfred <fred>
Tue, 26 Mar 2002 22:45:23 +0000 (22:45 +0000)
lily/include/time-signature.hh
lily/time-signature-engraver.cc
lily/time-signature.cc

index e09572632fa9d4338b4705eb4136ffc74f75397e..4d02f04693f216423ae97c6e43bd26d4f57fa62c 100644 (file)
   C style time_signatures, 2+3+2/8 time_signatures, alla breve.
   
  */
-class Time_signature: public Item {
+class Time_signature: public Item
+{
+  Molecule special_time_signature (String,int,int) const;
+  Molecule time_signature (int, int)const;
+  
 protected:
   virtual Molecule*do_brew_molecule_p() const;
 public:
index 965ecbf3c4431f53ef2df6750c7b4a70699bbef9..0e6f874f1f6d5393deff9355a4619ff5c8308446 100644 (file)
@@ -35,12 +35,10 @@ Time_signature_engraver::do_process_requests()
   Time_signature_change_req *req = timing_grav_l->time_signature_req_l();
   if (req)
     {
-      Array<int> args;
-      args.push (req->beats_i_);
-      args.push (req->one_beat_i_);
-       
       time_signature_p_ = new Time_signature;
-      time_signature_p_->args_ = args;
+      time_signature_p_->set_elt_property ("fraction",
+                                          gh_cons (gh_int2scm (req->beats_i_),
+                                                   gh_int2scm (req->one_beat_i_))); 
       time_signature_p_->set_elt_property ("break-aligned", SCM_BOOL_T);
     }
 
index aaa7952d8e555ba34900fc835d299f9b49aa748b..24f0fa73f0d8cd51a49da566cacad039146bbcd8 100644 (file)
@@ -23,25 +23,76 @@ Molecule*
 Time_signature::do_brew_molecule_p () const
 {
   SCM st = get_elt_property ("style");
+
+  SCM frac = get_elt_property ("fraction");
+  int n = 4;
+  int d = 4;
+  if (gh_pair_p (frac))
+    {
+      n = gh_scm2int (gh_car (frac));
+      d = gh_scm2int (gh_cdr (frac));
+    }
+
   
   if (gh_string_p (st))
     {
       String style (ly_scm2string (st));
       if (style[0]=='1')
        {
-         Array<int> tmparr = args_;
-         return new Molecule( lookup_l ()->time_signature (args_[0], 0, paper_l ()));
+         return new Molecule (time_signature (n, 0));
        }
       else
        {
-         return new Molecule( lookup_l ()-> special_time_signature (style, args_[0], args_[1], paper_l ()));
+         return new Molecule (special_time_signature (style, n, d));
        }
     }
   else
-    return new Molecule(lookup_l ()->time_signature (args_[0], args_[1],paper_l ()));
+    return new Molecule (time_signature (n,d));
 }
 
+Molecule
+Time_signature::special_time_signature (String s, int n, int d) const
+{
+  // First guess: s contains only the signature style
+  String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d);
+  
+  Molecule m = lookup_l ()->afm_find (symbolname, false);
+  if (!m.empty_b()) 
+    return m;
+
+  // Second guess: s contains the full signature name
+  m = lookup_l ()->afm_find ("timesig-"+s, false);
+  if (!m.empty_b ()) 
+    return m;
+
+  // Resort to default layout with numbers
+  return time_signature (n,d);
+}
 
 
+Molecule
+Time_signature::time_signature (int num, int den) const
+{
+  String sty = "number";
 
+  /*
+    UGH: need to look at fontsize.
+   */
+  Molecule n (lookup_l ()->text (sty, to_str (num), paper_l ()));
+  Molecule d (lookup_l ()->text (sty, to_str (den), paper_l ()));
+  n.align_to (X_AXIS, CENTER);
+  d.align_to (X_AXIS, CENTER);
+  Molecule m;
+  if (den)
+    {
+      m.add_at_edge (Y_AXIS, UP, n, 0.0);
+      m.add_at_edge (Y_AXIS, DOWN, d, 0.0);
+    }
+  else
+    {
+      m = n;
+      m.align_to (Y_AXIS, CENTER);
+    }
+  return m;
+}