]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-interface.cc
accidental-engraver cleanups.
[lilypond.git] / lily / line-interface.cc
index fab325528f90dffed69636ab33be3d034c5c9816..f65dc946f2c70b62d7196f66159d99c2c1307dde 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2004--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "line-interface.hh"
@@ -11,6 +11,7 @@
 #include "staff-symbol-referencer.hh"
 #include "lookup.hh"
 #include "output-def.hh"
+#include "grob.hh"
 
 Stencil
 Line_interface::make_arrow (Offset begin, Offset end,
@@ -18,13 +19,13 @@ Line_interface::make_arrow (Offset begin, Offset end,
                            Real length, Real width)
 {
   Real angle = (end - begin).arg ();
-  Array<Offset> points;
+  vector<Offset> points;
 
-  points.push (Offset (0, 0));
-  points.push (Offset (-length, width));
-  points.push (Offset (-length, -width));
+  points.push_back (Offset (0, 0));
+  points.push_back (Offset (-length, width));
+  points.push_back (Offset (-length, -width));
 
-  for (int i = 0; i < points.size (); i++)
+  for (vsize i = 0; i < points.size (); i++)
     points[i] = points[i] * complex_exp (Offset (0, angle)) + end;
 
   return Lookup::round_filled_polygon (points, thick);
@@ -44,6 +45,7 @@ Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
                       scm_from_double (off),
                       scm_from_double (to[X_AXIS] - from[X_AXIS]),
                       scm_from_double (to[Y_AXIS] - from[Y_AXIS]),
+                      scm_from_double (0.0),
                       SCM_UNDEFINED);
 
   Box box;
@@ -138,7 +140,7 @@ Line_interface::line (Grob *me, Offset from, Offset to)
   return stil;
 }
 
-ADD_INTERFACE (Line_interface, "line-interface",
+ADD_INTERFACE (Line_interface,
               "Generic line objects. Any object using lines supports this.  Normally, "
               "you get a straight line. If @code{dash-period} is defined, a dashed line is "
               "produced; the length of the dashes is tuned with "
@@ -146,4 +148,29 @@ ADD_INTERFACE (Line_interface, "line-interface",
               "produced. If @code{dash-fraction} is negative, the line is made "
               "transparent.",
 
-              "dash-period dash-fraction thickness style arrow-length arrow-width")
+              /* properties */
+              "dash-period "
+              "dash-fraction "
+              "thickness "
+              "style "
+              "arrow-length "
+              "arrow-width")
+
+
+
+/* todo: move this somewhere else? */
+Stencil
+points_to_line_stencil (vector<Offset> points)
+{
+  Stencil ret;
+  for (vsize i = 1; i < points.size (); i++)
+    {
+      if (points[i-1].is_sane ()  && points[i].is_sane ())
+       {
+         Stencil line
+           = Line_interface::make_line (0.1, points[i-1], points[i]);
+         ret.add_stencil (line);
+       }
+    }
+  return ret;
+}