]> git.donarmstrong.com Git - lilypond.git/blobdiff - src/slur.cc
partial: 0.0.39-1.jcn
[lilypond.git] / src / slur.cc
index 2cdddfec47b9071fb5b2a05bcb0c962d20ba71ad..ba77a6948e710a3ac129879974bcc876c019a240 100644 (file)
@@ -1,23 +1,29 @@
+/*
+
+  TODO:
+  think about crossing stems.
+ */
 #include "slur.hh"
 #include "scalar.hh"
 #include "lookup.hh"
-#include "paper.hh"
+#include "paper-def.hh"
 #include "notehead.hh"
 #include "pcol.hh"
 #include "molecule.hh"
 #include "debug.hh"
 #include "boxes.hh"
-NAME_METHOD(Slur);
+
+
+
 Slur::Slur()
 {
-    dir = 0;
     open_right=open_left=false;
 }
 
 Offset
 Slur::center() const
 {
-    int pos1 = encompass.last()->position;
+    int pos1 = encompass.top()->position;
     int pos2 = encompass[0]->position;
 
     int dy =  pos1-pos2;
@@ -31,7 +37,7 @@ void
 Slur::add(Notehead*n)
 {
     encompass.push(n);
-    dependencies.push(n);
+    add_dependency(n);
 }
 
 void
@@ -45,15 +51,15 @@ 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
 Slur::do_pre_processing()
 {
-    right  = encompass.last()->pcol_l_;
+    right  = encompass.top()->pcol_l_;
     left = encompass[0]->pcol_l_;    
 }
 
@@ -80,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*
@@ -96,15 +103,15 @@ Slur::brew_molecule_p() const
     assert(encompass.size()>0);        // todo
     
     Notehead *lnote_p =encompass[0];
-    Notehead *rnote_p =encompass.last();
+    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);
     
@@ -115,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;