]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-spanner.cc
* input/regression/beam-quanting-horizontal.ly: update texidoc
[lilypond.git] / lily / line-spanner.cc
index 7ae32efb41ce90045758bfaa3c5e3c7079a961ed..fabfbf1a76e6bd28a24900935396999b5d3bcd4b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "molecule.hh"
@@ -14,6 +14,7 @@
 #include "paper-column.hh"
 #include "staff-symbol-referencer.hh"
 #include "font-interface.hh"
+#include "warn.hh"
 
 #include <math.h>
 
@@ -123,7 +124,7 @@ Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
                                                           SCM_UNDEFINED));
       Molecule m = fm->find_by_name ("scripts-trill-element");
       do
-       mol.add_at_edge (X_AXIS, RIGHT, m, 0);
+       mol.add_at_edge (X_AXIS, RIGHT, m, 0,0);
       while (m.extent (X_AXIS).length ()
             && mol.extent (X_AXIS).length ()
             + m.extent (X_AXIS).length () < dx);
@@ -214,13 +215,17 @@ Line_spanner::brew_molecule (SCM smob)
   
   Item** bound = bound_drul + 1;
 
-  Grob *common[] = { 0, 0 };
-  for (Axis a = X_AXIS;  a < NO_AXES; a = Axis (a + 1))
+  Grob *common[] = { me, me };
+  for (int a = X_AXIS;  a < NO_AXES; a++)
     {
-      common[a] = bound[LEFT]->common_refpoint (bound[RIGHT], a);
+      common[a] = me->common_refpoint (bound[RIGHT], Axis (a));
+      common[a] = common[a]->common_refpoint (bound[LEFT], Axis (a));
       
       if (!common[a])
-       return SCM_EOL;
+       {
+         programming_error ("No common point!");
+         return SCM_EOL;
+       }
     }
   
   Real gap = gh_scm2double (me->get_grob_property ("gap"));
@@ -258,24 +263,22 @@ Line_spanner::brew_molecule (SCM smob)
   else
     {
       Real off = gap + ((bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()*3)/4); // distance from center to start of line
-      dxy[X_AXIS] = bound[RIGHT]->extent (common[X_AXIS], X_AXIS).center ()
-       - bound[LEFT]->extent (common[X_AXIS], X_AXIS).center ();
-      dxy[Y_AXIS] = bound[RIGHT]->extent (common[Y_AXIS], Y_AXIS).center ()
-       - bound[LEFT]->extent (common[Y_AXIS], Y_AXIS).center ();
 
-      dist = sqrt (dxy[X_AXIS]*dxy[X_AXIS]+dxy[Y_AXIS]*dxy[Y_AXIS]);
-      ofxy = dxy* (off/dist);
-      dxy -= 2*ofxy;
+      for (int a = X_AXIS; a < NO_AXES; a++)
+       {
+         Axis ax = (Axis)a;
+         dxy[ax] =
+           + bound[RIGHT]->extent (common[X_AXIS], ax).center ()
+           - bound[LEFT]->extent (common[X_AXIS], ax).center ();
+
+         my_off[ax] =me->relative_coordinate (common[a], ax);
+         his_off[ax] = bound[LEFT]->relative_coordinate (common[a], ax);
+         
+       }
 
-      my_off = Offset (me->relative_coordinate (common[X_AXIS], X_AXIS),
-                      me->relative_coordinate (common[Y_AXIS], Y_AXIS)); 
-      
-      his_off = Offset (bound[LEFT]->relative_coordinate (common[X_AXIS],
-                                                         X_AXIS),
-                       bound[LEFT]->relative_coordinate (common[Y_AXIS],
-                                                         Y_AXIS)); 
-      
-      }
+      ofxy = dxy * (off/dxy.length ());
+      dxy -= 2*ofxy;
+    }
 
   Real thick = me->get_paper ()->get_var ("linethickness");  
 
@@ -294,8 +297,10 @@ Line_spanner::brew_molecule (SCM smob)
 
 
 ADD_INTERFACE (Line_spanner, "line-spanner-interface",
-  "Generic line drawn between two objects, eg. for use with glissandi.
-gap is measured in staff-spaces.   ",
+  "Generic line drawn between two objects, eg. for use with glissandi.\n"
+"gap is measured in staff-spaces.\n"
+"The property 'type is one of: line, dashed-line, trill, dotted-line or zigzag.\n"
+"\n",
   "gap dash-period dash-length zigzag-width zigzag-length thickness type");