]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-spanner.cc
* Documentation/user/refman.itely: bugfix: "Chord namess" ->
[lilypond.git] / lily / line-spanner.cc
index 9f8a47b83045d8e7dcf7a6fbcaca7b78c0155155..b0084a8075e354e09c2e405140488d1c23510fd5 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"
@@ -61,6 +61,30 @@ line_atom (Grob* me, Real thick, Real dx, Real dy)
   return list;
 }
 
+static SCM
+zigzag_atom (Grob* me, Real thick, Real dx, Real dy)
+{
+  Real staff_space = Staff_symbol_referencer::staff_space (me);
+  SCM ws = me->get_grob_property ("zigzag-width");
+  SCM ls = me->get_grob_property ("zigzag-length");
+  double w = (gh_number_p(ws) ? gh_scm2double(ws) : 1)*staff_space;
+  double l = (gh_number_p(ls) ? gh_scm2double(ls) : 1)*w;
+  double h = l>w/2 ? sqrt(l*l-w*w/4) : 0;
+  
+  SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"),
+                     gh_bool2scm (true),
+                     gh_double2scm (w),
+                     gh_double2scm (h),
+                     gh_double2scm (thick),
+                     gh_double2scm (dx),
+                     gh_double2scm (dy),
+                     SCM_UNDEFINED);
+
+  return list;
+}
+
+
+
 Molecule
 Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
 {
@@ -76,6 +100,15 @@ Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
             Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
       mol = Molecule (b, line_atom (me, thick, dx, dy));
     }
+  else if (gh_symbol_p (type)
+          && type == ly_symbol2scm ("zigzag"))
+    {
+      // TODO:
+      Box b (Interval (-0.5* thick +  (0 <? dx) ,0.5* thick+ (0 >? dx)),
+            Interval (- 0.5* thick + (0<? dy), 0.5*thick + (0 >? dy)));
+      mol = Molecule (b, zigzag_atom (me, thick, dx, dy));
+
+    }
   else if (gh_symbol_p (type)
           && type == ly_symbol2scm ("trill"))
     {
@@ -90,7 +123,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);
@@ -114,9 +147,9 @@ Line_spanner::get_broken_offset (Grob *me, Direction dir)
   if (!bound->break_status_dir ())
     {
       Grob *common[] = {
-       bound->common_refpoint (Staff_symbol_referencer::staff_symbol_l (me),
+       bound->common_refpoint (Staff_symbol_referencer::get_staff_symbol (me),
                                X_AXIS),
-       bound->common_refpoint (Staff_symbol_referencer::staff_symbol_l (me),
+       bound->common_refpoint (Staff_symbol_referencer::get_staff_symbol (me),
                                Y_AXIS)
       };
   
@@ -133,15 +166,15 @@ Line_spanner::broken_trend_offset (Grob *me, Direction dir)
      the unbroken line-spanner would have had.
      From slur */
   Offset o;
-  if (Spanner *mother =  dynamic_cast<Spanner*> (me->original_l_))
+  if (Spanner *mother =  dynamic_cast<Spanner*> (me->original_))
     {
-      for (int i = dir == LEFT ? 0 : mother->broken_into_l_arr_.size () - 1;
-          dir == LEFT ? i < mother->broken_into_l_arr_.size () : i > 0;
+      for (int i = dir == LEFT ? 0 : mother->broken_intos_.size () - 1;
+          dir == LEFT ? i < mother->broken_intos_.size () : i > 0;
           dir == LEFT ? i++ : i--)
        {
-         if (mother->broken_into_l_arr_[i - dir] == me)
+         if (mother->broken_intos_[i - dir] == me)
            {
-             Grob *neighbour = mother->broken_into_l_arr_[i];
+             Grob *neighbour = mother->broken_intos_[i];
              Offset neighbour_o = get_broken_offset (neighbour, dir);
              Offset me_o = get_broken_offset (me, -dir);
              // Hmm, why not return me_o[X], but recalc in brew_mol?
@@ -244,9 +277,9 @@ Line_spanner::brew_molecule (SCM smob)
       
       }
 
-  Real thick = me->paper_l ()->get_var ("stafflinethickness");  
+  Real thick = me->get_paper ()->get_var ("linethickness");  
 
-  SCM s = me->get_grob_property ("line-thickness");
+  SCM s = me->get_grob_property ("thickness");
   if (gh_number_p (s))
     thick *= gh_scm2double (s);
 
@@ -259,3 +292,12 @@ Line_spanner::brew_molecule (SCM smob)
 }
 
 
+
+ADD_INTERFACE (Line_spanner, "line-spanner-interface",
+  "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");
+
+