]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.30
authorfred <fred>
Sun, 24 Mar 2002 19:31:20 +0000 (19:31 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:31:20 +0000 (19:31 +0000)
Documentation/error.pod
Documentation/lilyinput.pod
src/slur.cc
src/slurreg.cc [new file with mode: 0644]
src/texslur.cc

index 1888beaf98cbeca1594431d1055e0673dbc2a14f..0a73c5b627ba9001788aee9489de23dd14eb4c9e 100644 (file)
@@ -10,6 +10,8 @@ A correctly parsed F<input.ly> does not guarantuee output. A lot
 (most) of the checking is done B<after> parsing (some checks even are
 done after the break calc!); I'm sorry.
 
+[outdated]
+
 The parser's job is to construct appropriate objects. It will B<only>
 detect parse errors.
 
index 6e086690716801b831a307f7295113936c5c5619..dfdd59794832ec97a7b3c6f41a545bd67e316efe 100644 (file)
@@ -39,7 +39,7 @@ than in "command" mode, eg,
 
        identifier = score { .. }
 
-So you have to signal that to the tokenizer. This is done with
+So you have to signal this to the tokenizer. This is done with
 '$'. '$' is a delimiter, which used by the tokenizer only. The same
 goes for lyrics, it has a '@' delimiter.
 
index 5b7f99d16ed4fb157de1cf6d1431f93cf71dc939..856ca990352b46f0c5af5c180812eed76f1b5ca6 100644 (file)
 #include "molecule.hh"
 #include "debug.hh"
 #include "boxes.hh"
+
 NAME_METHOD(Slur);
+
 Slur::Slur()
 {
-    dir = 0;
     open_right=open_left=false;
 }
 
@@ -50,9 +51,9 @@ Slur::set_default_dir()
     /* should consult stems */
     Real meanpos = sumpos/Real(encompass.size());
     if (meanpos < 5)           // todo
-       dir = -1;
+       dir_i_ = -1;
     else
-       dir = 1;    
+       dir_i_ = 1;    
 }
 
 void
@@ -85,7 +86,8 @@ Slur::do_break_at(PCol*l, PCol*r) const
 void
 Slur::do_post_processing()
 {
-    set_default_dir();
+    if (!dir_i_)
+       set_default_dir();
 }
 
 Molecule*
@@ -104,12 +106,12 @@ Slur::brew_molecule_p() const
     Notehead *rnote_p =encompass.top();
     int lpos_i = lnote_p->position;
     int rpos_i = rnote_p->position;
-    Offset  left_off(lnote_p->x_dir, lpos_i + 2*dir);
-    Offset right_off(lnote_p->x_dir, rpos_i + 2*dir);
+    Offset  left_off(lnote_p->x_dir, lpos_i + 2*dir_i_);
+    Offset right_off(lnote_p->x_dir, rpos_i + 2*dir_i_);
     if (!lnote_p->extremal)
-       left_off += Offset(0.5, -dir);
+       left_off += Offset(0.5, -dir_i_);
     if (!rnote_p->extremal)
-       right_off+= Offset(-0.5, -dir);
+       right_off+= Offset(-0.5, -dir_i_);
     
     int dy = int(right_off.y - left_off.y);
     
@@ -120,7 +122,7 @@ Slur::brew_molecule_p() const
     w+= (right_off.x - left_off.x) * nw_f ;
     Real round_w = w;          // slur lookup rounds the slurwidth .
     
-    Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir);
+    Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir_i_);
 
     Real error = w-round_w;
     
