]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.0.1
authorfred <fred>
Sun, 24 Mar 2002 20:12:44 +0000 (20:12 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:12:44 +0000 (20:12 +0000)
lily/time-signature-engraver.cc [new file with mode: 0644]
lily/time-signature.cc [new file with mode: 0644]
lily/timing-translator.cc

diff --git a/lily/time-signature-engraver.cc b/lily/time-signature-engraver.cc
new file mode 100644 (file)
index 0000000..75d8032
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+  time_signature-reg.cc -- implement Time_signature_engraver
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "time-signature-engraver.hh"
+#include "time-signature.hh"
+#include "command-request.hh"
+#include "timing-engraver.hh"
+#include "engraver-group.hh"
+
+Time_signature_engraver::Time_signature_engraver()
+{ 
+  time_signature_p_ =0;
+}
+
+void
+Time_signature_engraver::do_process_requests()
+{
+  Translator * result =
+    daddy_grav_l()->get_simple_translator (Timing_engraver::static_name());
+
+  if (!result)
+    {
+      warning (_ ("lost in time") + ": " + _ ("can't find") 
+        + " Timing_translator");
+      return ;
+    }
+  
+  Timing_engraver * timing_grav_l= (Timing_engraver*) result->engraver_l ();
+  
+  Time_signature_change_req *req = timing_grav_l->time_signature_req_l();
+  if (req)
+    {
+      Array<Scalar> args;
+      args.push (req->beats_i_);
+      args.push (req->one_beat_i_);
+       
+      time_signature_p_ = new Time_signature (args);
+      time_signature_p_->break_priority_i_ = 1; // ugh
+    }
+
+  if (time_signature_p_)
+    announce_element (Score_element_info (time_signature_p_, req));
+}
+
+void
+Time_signature_engraver::do_pre_move_processing()
+{
+  if (time_signature_p_) 
+    {
+      typeset_element (time_signature_p_);
+      time_signature_p_ =0;
+    }
+}
+
+
+ADD_THIS_TRANSLATOR(Time_signature_engraver);
+IMPLEMENT_IS_TYPE_B1(Time_signature_engraver,Engraver); 
diff --git a/lily/time-signature.cc b/lily/time-signature.cc
new file mode 100644 (file)
index 0000000..e882c55
--- /dev/null
@@ -0,0 +1,23 @@
+#include "scalar.hh"
+#include "molecule.hh"
+#include "time-signature.hh"
+#include "paper-def.hh"
+#include "lookup.hh"
+
+Time_signature::Time_signature (Array<Scalar>a)
+  :args (a)
+{
+  breakable_b_ = true;
+}
+
+Molecule*
+Time_signature::brew_molecule_p() const
+{
+  Atom s = lookup_l ()->time_signature (args);
+  s.translate_axis (-s.extent()[Y_AXIS].center (), Y_AXIS);
+  return new Molecule (Atom (s));
+}
+
+
+
+IMPLEMENT_IS_TYPE_B1(Time_signature,Item);
index ce04be40a97f4e25c60fab59d08b3c8348994cb4..6ab83a2ea9751912ef571f825c66beaef3cb3a02 100644 (file)
@@ -1,10 +1,9 @@
-
 /*
   timing-translator.cc -- implement Timing_translator
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "timing-translator.hh"
@@ -21,8 +20,8 @@ Timing_translator::Timing_translator ()
 bool
 Timing_translator::do_try_request(Request*r)
 {
-  Command_req * c = r->command();
-  if (!(c && c->timing()))
+  Command_req * c = r->access_Command_req ();
+  if (!(c && c->access_Timing_req ()))
     return false;
   for (int i=0; i < timing_req_l_arr_.size (); i++)
     {
@@ -30,22 +29,22 @@ Timing_translator::do_try_request(Request*r)
        return true;
       if (timing_req_l_arr_[i]->name() == r->name())
        {
-         r->warning (_("conflicting timing request"));
+         r->warning (_ ("conflicting timing request"));
          return false;
        }
     }
 
-  timing_req_l_arr_.push(c->timing());
+  timing_req_l_arr_.push(c->access_Timing_req ());
   return true;
 }
 
-Meter_change_req*
-Timing_translator::meter_req_l() const
+Time_signature_change_req*
+Timing_translator::time_signature_req_l() const
 {
-  Meter_change_req *m_l=0;
+  Time_signature_change_req *m_l=0;
   for (int i=0; !m_l && i < timing_req_l_arr_.size (); i++)
     {
-      m_l=timing_req_l_arr_[i]->meterchange();
+      m_l=timing_req_l_arr_[i]->access_Time_signature_change_req ();
     }
   return m_l;
 }
@@ -56,23 +55,23 @@ Timing_translator::do_process_requests()
   for (int i=0; i < timing_req_l_arr_.size (); i++)
     {
       Timing_req * tr_l = timing_req_l_arr_[i];
-      Meter_change_req *m_l = tr_l->meterchange();
+      Time_signature_change_req *m_l = tr_l->access_Time_signature_change_req ();
       if (m_l)
        {
          int b_i= m_l->beats_i_;
          int o_i = m_l->one_beat_i_;
-         if (! time_.allow_meter_change_b())
-           tr_l->warning (_("Meter change not allowed here"));
+         if (! time_.allow_time_signature_change_b())
+           tr_l->warning (_ ("time signature change not allowed here"));
          else
            {
-             time_.set_meter (b_i, o_i);
+             time_.set_time_signature (b_i, o_i);
              default_grouping_ =
                Rhythmic_grouping (MInterval (0,Moment (b_i, o_i)), b_i);
            }
        }
-      else if (tr_l->partial())
+      else if (tr_l->access_Partial_measure_req ())
        {
-         Moment m = tr_l->partial()->duration_;
+         Moment m = tr_l->access_Partial_measure_req ()->duration_;
          String error = time_.try_set_partial_str (m);
          if (error.length_i ())
            {
@@ -81,26 +80,27 @@ Timing_translator::do_process_requests()
          else
            time_.setpartial (m);
        }
-      else if (tr_l->barcheck())
+      else if (tr_l->access_Barcheck_req())
        {
          if (time_.whole_in_measure_)
            {
-             tr_l ->warning (_("Barcheck failed"));
+             tr_l ->warning (_f ("barcheck failed by: %s", 
+               time_.whole_in_measure_.str ()));
 
              time_.whole_in_measure_ = 0; // resync
              time_.error_b_ = true;
            }
 
        }
-      else if (tr_l->cadenza())
+      else if (tr_l->access_Cadenza_req ())
        {
-         time_.set_cadenza (tr_l->cadenza()->on_b_);
+         time_.set_cadenza (tr_l->access_Cadenza_req ()->on_b_);
        }
-      else if (tr_l->measuregrouping())
+      else if (tr_l->access_Measure_grouping_req ())
        {
          default_grouping_ =
-           parse_grouping (tr_l->measuregrouping()->beat_i_arr_,
-                           tr_l->measuregrouping()->elt_length_arr_);
+           parse_grouping (tr_l->access_Measure_grouping_req ()->beat_i_arr_,
+                           tr_l->access_Measure_grouping_req ()->elt_length_arr_);
 
        }
     }