[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
prevent collision of ligatures and next note (issue 6740046)
From: |
benko . pal |
Subject: |
prevent collision of ligatures and next note (issue 6740046) |
Date: |
Fri, 19 Oct 2012 19:25:05 +0000 |
Reviewers: ,
Message:
mensural-ligatures.ly is listed as changed - that is not surprising,
although I couldn't tell in advance _how_ it will change. what is a bit
more surprising that I can't tell even now, having seen the regtest
comparison.
Description:
prevent collision of ligatures and next note
Please review this at http://codereview.appspot.com/6740046/
Affected files:
M lily/mensural-ligature-engraver.cc
M scm/define-grobs.scm
Index: lily/mensural-ligature-engraver.cc
diff --git a/lily/mensural-ligature-engraver.cc
b/lily/mensural-ligature-engraver.cc
index
35b8614b0d62fa2a657510c68b9ac3fc35e37144..848ca0cb4b003a11a0e3cc63cbfe78f1065d7a0a
100644
--- a/lily/mensural-ligature-engraver.cc
+++ b/lily/mensural-ligature-engraver.cc
@@ -64,9 +64,11 @@ public:
TRANSLATOR_DECLARATIONS (Mensural_ligature_engraver);
private:
- void transform_heads (vector<Grob_info> primitives);
- void propagate_properties (Spanner *ligature, vector<Grob_info>
primitives);
- void fold_up_primitives (vector<Grob_info> primitives);
+ void transform_heads (vector<Grob_info> const &primitives);
+ void propagate_properties (Spanner *ligature,
+ vector<Grob_info> const &primitives);
+ void fold_up_primitives (Spanner *ligature,
+ vector<Grob_info> const &primitives);
};
IMPLEMENT_TRANSLATOR_LISTENER (Mensural_ligature_engraver, ligature);
@@ -89,7 +91,7 @@ Mensural_ligature_engraver::create_ligature_spanner ()
}
void
-Mensural_ligature_engraver::transform_heads (vector<Grob_info> primitives)
+Mensural_ligature_engraver::transform_heads (vector<Grob_info> const
&primitives)
{
if (primitives.size () < 2)
{
@@ -336,7 +338,7 @@ Mensural_ligature_engraver::transform_heads
(vector<Grob_info> primitives)
*/
void
Mensural_ligature_engraver::propagate_properties (Spanner *ligature,
- vector<Grob_info>
primitives)
+ vector<Grob_info> const
&primitives)
{
Real thickness
= robust_scm2double (ligature->get_property ("thickness"), 1.3);
@@ -349,6 +351,7 @@ Mensural_ligature_engraver::propagate_properties
(Spanner *ligature,
Real maxima_head_width
= Font_interface::get_default_font (ligature)->
find_by_name ("noteheads.sM3ligmensural").extent (X_AXIS).length ();
+ Real min_length = 0.0;
Item *prev_primitive = NULL;
for (vsize i = 0; i < primitives.size (); i++)
@@ -362,9 +365,11 @@ Mensural_ligature_engraver::propagate_properties
(Spanner *ligature,
{
case MLP_BREVIS:
case MLP_LONGA:
+ min_length += head_width;
primitive->set_property ("head-width", scm_from_double
(head_width));
break;
case MLP_MAXIMA:
+ min_length += maxima_head_width;
primitive->set_property ("head-width",
scm_from_double (maxima_head_width));
break;
@@ -377,6 +382,7 @@ Mensural_ligature_engraver::propagate_properties
(Spanner *ligature,
{
SCM flexa_scm = primitive->get_property ("flexa-width");
Real const flexa_width = robust_scm2double (flexa_scm, 2.0);
+ min_length += flexa_width + thickness;
SCM head_width = scm_from_double (0.5 * (flexa_width +
thickness));
primitive->set_property ("head-width", head_width);
prev_primitive->set_property ("head-width", head_width);
@@ -390,10 +396,13 @@ Mensural_ligature_engraver::propagate_properties
(Spanner *ligature,
prev_primitive = primitive;
}
+
+ ligature->set_property ("minimum-length", scm_from_double (min_length));
}
void
-Mensural_ligature_engraver::fold_up_primitives (vector<Grob_info>
primitives)
+Mensural_ligature_engraver::fold_up_primitives (Spanner *ligature,
+ vector<Grob_info> const
&primitives)
{
Item *first = 0;
Real distance = 0.0;
@@ -416,7 +425,7 @@ Mensural_ligature_engraver::fold_up_primitives
(vector<Grob_info> primitives)
Real head_width = scm_to_double (current->get_property
("head-width"));
distance += head_width - thickness;
- if (Rhythmic_head::dot_count (current) > 0)
+ if (size_t const dot_count = Rhythmic_head::dot_count (current))
/*
Move dots above/behind the ligature.
dots should also avoid staff lines.
@@ -452,6 +461,12 @@ Mensural_ligature_engraver::fold_up_primitives
(vector<Grob_info> primitives)
else if (delta == 1 || delta == -1)
vert_shift -= delta * staff_space;
}
+ else
+ ligature->set_property
+ ("minimum-length",
+ scm_from_double
+ (head_width*dot_count + robust_scm2double
+ (ligature->get_property ("minimum-length"), 0.0)));
dot_gr->translate_axis (vert_shift, Y_AXIS);
@@ -470,7 +485,7 @@ Mensural_ligature_engraver::build_ligature (Spanner
*ligature,
{
transform_heads (primitives);
propagate_properties (ligature, primitives);
- fold_up_primitives (primitives);
+ fold_up_primitives (ligature, primitives);
}
ADD_ACKNOWLEDGER (Mensural_ligature_engraver, rest);
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index
28bc6d04d4199d2f0528b3b5ecce554f7ff93f68..1ebd9c34e88263d05d7b92dccb541b848e62d332
100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1343,6 +1343,7 @@
(MensuralLigature
. (
+ (springs-and-rods . ,ly:spanner::set-spacing-rods)
(stencil . ,ly:mensural-ligature::print)
(thickness . 1.3)
(meta . ((class . Spanner)