summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>2007-01-24 13:25:18 +0100
committerHan-Wen Nienhuys <hanwen@xs4all.nl>2007-01-24 13:25:18 +0100
commitc8125dcfe0e590d855ed1cade526db54afb1dc1d (patch)
treecf274cf72821193738f979b2b85e8c03daf37fc7
parent767d1f1909e4f02ec58c3b71a35d70e04a0c8baa (diff)
move trill line into line-interface. Allows angled trill lines.
-rw-r--r--input/regression/line-style.ly24
-rw-r--r--lily/include/line-interface.hh5
-rw-r--r--lily/line-interface.cc52
-rw-r--r--lily/line-spanner.cc46
-rw-r--r--lily/new-line-spanner.cc72
5 files changed, 83 insertions, 116 deletions
diff --git a/input/regression/line-style.ly b/input/regression/line-style.ly
new file mode 100644
index 0000000000..4d33f4945b
--- /dev/null
+++ b/input/regression/line-style.ly
@@ -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
+}
diff --git a/lily/include/line-interface.hh b/lily/include/line-interface.hh
index ccbd83eba1..fa94b9f711 100644
--- a/lily/include/line-interface.hh
+++ b/lily/include/line-interface.hh
@@ -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);
diff --git a/lily/line-interface.cc b/lily/line-interface.cc
index fcfa28e93c..8c54fa7ed1 100644
--- a/lily/line-interface.cc
+++ b/lily/line-interface.cc
@@ -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");
diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc
index 0bbe92ad34..7a8870aee5 100644
--- a/lily/line-spanner.cc
+++ b/lily/line-spanner.cc
@@ -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));
diff --git a/lily/new-line-spanner.cc b/lily/new-line-spanner.cc
index 85959653cd..4bc7896d44 100644
--- a/lily/new-line-spanner.cc
+++ b/lily/new-line-spanner.cc
@@ -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 ();
}