]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.66
authorfred <fred>
Tue, 26 Mar 2002 23:24:00 +0000 (23:24 +0000)
committerfred <fred>
Tue, 26 Mar 2002 23:24:00 +0000 (23:24 +0000)
lily/cross-staff.cc
lily/include/slur.hh
lily/slur.cc
scm/slur.scm

index e1874661219789c6690a770b18c1a0e0c199302c..8e5e8e6f4a84f393994c10bfd23a36c2d3ab8ed8 100644 (file)
@@ -4,6 +4,9 @@
 #include "spanner.hh"
 #include "warn.hh"
 
+/*
+  JUNKME
+ */
 Real
 calc_interstaff_dist (Item const *item, Spanner const *span)
 {
index 80b18fbfc7569a1100ad96951262969011140aec..3176d4b6bbc848d429b536bc37be57881e3e8b9f 100644 (file)
@@ -37,7 +37,6 @@ private:
   void de_uglyfy (Slur_bezier_bow* bb, Real default_height);
   void set_extremities ();
   void set_control_points ();
-  int cross_staff_count () const;
   Offset encompass_offset (Note_column const* )const;
 };
 
index 05ff6477eafef83fbbf80becce13cd5acf83393e..260e2cecc922dfb101a49a1871a5a8a8e671f021 100644 (file)
@@ -9,6 +9,7 @@
 
 /*
   [TODO]
+    * fix broken interstaff slurs
     * begin and end should be treated as a/acknowledge Scripts.
     * broken slur should have uniform trend
     * smart changing of endings
@@ -28,7 +29,6 @@
 #include "debug.hh"
 #include "slur-bezier-bow.hh"
 #include "main.hh"
-#include "cross-staff.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
 
@@ -130,8 +130,8 @@ Slur::encompass_offset (Note_column const* col) const
   if (!stem_l)
     {
       warning (_ ("Slur over rest?"));
-     o[X_AXIS] = col->relative_coordinate (0, X_AXIS);
-      o[Y_AXIS] = col->extent (Y_AXIS)[dir];
+      o[X_AXIS] = col->relative_coordinate (0, X_AXIS);
+      o[Y_AXIS] = col->relative_coordinate (0, Y_AXIS);
       return o;  
     }
   Direction stem_dir = Directional_element_interface (stem_l).get ();
@@ -146,18 +146,17 @@ Slur::encompass_offset (Note_column const* col) const
   if ((stem_dir == dir)
       && !stem_l->extent (Y_AXIS).empty_b ())
     {
-      o[Y_AXIS] = stem_l->extent (Y_AXIS)[dir];
+      o[Y_AXIS] = stem_l->relative_coordinate (0, Y_AXIS);
     }
   else
     {
-      o[Y_AXIS] = col->extent (Y_AXIS)[dir];
+      o[Y_AXIS] = col->relative_coordinate (0, Y_AXIS);
     }
 
   /*
    leave a gap: slur mustn't touch head/stem
    */
   o[Y_AXIS] += dir * paper_l ()->get_var ("slur_y_free");
-  o[Y_AXIS] -= calc_interstaff_dist (stem_l, this);
   return o;
 }
 
@@ -220,10 +219,8 @@ Slur::set_extremities ()
          for (SCM s = scm_eval (ly_symbol2scm ("slur-extremity-rules"));
               s != SCM_EOL; s = gh_cdr (s))
            {
-             SCM r = scm_eval (scm_listify (gh_caar (s),
-                                            this->self_scm_,
-                                            gh_int2scm ((int)dir),
-                                            SCM_UNDEFINED));
+             SCM r = gh_call2 (gh_caar (s), this->self_scm_,
+                                gh_int2scm ((int)dir));
              if (r != SCM_BOOL_F)
                {
                  index_set_cell (get_elt_property ("attachment"), dir,
@@ -304,39 +301,13 @@ Slur::get_attachment (Direction dir) const
        }
     }
 
-
-  /*
-    URG
-   */
-
-  if (str != "loose-end")
-    {
-      Link_array<Note_column> encompass_arr =
-       Pointer_group_interface__extract_elements (this, (Note_column*)0,
-                                                  "note-columns");
-      o -= Offset (0, calc_interstaff_dist (dir == LEFT ? encompass_arr[0]
-                                           : encompass_arr.top (), this));
-    }
+    if (str != "loose-end")
+      o += Offset (0, get_bound (dir)->relative_coordinate (0, Y_AXIS)
+                - relative_coordinate (0, Y_AXIS));
+    
   return o;
 }
 