diff --git a/src/slurreg.cc b/src/slurreg.cc
new file mode 100644 (file)
index 0000000..05a7564
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+  slurreg.cc -- implement Slur_register
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "complexwalker.hh"
+#include "slurreg.hh"
+#include "slur.hh"
+#include "debug.hh"
+void
+Slur_register::set_dir(int i)
+{
+    dir_i_ = i;
+}
+
+Slur_register::Slur_register(Complex_walker* w)
+    : Request_register(w)
+{
+    set_dir(0);
+}
+
+bool
+Slur_register::try_request(Request *req_l)
+{
+    if(!req_l->slur())
+       return false;
+
+    accepted_req_arr_.push(req_l);
+    return true;
+}
+
+void
+Slur_register::acknowledge_element(Staff_elem_info info)
+{
+    if (info.elem_p_->name() == String("Notehead")) { 
+       Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh
+       for (int i = 0; i < slur_l_stack_.size(); i++)
+           slur_l_stack_[i]->add(head_p );
+       for (int i = 0; i < end_slur_l_arr_.size(); i++)
+           end_slur_l_arr_[i]->add(head_p);
+    }
+}
+/*
+  abracadabra
+  */
+void
+Slur_register::process_request()
+{
+    Array<Slur*> start_slur_l_arr_;
+    for (int i=0; i< accepted_req_arr_.size(); i++) {
+       Slur_req* slur_req_l = accepted_req_arr_[i]->slur();
+       // end slur: move the slur to other array
+       if (slur_req_l->spantype == Span_req::STOP) {
+           if (slur_l_stack_.empty())
+               warning("can't find slur to end",
+                     slur_req_l->defined_ch_c_l_m);
+           else {
+               end_slur_l_arr_.push(slur_l_stack_.pop());
+               requests_arr_.pop();
+           }
+       } else  if (slur_req_l->spantype == Span_req::START) {
+           // push a new slur onto stack.
+           //(use temp. array to wait for all slur STOPs)
+           Slur * s_p =new Slur;
+           requests_arr_.push(slur_req_l);
+           start_slur_l_arr_.push(s_p);
+           announce_element(Staff_elem_info(s_p, slur_req_l, this));
+       }
+    }
+    for (int i=0; i < start_slur_l_arr_.size(); i++)
+       slur_l_stack_.push(start_slur_l_arr_[i]);
+}
+
+void
+Slur_register::do_pre_move_process()
+{
+    for (int i = 0; i < end_slur_l_arr_.size(); i++) {
+       if (dir_i_) 
+           end_slur_l_arr_[i]->dir_i_ = dir_i_;
+       typeset_element(end_slur_l_arr_[i]);
+    }
+    end_slur_l_arr_.set_size(0);
+}
+
+Slur_register::~Slur_register()
+{
+    for (int i=0; i < requests_arr_.size(); i++) {
+       warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m);
+    }
+}
index a3a29db4444f557bd4795c7adea80347bc0fbc6e..71cded95299cdebe83f02da7c43dadc746320640 100644 (file)
@@ -28,9 +28,11 @@ char direction_char(int y_sign)
 Symbol
 Lookup::half_slur_middlepart(Real &dx, int dir)
 {
-    if (dx >= convert_dimen(400,"pt")) // todo
-       error ("halfslur too large");
-    int    widx = int(floor(dx / 4.0));
+    if (dx >= 400 PT) {// todo
+       WARN<<"halfslur too large" <<print_dimen(dx)<< "shrinking (ugh)\n";
+       dx = 400 PT;
+    }
+    int widx = int(floor(dx / 4.0));
     dx = widx * 4.0;
     if (widx) widx --;
     else {
@@ -39,7 +41,7 @@ Lookup::half_slur_middlepart(Real &dx, int dir)
 
     Symbol s;
     
-    s.dim.y = Interval(min(0,0), max(0,0));
+    s.dim.y = Interval(min(0,0), max(0,0)); // todo
     s.dim.x = Interval(0,dx);
 
     String f =  String("\\hslurchar");
@@ -61,22 +63,23 @@ Lookup::half_slur_middlepart(Real &dx, int dir)
 Symbol
 Lookup::half_slur(int dy, Real &dx, int dir, int xpart)
 {
+    Real orig_dx = dx;
     if (!xpart)
        return half_slur_middlepart(dx, dir);
 
     int widx;
                
-    if (dx >= convert_dimen(96,"pt")) {
-       WARN << "Slur half too wide.";
-       dx =  convert_dimen(96,"pt");
+    if (dx >= 96 PT) {
+       WARN << "Slur half too wide." << print_dimen(orig_dx) << " shrinking (ugh)\n";
+       dx =  96 PT;
     }
-    
+
     widx = int(rint(dx/12.0));
     dx = widx*12.0;
     if (widx)
        widx --;
     else {
-       WARN <<  "slur too narrow\n";
+       WARN <<  "slur too narrow " << print_dimen(orig_dx)<<"\n";
     }
        
     Symbol s;
@@ -109,36 +112,36 @@ Lookup::half_slur(int dy, Real &dx, int dir, int xpart)
 
 Symbol
 Lookup::slur (int dy , Real &dx, int dir)
-{                              // ugh. assuming pt here.
-    assert(dx >=0);
+{
+    assert(dx >=0 && abs(dir) <= 1);
     int y_sign = sign(dy);
 
     bool large = dy > 16;
 
     if (y_sign) {
-       large |= dx>= convert_dimen(4*16, "pt");
+       large |= dx>= 4*16 PT;
     } else
-       large |= dx>= convert_dimen(4*54, "pt");
+       large |= dx>= 4*54 PT;
     
     if (large) {
        return big_slur(dy, dx, dir);
     }
-    
+    Real orig_dx = dx;
     int widx = int(floor(dx/4.0)); // slurs better too small..
     dx = 4.0 * widx;
     if (widx)
        widx --;
     else {
-       WARN <<  "slur too narrow\n";
+       WARN <<  "slur too narrow: " << print_dimen(orig_dx) << "\n";
     }
 
     int hidx = dy;
     if (hidx <0)
        hidx = -hidx;
     hidx --; 
-    if (hidx > 16)
-       error("slur to steep");
-    
+    if (hidx > 16) {
+       WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
+    }
     
     Symbol s;
     s.dim.x = Interval(0,dx);
@@ -152,8 +155,11 @@ Lookup::slur (int dy , Real &dx, int dir)
        if (dir < 0)
            idx += 128;
     } else {
-       if (dx >= convert_dimen(4*54, "pt"))
-           error("slur too wide");
+       if (dx >= 4*54 PT) {
+           WARN << "slur too wide: " << print_dimen(dx) <<
+               " shrinking (ugh)\n";
+           dx = 4*54 PT;
+       }
        idx = widx;
        if (dir < 0)
            idx += 54;          
@@ -172,7 +178,7 @@ Lookup::slur (int dy , Real &dx, int dir)
 Symbol
 Lookup::big_slur(int dy , Real &dx, int dir)
 {
-    assert(dx >= convert_dimen(24,"pt"));
+    assert(dx >= 24 PT);
     Real slur_extra =abs(dy)  /2.0 + 2; 
     int l_dy = int(Real (dy)/2 + slur_extra*dir);
     int r_dy =  dy - l_dy;