]> git.donarmstrong.com Git - lilypond.git/commitdiff
move trill line into line-interface. Allows angled trill lines.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 24 Jan 2007 12:25:18 +0000 (13:25 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 24 Jan 2007 12:25:18 +0000 (13:25 +0100)
input/regression/line-style.ly [new file with mode: 0644]
lily/include/line-interface.hh
lily/line-interface.cc
lily/line-spanner.cc
lily/new-line-spanner.cc

diff --git a/input/regression/line-style.ly b/input/regression/line-style.ly
new file mode 100644 (file)
index 0000000..4d33f49
--- /dev/null
@@ -0,0 +1,24 @@
+\header {
+  texidoc = "Cover all line styles available"
+  
+}
+\version "2.11.13"
+\paper {
+  ragged-right = ##T
+}
+
+\relative c'' {
+  \override Glissando #'breakable = ##t
+
+  s2
+  d2 \glissando d'2
+  \once \override Glissando #'dash-fraction = #0.5
+  d,2 \glissando d'2
+  \override Glissando #'style = #'dotted-line
+  d,2 \glissando d'2
+
+  \override Glissando #'style = #'zigzag
+  d,2 \glissando d'2
+  \override Glissando #'style = #'trill
+  d,2 \glissando d'2
+}
index ccbd83eba121f648bd21e483a9ec02b4afef01c3..fa94b9f71185fc5813bce3229b8f0e09e64ede18 100644 (file)
@@ -16,7 +16,10 @@ struct Line_interface
 {
   static Stencil line (Grob *me, Offset from, Offset to);
   DECLARE_GROB_INTERFACE();
-  static Stencil zigzag_stencil (Grob *me,
+  static Stencil make_zigzag_line (Grob *me,
+                                  Offset from,
+                                  Offset to);
+  static Stencil make_trill_line (Grob *me,
                                 Offset from,
                                 Offset to);
   static Stencil make_dashed_line (Real th, Offset from, Offset to, Real, Real);
index fcfa28e93cf3d86b6e47daa5826deb16059ab47b..8c54fa7ed1d35a31aa9ca34405fd2a3e64bf7ec7 100644 (file)
@@ -12,6 +12,7 @@
 #include "lookup.hh"
 #include "output-def.hh"
 #include "grob.hh"
+#include "font-interface.hh"
 
 Stencil
 Line_interface::make_arrow (Offset begin, Offset end,
@@ -32,9 +33,49 @@ Line_interface::make_arrow (Offset begin, Offset end,
 }
 
 Stencil
-Line_interface::zigzag_stencil (Grob *me,
-                               Offset from,
-                               Offset to)
+Line_interface::make_trill_line (Grob *me,
+                                Offset from,
+                                Offset to)
+{
+  Offset dz = (to-from);
+  SCM alist_chain = Font_interface::text_font_alist_chain (me);
+  SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"),
+                                         ly_symbol2scm ("fetaMusic")),
+                               SCM_UNDEFINED);
+
+  Font_metric *fm = select_font (me->layout (),
+                                scm_cons (style_alist,
+                                          alist_chain));
+
+  Stencil elt = fm->find_by_name ("scripts.trill_element");
+
+  Real elt_len = elt.extent (X_AXIS).length ();
+  if (elt_len <= 0.0)
+    {
+      programming_error ("can't find scripts.trill_element");
+      return Stencil ();
+    }
+      
+  Stencil line;
+  Real len = 0.0;
+  do
+    {
+      line.add_at_edge (X_AXIS, RIGHT, elt, 0);
+      len = line.extent (X_AXIS).length ();
+    }
+  while (len + elt_len < dz.length ());
+
+  line.rotate (dz.arg (), Offset (0,0));
+  line.translate (from);
+
+  return line; 
+}
+
+
+Stencil
+Line_interface::make_zigzag_line (Grob *me,
+                                 Offset from,
+                                 Offset to)
 {
   Offset dz = to -from;
 
@@ -164,8 +205,11 @@ Line_interface::line (Grob *me, Offset from, Offset to)
   SCM type = me->get_property ("style");
   if (type == ly_symbol2scm ("zigzag"))
     {
-      return zigzag_stencil (me, from, to);
+      return make_zigzag_line (me, from, to);
     }
+  else if (type == ly_symbol2scm ("trill"))
+    return make_trill_line (me, from, to);
+  
   Stencil stil;
 
   SCM dash_fraction = me->get_property ("dash-fraction");
index 0bbe92ad3480d53485e1919209d0e8ed7397fe6c..7a8870aee5d8c4ac4f0ab0ac682e5e56d225198e 100644 (file)
@@ -57,51 +57,7 @@ Line_spanner::line_stencil (Grob *me,
                            Offset from,
                            Offset to)
 {
-  Offset dz = to -from;
-  SCM type = me->get_property ("style");
-
-  Stencil line;
-
-  if (scm_is_symbol (type)
-      && (type == ly_symbol2scm ("line")
-         || type == ly_symbol2scm ("dashed-line")
-         || type == ly_symbol2scm ("dotted-line")
-         || type == ly_symbol2scm ("zigzag")
-         || (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
-    {
-      line = Line_interface::line (me, from, to);
-    }
-  else if (scm_is_symbol (type)
-          && type == ly_symbol2scm ("trill"))
-    {
-      SCM alist_chain = Font_interface::text_font_alist_chain (me);
-      SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"),
-                                             ly_symbol2scm ("fetaMusic")),
-                                   SCM_UNDEFINED);
-
-      Font_metric *fm = select_font (me->layout (),
-                                    scm_cons (style_alist,
-                                              alist_chain));
-      Stencil m = fm->find_by_name ("scripts.trill_element");
-      Stencil mol;
-
-      do
-       mol.add_at_edge (X_AXIS, RIGHT, m, 0);
-      while (m.extent (X_AXIS).length ()
-            && mol.extent (X_AXIS).length ()
-            + m.extent (X_AXIS).length () < dz[X_AXIS])
-       ;
-
-      /*
-       FIXME: should center element on x/y
-      */
-      mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS);
-      mol.translate_axis (- (mol.extent (Y_AXIS)[DOWN]
-                            + mol.extent (Y_AXIS).length ()) / 2, Y_AXIS);
-
-      mol.translate (from);
-      line = mol;
-    }
+  Stencil line = Line_interface::line (me, from, to);
 
   if (to_boolean (me->get_property ("arrow")))
     line.add_stencil (Line_interface::arrows (me, from, to, false, true));
index 85959653cda70b31c69a38c6d0caa6681bedce41..4bc7896d444d12f88b2b5e9b2828972c5c93e28c 100644 (file)
@@ -30,8 +30,6 @@ public:
   DECLARE_SCHEME_CALLBACK (calc_right_bound_info, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_bound_info, (SCM, Direction));
   DECLARE_GROB_INTERFACE();
-
-  static Stencil line_stencil (Grob *me, Offset f, Offset t);
 };
 
 
@@ -52,65 +50,6 @@ line_spanner_common_parent (Grob *me)
   return common;
 }
 
-
-Stencil
-New_line_spanner::line_stencil (Grob *me,
-                           Offset from,
-                           Offset to)
-{
-  Offset dz = to -from;
-  SCM type = me->get_property ("style");
-
-  Stencil line;
-
-  if (scm_is_symbol (type)
-      && (type == ly_symbol2scm ("line")
-         || type == ly_symbol2scm ("dashed-line")
-         || type == ly_symbol2scm ("dotted-line")
-         || type == ly_symbol2scm ("zigzag")
-         || (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
-    {
-      line = Line_interface::line (me, from, to);
-    }
-  else if (scm_is_symbol (type)
-          && type == ly_symbol2scm ("trill"))
-    {
-      SCM alist_chain = Font_interface::text_font_alist_chain (me);
-      SCM style_alist = scm_list_n (scm_cons (ly_symbol2scm ("font-encoding"),
-                                             ly_symbol2scm ("fetaMusic")),
-                                   SCM_UNDEFINED);
-
-      Font_metric *fm = select_font (me->layout (),
-                                    scm_cons (style_alist,
-                                              alist_chain));
-      Stencil m = fm->find_by_name ("scripts.trill_element");
-      Stencil mol;
-
-      do
-       mol.add_at_edge (X_AXIS, RIGHT, m, 0);
-      while (m.extent (X_AXIS).length ()
-            && mol.extent (X_AXIS).length ()
-            + m.extent (X_AXIS).length () < dz[X_AXIS])
-       ;
-
-      /*
-       FIXME: should center element on x/y
-      */
-      mol.translate_axis (m.extent (X_AXIS).length () / 2, X_AXIS);
-      mol.translate_axis (- (mol.extent (Y_AXIS)[DOWN]
-                            + mol.extent (Y_AXIS).length ()) / 2, Y_AXIS);
-
-      mol.translate (from);
-      line = mol;
-    }
-
-  if (to_boolean (me->get_property ("arrow")))
-    line.add_stencil (Line_interface::arrows (me, from, to, false, true));
-
-  return line;
-}
-
-
 SCM
 New_line_spanner::calc_bound_info (SCM smob, Direction dir)
 {
@@ -279,18 +218,19 @@ New_line_spanner::print (SCM smob)
   
   span_points[LEFT] -= my_z;
   span_points[RIGHT] -= my_z;
-  
-  Stencil line = line_stencil (me,
-                              span_points[LEFT],
-                              span_points[RIGHT]);
 
+  
+  
+  Stencil line = Line_interface::line (me, 
+                                      span_points[LEFT],
+                                      span_points[RIGHT]);
 
   line.add_stencil (Line_interface::arrows (me,
                                            span_points[LEFT],
                                            span_points[RIGHT],
                                            arrows[LEFT],
                                            arrows[RIGHT]));
-                                           
+
   return line.smobbed_copy ();
 }