]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-spanner.cc
po-replace
[lilypond.git] / lily / line-spanner.cc
index c9071393cfb62c2ff185fef1278e8e851e4b15bf..5ba97cf8e3c2eaa8903fc38eee1c12b2b10c865e 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "molecule.hh"
 
 #include <math.h>
 
-SCM
-Line_spanner::line_atom (Grob* me, Real dx, Real dy)
+
+/*
+  slightishly clumsy interface?
+
+  Make  a Scheme expression for a line going from (0,0) to (dx,dy). 
+ */
+
+static SCM
+line_atom (Grob* me, Real thick, Real dx, Real dy)
 {
   SCM type = me->get_grob_property ("type");
   Real staff_space = Staff_symbol_referencer::staff_space (me);
-  Real thick = me->paper_l ()->get_var ("stafflinethickness");  
-
-  SCM s = me->get_grob_property ("line-thickness");
-  if (gh_number_p (s))
-    thick *= gh_scm2double (s);
   
       // maybe these should be in line-thickness?
   Real length = staff_space;
-  s = me->get_grob_property ("dash-length");
+  SCM s = me->get_grob_property ("dash-length");
   if (gh_number_p (s))
     length = gh_scm2double (s) * staff_space;
 
@@ -48,7 +50,7 @@ Line_spanner::line_atom (Grob* me, Real dx, Real dy)
   Real on = length - thick;
   Real off = period - on;
 
-  SCM list = scm_listify (ly_symbol2scm ("dashed-line"),
+  SCM list = scm_list_n (ly_symbol2scm ("dashed-line"),
                      gh_double2scm (thick),
                      gh_double2scm (on),
                      gh_double2scm (off),
@@ -60,7 +62,7 @@ Line_spanner::line_atom (Grob* me, Real dx, Real dy)
 }
 
 Molecule
-Line_spanner::line_molecule (Grob* me, Real dx, Real dy)
+Line_spanner::line_molecule (Grob* me, Real thick, Real dx, Real dy)
 {
   Molecule mol;
   SCM type = me->get_grob_property ("type");
@@ -70,19 +72,20 @@ Line_spanner::line_molecule (Grob* me, Real dx, Real dy)
          || type == ly_symbol2scm ("dotted-line")
          || (type == ly_symbol2scm ("trill") && dy != 0)))
     {
-      Box b (Interval (0, dx), Interval (0, dy));
-      mol = Molecule (b, line_atom (me, dx, dy));
+      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, line_atom (me, thick, dx, dy));
     }
   else if (gh_symbol_p (type)
           && type == ly_symbol2scm ("trill"))
     {
       SCM alist_chain = Font_interface::font_alist_chain (me);
-      SCM style_chain = scm_listify (gh_cons (ly_symbol2scm ("font-family"),
+      SCM style_chain = scm_list_n (gh_cons (ly_symbol2scm ("font-family"),
                                          ly_symbol2scm ("music")),
                                 SCM_UNDEFINED);
       
       Font_metric *fm = Font_interface::get_font (me,
-                                                 scm_listify (style_chain,
+                                                 scm_list_n (style_chain,
                                                           alist_chain,
                                                           SCM_UNDEFINED));
       Molecule m = fm->find_by_name ("scripts-trill-element");
@@ -240,8 +243,15 @@ Line_spanner::brew_molecule (SCM smob)
                                                          Y_AXIS)); 
       
       }
+
+  Real thick = me->paper_l ()->get_var ("linethickness");  
+
+  SCM s = me->get_grob_property ("thickness");
+  if (gh_number_p (s))
+    thick *= gh_scm2double (s);
+
   
-  Molecule line = line_molecule (me, dxy[X_AXIS], dxy[Y_AXIS]);
+  Molecule line = line_molecule (me, thick, dxy[X_AXIS], dxy[Y_AXIS]);
   line.translate_axis (bound[LEFT]->extent (bound[LEFT],
                                            X_AXIS).length ()/2, X_AXIS); 
   line.translate (ofxy - my_off + his_off);
@@ -249,3 +259,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.   ",
+  "gap dash-period dash-length thickness type");
+
+