]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-interface.cc
($(outdir)/%.pdf): add DVIPS_FLAGS. This will
[lilypond.git] / lily / line-interface.cc
index cac08cc08e607b2191d83e12851377f2fbd9de2c..091eac7cf1050d3e9b3202276568a08332663212 100644 (file)
@@ -8,14 +8,14 @@ source file of the GNU LilyPond music typesetter
  */
 
 #include "line-interface.hh"
-#include "molecule.hh"
+#include "stencil.hh"
 #include "grob.hh"
 #include "staff-symbol-referencer.hh"
 #include "lookup.hh"
+#include "paper-def.hh"
 
 
-
-Molecule
+Stencil
 Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
                             Real dash_period, Real dash_fraction)
 {
@@ -38,39 +38,70 @@ Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
   box[X_AXIS].widen (thick/2);
   box[Y_AXIS].widen (thick/2);  
 
-  Molecule m = Molecule (box, at);
+  Stencil m = Stencil (box, at);
   m.translate (from);
   return m;
 }
-/*
-  TODO: read THICK from ME
- */
-Molecule
-Line_interface::dashed_line (Grob *me, Real thick, Offset from, Offset to)
+
+Stencil
+Line_interface::make_line (Real th, Offset from, Offset to)
 {
+  SCM at = scm_list_n (ly_symbol2scm ("draw-line"),
+                       gh_double2scm (th), 
+                       gh_double2scm (from[X_AXIS]),
+                       gh_double2scm (from[Y_AXIS]),
+                       gh_double2scm (to[X_AXIS]),
+                       gh_double2scm (to[Y_AXIS]),
+                       SCM_UNDEFINED);
+
+  Box box;
+  box.add_point (from);
+  box.add_point (to);
+
+  box[X_AXIS].widen (th/2);
+  box[Y_AXIS].widen (th/2);  
+
+  return Stencil (box, at);
+}
+
+Stencil
+Line_interface::line (Grob *me, Offset from, Offset to)
+{
+  Real thick = Staff_symbol_referencer::line_thickness (me)
+    * robust_scm2double (me->get_grob_property ("thickness"),1);
+  
   SCM type = me->get_grob_property ("style");
-  if (type == ly_symbol2scm ("dotted-line")
-      || type == ly_symbol2scm ("dashed-line"))
-    {
-      Real fraction =
-       robust_scm2double (me->get_grob_property ("dash-fraction"),
-                          (type == ly_symbol2scm ("dotted-line")) ? 0.0 : 0.4);
 
+  SCM dash_fraction = me->get_grob_property ("dash-fraction");
+  if (gh_number_p (dash_fraction) || type == ly_symbol2scm ("dotted-line"))
+    {
+      
+      Real fraction
+       = type == ly_symbol2scm ("dotted-line")
+       ? 0.0
+       : robust_scm2double (dash_fraction, 0.4);
+      
       fraction = (fraction >? 0) <? 1.0;
       Real period = Staff_symbol_referencer::staff_space (me)
        * robust_scm2double (me->get_grob_property ("dash-period"), 1.0);
 
       if (period < 0)
-       return Molecule ();
-       
+       return Stencil ();
+  
       return make_dashed_line (thick, from, to, period, fraction);
     }
   else
     {
-      return Lookup::line (thick, from, to);
+      return make_line (thick, from, to);
     }
 }
 
 ADD_INTERFACE(Line_interface, "line-interface",
-             "Generic line objects. Any object using lines supports this. ",
+             "Generic line objects. Any object using lines supports this.  Normally,"
+             "you get a straight line. If dash-period is defined, a dashed line is "
+             "produced; the length of the dashes is tuned with" 
+             "@code{dash-fraction}. If the latter is set to 0, a dotted line is "
+             "produced. If @code{dash-fraction} is negative, the line is set "
+             "transparent.",
+             
              "dash-period dash-fraction thickness style")