-int
-Slur::cross_staff_count ()const
-{
-  Link_array<Note_column> encompass_arr =
-    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
-
-  int k=0;
-
-  for (int i = 0; i < encompass_arr.size (); i++)
-    {
-      if (calc_interstaff_dist (encompass_arr[i], this))
-       k++;
-    }
-  return k;
-}
-
-
 Array<Offset>
 Slur::get_encompass_offset_arr () const
 {
@@ -345,7 +316,8 @@ Slur::get_encompass_offset_arr () const
   
   Array<Offset> offset_arr;
 
-  Offset origin (relative_coordinate (0, X_AXIS), 0);
+  Offset origin (relative_coordinate (0, X_AXIS),
+                relative_coordinate (0, Y_AXIS));
 
   int first = 1;
   int last = encompass_arr.size () - 2;
@@ -355,18 +327,12 @@ Slur::get_encompass_offset_arr () const
   /*
     left is broken edge
   */
-  int cross_count  = cross_staff_count ();
 
-  /*
-    URG
-  */
-  bool cross_b = cross_count && cross_count < encompass_arr.size ();
   if (encompass_arr[0] != get_bound (LEFT))
     {
       first--;
-      Real is = calc_interstaff_dist (encompass_arr[0], this);
-      if (cross_b)
-       offset_arr[0][Y_AXIS] += is;
+      offset_arr[0][Y_AXIS] -= encompass_arr[0]->relative_coordinate (0, Y_AXIS)
+       - relative_coordinate (0, Y_AXIS);
     }
 
   /*
@@ -385,6 +351,12 @@ Slur::get_encompass_offset_arr () const
 
   offset_arr.push (Offset (spanner_length (), 0) + get_attachment (RIGHT));
 
+  if (encompass_arr[0] != get_bound (LEFT))
+    {
+      offset_arr.top ()[Y_AXIS] -= encompass_arr.top ()->relative_coordinate (0, Y_AXIS)
+       - relative_coordinate (0, Y_AXIS);
+    }
+
   return offset_arr;
 }
 
index c21ae76db46b2ee00b883092a105fb7e5402ac55..58a1b2b99f316141b4cddac78c9ecc67dba72dde 100644 (file)
@@ -8,41 +8,65 @@
      stem
      (get-pointer stem 'heads))))
 
+
+;; Slur-extremity-rules is a list of rules.  Each rule is a pair 
+;; (fuction . attachment), where function takes two arguments,
+;; the slur and the direction of the attachment.
+;;
+;; The rules are tried starting from the car of this list.  If the
+;; function part (car) evaluates to #t, the corresponding
+;; attachment (cdr) is used for the slur's dir.  Otherwise, the next
+;; rule is tried.
+;;
+;; Currently, we have attachments:
+;;
+;;    'head 'along-side-stem 'stem 'loose-end
+;;
+
 (define slur-extremity-rules
-  '(
-    ((lambda (slur dir)
+  (list
+    (cons (lambda (slur dir)
        ;; urg, code dup
        (let* ((note-columns (get-pointer slur 'note-columns))
         (col (if (= dir 1) (car note-columns) (car (reverse note-columns))))
         (stem (get-pointer col 'stem)))
         (and stem
              (not (= (get-property slur 'direction) 
-                     (get-property stem 'direction)))))) . head)
-
-    ((lambda (slur dir)
-       ;; if attached-to-stem
-       (and (attached-to-stem slur dir)
-           ;; and got beam
-           ;; urg, code dup
-           (let* ((note-columns (get-pointer slur 'note-columns))
-                  (col (if (= dir 1) (car note-columns) (car (reverse note-columns))))
-                  (stem (get-pointer col 'stem)))
-           (and stem
-                (get-pointer stem 'beam)
-                ;; and beam on same side as slur
-                (let ((beaming (get-property stem 'beaming)))
-                  (if (pair? beaming)
-                      (>= 1
-                          (if (= dir -1) (car beaming) (cdr beaming)))
-                      #f)))))) . stem)
-
-    ((lambda (slur dir) (not (attached-to-stem slur dir))) . loose-end)
+                     (get-property stem 'direction))))))  'head)
+
+    (cons (lambda (slur dir)
+           ;; if attached-to-stem
+           (and (attached-to-stem slur dir)
+                ;; and got beam
+                ;; urg, code dup
+                (let* ((note-columns (get-pointer slur 'note-columns))
+                       (col (if (= dir 1) (car note-columns) (car (reverse note-columns))))
+                       (stem (get-pointer col 'stem)))
+                  (and stem
+                       (get-pointer stem 'beam)
+                       ;; and beam on same side as slur
+                       (let ((beaming (get-property stem 'beaming)))
+                         (if (pair? beaming)
+                             (<= 1
+                                 (if (= dir -1) (car beaming) (cdr beaming)))
+                             #f))))))
+         'stem)
+
+    (cons (lambda (slur dir) (not (attached-to-stem slur dir)))  'loose-end)
 
     ;; default case, attach to head
-    ((lambda (x y) #t) . head)
+    (cons (lambda (x y) #t)  'head)
     ))
 
 
+;; This list defines the offsets for each type of attachment.
+;; The format of each element is
+;; (attachment stem-dir * attachment-dir slur-dir)
+;; Different attachments have different default points:
+;;
+;; head: Default position is centered in X, on outer side of head Y
+;; along-side-stem: Default position is on stem X, on outer side of head Y
+;; stem: Default position is on stem X, at stem end Y
 (define slur-extremity-offset-alist
   '(
     ((head 1 1) . (-0.25 . 0.2))